PHYS·02 Kepler — an orbital mechanics sandbox: a central star, satellites launched by slingshot drag with a dotted preview of their simulated future, symplectic integration so ellipses persist, trails colored by speed

Physics Lab · Experiment 02 · celestial mechanics

Falling, forever.

A star, some moons, and an inverse-square law. An orbit is just a fall that keeps missing. Tap anywhere to add a moon in a perfect circle — then head to the bench to launch by hand and watch the circles break into ellipses.

3 moons
scroll
[00]The law

one force, everything downstream of it

Force
inverse square — a = −GM·r̂ / r² · that's the entire rulebook
Integrator
semi-implicit Euler, 8 substeps · it's symplectic, so orbits don't quietly decay or inflate over minutes
Launch
drag back like a slingshot on the bench · the dotted line is the moon's actual future, 320 steps simulated per frame
Trail
colored by speed — terra when coasting at apoapsis, bone-white when whipping past the star
Endings
fall in and you flare · leave the frame far enough and you're quietly forgotten
Status
🟢 in orbit · sims pause offscreen · max 14 bodies
[01]Six observations

what Kepler saw without a canvas element

01 · ellipses

Ellipses come free

Nothing in the code draws an ellipse. The inverse-square law plus a sideways shove produces them on its own — the shape is a consequence, not an instruction.

02 · equal areas

Fast near, slow far

Kepler's second law, visible as trail color: the moon sprints past the star and dawdles at the far end.

03 · the future

The preview is not a guess

While you aim, a phantom copy of your moon is integrated 320 steps ahead every frame. The dots are physics, not a bezier drawn to look plausible.

04 · symplectic

Why the orbit survives

Update velocity first, then position with the new velocity. That one-line reordering conserves a shadow of the true energy — RK4's fancier cousin for long-running orbits.

05 · slingshot

Drag back, let fly

Pull away from where you want to go. Every playground intuition applies.

06 · escape

Two ways to leave

Launch too hard and the conic flips from ellipse to hyperbola — the moon leaves and never returns. Launch too soft and the star collects you with a small flare. The interesting lives are in between.

[02]The bench

press, drag back, release to launch · dotted line = simulated future · star mass bends every orbit live

star mass 100
Field note: the hero is deliberately tap-only — touch-action: pan-y means your thumb can always scroll past a full-screen canvas. The bench claims the whole gesture (touch-action: none) but only stands ~60svh tall, so the page never traps you. Slide the mass mid-flight: every trajectory, including the preview, re-bends instantly.