Magnetic Basin Fractals

WebAssembly renderer · flat attractor-label colors · pan, zoom, and trace the fractal basin

Made by John Dews-Flick 2026

Selected point None
Outcome Select Trace 3D, then click the basin
Loading WASM…

Magnetic Pendulum Model

Each pixel is an initial pendulum position. The solver integrates a damped point mass pulled by fixed magnets, then colors the pixel by the magnet closest to the final resting point.

r'' = Σ km(mi - r) / (||mi - r||² + z0² + ε²)3/2 - ksr - c r'

The left side, r'', is acceleration. The right side adds up three effects: magnetic attraction toward each magnet, a weak spring pulling the pendulum back toward the origin, and damping that removes energy over time.

r = (x, y)
The pendulum bob's horizontal position above the magnet plane.
r' and r''
The bob's velocity and acceleration.
mi
The position of magnet i. The summation adds the pull from every magnet.
km
Magnet strength. Larger values make the magnets pull harder.
z0
The fixed height of the bob above the magnets, keeping the magnetic force finite.
ε
Softening, an extra numerical cushion that prevents extreme forces near a magnet.
ks
Spring constant for the restoring force back toward the center.
c
Damping. This slows the bob until it settles into one magnet's basin.

A basin boundary appears where tiny changes in the starting point send the bob to different final magnets. That sensitivity is what creates the fractal structure.

The 3D trace mode replays that same equation for one selected initial point, showing the path from initial condition to attractor instead of only the final basin color.