Force ×1.0

Magnet Lab

An interactive 2D physics sandbox built from real magnetic dipole equations. Place magnets, watch them snap together, enable field-line streamers, and explore how different materials behave.

Physics Model

Each magnet is two point charges — a North pole and a South pole at opposite ends. Force between any two poles:

F = K × q₁ × q₂ / (r² + SOFT) // K = 2800 — force constant // SOFT = 100 — prevents singularity at r=0 // Opposite charges → attract (N pulls S) // Same charges → repel (N pushes N) // 1/r⁴ dipole falloff emerges naturally at range. // Torque = arm × F — magnets align on their own.

Why they stick: Nearly-inelastic collision (COR = 0.05) absorbs 95% of impact energy. The magnetic potential well holds them together.

Why they don't go crazy: High angular damping (DAMP_W = 0.70/frame) kills spin runaway from torque asymmetry. Confirmed fix from Bullet/Box2D physics research — angular damping is the critical stabilizer.

// The three parameters that make it stable: DAMP_V = 0.86 // surface friction (per frame) DAMP_W = 0.70 // angular friction — CRITICAL INERT[bar] = 65 // high inertia = slow to spin up

Materials

Ferrite
Ceramic · ~3.5 MGOe
×2
Common fridge magnet. Cheap, stable, no corrosion.
Alnico 5
Al·Ni·Co · ~5.5 MGOe
×4.5
Survives 500°C. Easy to accidentally demagnetize.
Neodymium N52
NdFeB · 52 MGOe
×8
Strongest ever made. Brittle, fails above 80°C.
SmCo
Sm·Co · ~30 MGOe
×6.5
Rated 300°C+. Aerospace grade. Very expensive.

Steel ball/plate: Ferromagnetic — attracted toward field gradients (∇B²).

Bismuth: Diamagnetic — genuinely repelled. Strongest diamagnetic pure element.

Copper: Eddy current braking — opposes magnet motion proportional to B²×v.

Controls

InputAction
Click toolbarSelect object to place
Click canvasPlace selected object
DragMove object (throw on release)
Right-clickDelete object
Dbl-click coilFlip electromagnet polarity
Pin → clickLock / unlock object
Force sliderScale all forces ×0.2–×3.0
Hover toolbarMaterial info tooltip

Credits

Dev
Kigan
kigan9900
Built everything — physics, canvas, icons, design.
Typography
Google Fonts
Fredoka One, Space Mono, Nunito.
Physics Ref
K&J Magnetics
kjmagnetics.com
Force calculation and material data reference.
Stability Ref
Box2D / Bullet
Angular damping fix for rigid body torque instability.

v1.1 · Single HTML file · ~55kb · No frameworks · 2026