438

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


import type { ArtRenderer, ParameterState, RenderContext, TimeState } from '../../types/engine';
import { hsla } from '../common/color';

// 2D Chladni Resonance Pattern: w = a*sin(n*pi*x)*sin(m*pi*y) - b*sin(m*pi*x)*sin(n*pi*y)
export function createStandingWaveGrid(): ArtRenderer {
  const MAX_SAND = 3000;
  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: RenderContext, timeState: TimeState, params: ParameterState) {
      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];

        // Chladni nodal plate equation
        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);

        // Particles drift toward nodal lines where vibration is zero
        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 * 0.0006 + (Math.random() - 0.5) * 0.002;
        py[i] -= gradY * 0.0006 + (Math.random() - 0.5) * 0.002;

        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);
      }
    },
  };
}
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
113 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! ✨