228

Standing Wave Grid

Ernst Chladni's vibrating plate acoustics where thousands of microscopic sand grains migrate to static zero-vibration nodal lines.

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

Full Executable Algorithm Code

// 018 - Standing Wave Grid (waves)
// 1:1 Original algorithm engine source
function createStandingWaveGrid() {
  const MAX_SAND = 3e3;
  const px = new Float32Array(MAX_SAND);
  const py = new Float32Array(MAX_SAND);
  return {
    setup() {
      for (let i = 0; i < MAX_SAND; i++) {
        px[i] = Math.random();
        py[i] = Math.random();
      }
    },
    render(context, timeState, params) {
      const { ctx, width, height } = context;
      const count = Math.min(MAX_SAND, Number(params.sandCount || 2400));
      const n = Number(params.modeN || 3) + Math.sin(timeState.time * 0.3) * 0.5;
      const m = Number(params.modeM || 5) + Math.cos(timeState.time * 0.25) * 0.5;
      const t = timeState.time;
      ctx.fillStyle = "rgba(8, 9, 13, 0.2)";
      ctx.fillRect(0, 0, width, height);
      for (let i = 0; i < count; i++) {
        const x = px[i];
        const y = py[i];
        const val = Math.sin(n * Math.PI * x) * Math.sin(m * Math.PI * y) - Math.sin(m * Math.PI * x) * Math.sin(n * Math.PI * y);
        const eps = 0.01;
        const valDx = Math.sin(n * Math.PI * (x + eps)) * Math.sin(m * Math.PI * y) - Math.sin(m * Math.PI * (x + eps)) * Math.sin(n * Math.PI * y);
        const valDy = Math.sin(n * Math.PI * x) * Math.sin(m * Math.PI * (y + eps)) - Math.sin(m * Math.PI * x) * Math.sin(n * Math.PI * (y + eps));
        const gradX = (Math.abs(valDx) - Math.abs(val)) / eps;
        const gradY = (Math.abs(valDy) - Math.abs(val)) / eps;
        px[i] -= gradX * 6e-4 + (Math.random() - 0.5) * 2e-3;
        py[i] -= gradY * 6e-4 + (Math.random() - 0.5) * 2e-3;
        if (px[i] < 0) px[i] = Math.random();
        if (px[i] > 1) px[i] = Math.random();
        if (py[i] < 0) py[i] = Math.random();
        if (py[i] > 1) py[i] = Math.random();
        const renderX = px[i] * width;
        const renderY = py[i] * height;
        const hue = (210 + Math.abs(val) * 120 + t * 10) % 360;
        ctx.fillStyle = hsla(hue, 90, 70, 0.8);
        ctx.fillRect(renderX, renderY, 1.6, 1.6);
      }
    }
  };
}

// Default parameters from content metadata
const defaultParams = [
  {
    "key": "modeN",
    "label": "Eigenmode N",
    "type": "range",
    "min": 1,
    "max": 8,
    "step": 1,
    "defaultValue": 3,
    "description": "Horizontal harmonic mode"
  },
  {
    "key": "modeM",
    "label": "Eigenmode M",
    "type": "range",
    "min": 1,
    "max": 8,
    "step": 1,
    "defaultValue": 5,
    "description": "Vertical harmonic mode"
  }
];

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

const instance = window.__art_instances['standing-wave-grid'];
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
Wn,m(x,y)=asin(nπxL)sin(mπyL)bsin(mπxL)sin(nπyL)=0W_{n,m}(x,y) = a \sin\left(\frac{n\pi x}{L}\right)\sin\left(\frac{m\pi y}{L}\right) - b \sin\left(\frac{m\pi x}{L}\right)\sin\left(\frac{n\pi y}{L}\right) = 0
Click to expand
Compact Formula
w(x, y) = sin(nπx)*sin(mπy) - sin(mπx)*sin(nπy), p -= ∇|w| * dt

Mathematical Tags

#chladni #acoustics #resonance #standing-waves #physics #particles
Author: Math Art Core Target: 60 FPS

Export & Embed: Standing Wave Grid

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/standing-wave-grid" 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! ✨