Magnetic Pendulum Chaos

A pendulum swings above three magnets locked in chaotic dance — inverse-square-ish attraction plus a linear restoring force and viscous damping. The trail color reveals which magnet dominates the local pull, blended by inverse-distance weighting across all three. Physics is integrated with a 4x-substepped semi-implicit Euler scheme for stability, and the 140-point trail is rebuilt every frame as a CatmullRom tube with per-vertex fade.

Controls