A probe on a straight line meets a planet orbiting a star at fixed radius. The only force modelled is the planet's own gravity — an inverse-square pull toward the planet's instantaneous position, integrated with semi-implicit (symplectic) Euler at a fixed 1/120 s sub-step so the trajectory stays stable through close approach:
r⃗ = planetPos − probePos
a⃗ = r⃗ · (GM / |r⃗|³) ( = GM/|r⃗|² toward the planet )
v ← v + a⃗·dt
p ← p + v·dt
Because the planet is moving, the encounter is not a fixed-source two-body problem — the probe effectively borrows a slice of the planet's orbital momentum. Approach the planet from behind its direction of travel and the probe leaves faster (a real gravity assist); approach it head-on and the probe leaves slower. The four sliders reproduce exactly this: planet mass sets the field strength (GM), entry speed and lateral drift set the incoming hyperbola, and planet phase sets where in its orbit the planet is when the probe arrives — which determines whether the assist adds or removes energy.
- Speed gain — current speed minus the entry speed; positive means the flyby added kinetic energy.
- Closest flyby — the minimum surface-relative distance reached during the pass.
- Distance-vs-time trace — the dip marks the moment of closest approach; a sharp, deep dip is a tight encounter, a shallow one barely deflects the probe.