228

Vortex Filament Drift

Classical inviscid point vortices rotating under mutual induced velocities, tracing complex filamentary chaotic orbits.

Playground
60 FPS Canvas 2D
Click + Drag to interact with field
</>

Full Executable Algorithm Code

// 005 - Vortex Filament Drift (fluid)
// 1:1 Original algorithm engine source
function createVortexFilament() {
  const MAX_PARTICLES = 2e3;
  const px = new Float32Array(MAX_PARTICLES);
  const py = new Float32Array(MAX_PARTICLES);
  const vortexX = new Float32Array(4);
  const vortexY = new Float32Array(4);
  const vortexGamma = new Float32Array([120, -140, 100, -110]);
  return {
    setup(context) {
      for (let i = 0; i < MAX_PARTICLES; i++) {
        px[i] = Math.random() * context.width;
        py[i] = Math.random() * context.height;
      }
    },
    render(context, timeState, params) {
      const { ctx, width, height } = context;
      const count = Math.min(MAX_PARTICLES, Number(params.particleCount || 1600));
      const coreR = Number(params.coreRadius || 20);
      const coreRSq = coreR * coreR;
      const t = timeState.time * 0.8;
      ctx.fillStyle = "rgba(8, 9, 13, 0.18)";
      ctx.fillRect(0, 0, width, height);
      const cx = width * 0.5;
      const cy = height * 0.5;
      const rOrb = Math.min(width, height) * 0.25;
      vortexX[0] = cx + Math.cos(t) * rOrb;
      vortexY[0] = cy + Math.sin(t) * rOrb;
      vortexX[1] = cx + Math.cos(t + Math.PI) * rOrb;
      vortexY[1] = cy + Math.sin(t + Math.PI) * rOrb;
      vortexX[2] = cx + Math.cos(-t * 1.3 + 1.2) * (rOrb * 0.6);
      vortexY[2] = cy + Math.sin(-t * 1.3 + 1.2) * (rOrb * 0.6);
      vortexX[3] = cx + Math.cos(-t * 1.3 - 1.2) * (rOrb * 0.6);
      vortexY[3] = cy + Math.sin(-t * 1.3 - 1.2) * (rOrb * 0.6);
      ctx.lineWidth = 1.1;
      for (let i = 0; i < count; i++) {
        let vx = 0;
        let vy = 0;
        for (let v = 0; v < 4; v++) {
          const dx = px[i] - vortexX[v];
          const dy = py[i] - vortexY[v];
          const dSq = dx * dx + dy * dy;
          const factor = vortexGamma[v] / (2 * Math.PI * (dSq + coreRSq)) * 12;
          vx += -dy * factor;
          vy += dx * factor;
        }
        const oldX = px[i];
        const oldY = py[i];
        px[i] += vx;
        py[i] += vy;
        if (px[i] < 0) px[i] += width;
        if (px[i] > width) px[i] -= width;
        if (py[i] < 0) py[i] += height;
        if (py[i] > height) py[i] -= height;
        const speed = Math.sqrt(vx * vx + vy * vy);
        const hue = (180 + speed * 15 + t * 20) % 360;
        ctx.strokeStyle = hsla(hue, 90, 60, Math.min(0.85, speed * 0.3 + 0.2));
        ctx.beginPath();
        ctx.moveTo(oldX, oldY);
        ctx.lineTo(px[i], py[i]);
        ctx.stroke();
      }
    }
  };
}

// Default parameters from content metadata
const defaultParams = [
  {
    "key": "particleCount",
    "label": "Tracer Count",
    "type": "range",
    "min": 500,
    "max": 2000,
    "step": 100,
    "defaultValue": 1600,
    "description": "Number of fluid tracers"
  },
  {
    "key": "coreRadius",
    "label": "Vortex Core Radius (rc)",
    "type": "range",
    "min": 5,
    "max": 40,
    "step": 1,
    "defaultValue": 20,
    "description": "Vortex core smoothing width"
  }
];

if (!window.__art_instances) window.__art_instances = {};
if (!window.__art_instances['vortex-filament']) {
  const inst = typeof createVortexFilament === 'function' ? createVortexFilament() : null;
  if (inst && inst.setup) {
    inst.setup({ ctx, width, height, dpr: 1, aspectRatio: width / height }, defaultParams);
  }
  window.__art_instances['vortex-filament'] = inst;
}

const instance = window.__art_instances['vortex-filament'];
if (instance && instance.render) {
  instance.render(
    { ctx, width, height, dpr: 1, aspectRatio: width / height },
    { time, deltaTime: dt, frameCount: Math.floor(time * 60), fps: 60 },
    defaultParams
  );
}
Edit in Interactive Playground Zero Dependencies • Standalone Canvas 2D
ƒ

Mathematical Formulation

medium
Analytical Equation
u(x)=i=1NΓi2πk×(xxi)xxi2+rc2\mathbf{u}(\mathbf{x}) = \sum_{i=1}^{N} \frac{\Gamma_i}{2\pi} \frac{\mathbf{k} \times (\mathbf{x} - \mathbf{x}_i)}{\|\mathbf{x} - \mathbf{x}_i\|^2 + r_c^2}
Click to expand
Compact Formula
v_θ(r) = (Γ / 2πr) * (1 - exp(-r² / r_core²))

Mathematical Tags

#vortex #fluid #biot-savart #physics #turbulence #circulation
Author: Math Art Core Target: 60 FPS

Export & Embed: Vortex Filament Drift

4K PNG Snapshot

High-resolution single frame render

WebM Video (5s Loop)

60 FPS browser-captured stream

Standalone JS Script

Complete executable Canvas 2D algorithm

HTML Iframe Embed

<iframe src="https://art.fazleyrabbi.xyz/embed/vortex-filament" width="500" height="500" frameborder="0" loading="lazy"></iframe>
ESC
↑↓ Navigate Select
110 Mathematical Artworks
Made by Fazley Rabbi

Support the Project

Keep mathematical creative coding alive & open source

Or via Direct Payoneer ($0 Fee)
Payoneer Customer ID: $0 Fee Direct
24076084

💡 Payoneer app: Go to Pay → Pay to recipient → Enter ID 24076084.

Thank you for supporting generative mathematical animations! ✨