Orbits

After Bartosz Ciechanowski, The Moon

Studied 2026-08-192D canvas, velocity Verlet at a fixed step, hand-rolled perspective projection.

Two bodies pulling on each other trace exactly one history. What that historylooks like is a separate question, and it is answered by where you put the origin. Stand still in space and you see two drifting spirals. Stand on the barycentre and you see two nested ellipses. Stand on the first body and you see the single clean ellipse the textbooks draw. An orbit only looks like an ellipse from the right frame, and most of what is confusing about orbits is a frame problem rather than a physics problem.

1 · The playground

Mutual gravity between two or three bodies, integrated with velocity Verlet. Drag a body to move it; drag the tip of its arrow to set its velocity. While paused, the dashed lines are the future — the same integrator run forward and drawn, updating as you drag.

Read this:the potential is softened — the inverse square is evaluated at √(r²+ε²) rather than r — so a near-miss cannot divide by nearly zero and throw a body off the page in one step. Pull softendown to 0.01 and close passes get violent again, which is both the honest behaviour and the reason a fixed-step integrator needs the guard. Velocity Verlet at a fixed 5 ms step: it is symplectic, so energy wanders a little but does not run away.

2 · The same orbit, three frames

One two-body system, solved exactly, drawn three ways. The switcher picks a frame; theblend slider morphs continuously between them, which is the whole point — the frames are not three pictures, they are one picture seen from three origins. Watch the barycentre: it is the only thing here moving in a straight line.

body 1body 2barycentre
Read this:nothing in the physics changes as the slider moves. Only the origin does. Subtract the barycentre and two drifting spirals unwind into two nested ellipses; subtract body 1 and those become the single relative ellipse a textbook draws, with body 1 sitting at its focus. The fixed-space view pans to keep the pair on the canvas — the grid shows the pan — but a pan only slides the curve about, it never changes its shape, which is exactly what a frame change does. At drift 0 the fixed and barycentric frames coincide, which is why a system with no net momentum looks so much simpler than it is.

3 · The ellipse, and equal areas

The relative orbit on its own. Both foci are marked; the body sits on the ellipse and moves at the speed Kepler's equation gives it, fast at periapsis and slow at apoapsis. The wedges are swept over equal intervals of time.

Read this:every wedge covers the same slice of time. Near periapsis the body is close and quick, so it turns through a wide angle over a short radius and the wedge comes out broad and stubby; near apoapsis it is far and slow, and the same time buys a long thin splinter. The measured area holds still while the shape does not — that is Kepler's second law, which is angular momentum conservation wearing a hat. The other constant on the readout is r₁+r₂, the sum of the two focal radii, which is the ellipse's definition.

4 · The plane, and how it drifts

An inclined orbit around a central body, in a hand-rolled perspective projection — drag to swing the camera. The faint disc is the reference plane. Where the orbit crosses it is the line of nodes: ascending in green going up, descending in red going down. Then two slow rotations are added on top, and they are not the same rotation.

ascending nodedescending nodeperiapsis track
Read this: set apsidal to zero and the ellipse is carried round rigidly: the node line sweeps, but periapsis keeps exactly the same angle from the ascending node, so nothing about the orbit changes relative to its own plane. Set nodal to zero instead and the plane holds still while the long axis walks around inside it, which is the drift the dropped markers are there to make legible. Together they make the rosette, and no single closed curve exists any more: the orbit is an ellipse for one lap at a time.
Built from scratch after Bartosz Ciechanowski's articleThe Moon, whose orbital figures are the reason this page exists. Nothing here is his code; the debt is to the way he stages an idea — one mechanism per figure, every parameter on a control the reader can move. Canvas 2D throughout, no libraries, one file. Figure 1 integrates; figures 2, 3 and 4 solve Kepler's equation directly, so their sliders morph the scene without ever resetting it.

What it actually does

  • Nothing in the physics changes as the frame slider moves. Only the origin does, and two drifting spirals unwind into nested ellipses and then into one relative ellipse.
  • The barycentre is the one point in the system that travels in a straight line.
  • With no net momentum the fixed and barycentric frames coincide, which is why a system at rest looks so much simpler than it is.
  • Kepler’s equal areas are visible rather than assertable once the swept wedges are filled: broad and stubby at periapsis, a long thin splinter at apoapsis, identical area.
  • Nodal and apsidal precession are separable and worth separating. Zero the apsidal rate and the ellipse is carried round rigidly; zero the nodal rate and the long axis walks around inside a plane that holds still.

What the rebuild taught

  • The morph is the argument. Cutting between three frames shows three pictures; blending continuously between them shows that there was only ever one. It is the same point-by-point blend as the four scenes in Orbital Field, applied to the origin instead of to the layout.
  • A fixed-step integrator needs a softened potential. Evaluating the inverse square at the softened radius stops a near miss dividing by nearly zero and flinging a body off the page in a single step, and the softening belongs in the UI rather than buried, because turning it down is how you see why it is there.
  • Symplectic stepping is what makes a demo you can leave running. Energy wanders a little and does not run away, which matters more here than per-step accuracy.
  • Dropping markers over time is how a slow drift becomes legible. Precession is invisible in the instant and obvious as a trail of periapsis marks.
  • A frame change is a per-sample origin; a camera pan is a per-frame origin. The first version subtracted one origin evaluated at the current time from every point in the history, which is a rigid translation: the curve slid about and its shape never changed, so the blend slider moved and the picture did not. The origin has to be indexed by the sample’s own time before spirals will unwind into ellipses.
  • A softened potential is a physics change, not a neutral safety net, and a choreography is exactly the case that notices. The figure-eight survives forty seconds of fixed-step Verlet at its own softening and visibly unwinds in thirty at the default, so the softening is per-preset and the knob goes low enough to watch it fail.
  • Two captions stated the physics backwards and both were caught by looking at the render rather than by argument: periapsis wedges are broad and stubby, not long and thin, and nodal precession does not leave dropped markers where they are, it carries the whole ellipse round and holds periapsis at a fixed angle from the ascending node. Plausible prose is not evidence; the numeric readout is.
  • Going analytic was the structural decision. Solving Kepler directly rather than integrating means sliders morph the scene instead of resetting it, the trail is evaluated backwards from now rather than remembered so it never depends on frame rate, and nothing drifts over a long session. Only the figure that is genuinely n-body integrates.

Rebuild

Four figures: an n-body playground with dragged velocity arrows and a predicted path, the frame morph, the ellipse with equal-area wedges, and the inclined plane with its line of nodes and the two precessions on separate knobs.

Primitives

Reference frameRe-origin the same simulation. Most of what is confusing about a system is a frame problem, not a physics problem.
Symplectic stepStep so that a long-running simulation stays put. Energy is allowed to wander; it is not allowed to run away.
Layout morphOne set of geometry under several layouts, blended point-by-point. How a scene becomes another scene without being rebuilt.
ProjectionReal 3D positions flattened by an explicit camera. The source of every honest 2.5D read.
TrailMotion history drawn as decaying echoes. Reads as speed without any blur pass.
Depth cueAlpha, scale or weight standing in for lighting. Cheap, flat, and more legible than shading.

The work it is after

ciechanow.ski/moon