Loading the engineShared by all simulations, so the next one opens instantly.
The physics

A gravity assist lets a spacecraft change speed without fuel by flying close past a planet. Relative to the planet, the craft leaves as fast as it arrived, only in a different direction. Relative to the Sun, the planet’s orbital velocity is added before and after the turn, so the turn becomes a change of speed: the craft gains energy when it passes behind the planet and loses energy when it passes in front, while the planet’s orbit changes by an immeasurably small amount. Mariner 10 first used the technique in 1974, at Venus on its way to Mercury. Voyager 1, launched in 1977, swung past Jupiter and Saturn and is now in interstellar space.

What you see

A star sits at the center of an 800 by 800 pixel world. A planet (cyan) orbits it counterclockwise, and a spacecraft (white) flies past the planet once. The arrow on the spacecraft shows its velocity, and the number next to it is its speed |v| relative to the canvas, which is in effect the star’s frame. Both leave trails; at the default length the planet’s covers about one orbit.

Each run is built around its closest approach. The planet is straight above the star at that moment, and the spacecraft passes it at the set distance and speed, at the set point around the planet. The simulation finds where the two had to start by running that encounter backward in time, with the same integrator, until the spacecraft is 220 pixels from the planet or near the edge of the world; the run then plays forward from there. The speed changes all along the path, since the spacecraft falls toward the star and climbs away again. What the planet contributes is the change of the spacecraft’s orbital energy around the star, E=12v2−GM⋆/r: compare the speeds at the same distance from the star before and after the flyby. Press Reset to watch again.

Governing equation

All three bodies attract each other with softened Newtonian gravity,

𝐫¨i=G∑j≠imj(𝐫j−𝐫i)(|𝐫j−𝐫i|2+ε2)3/2,

with G=1, star mass 2×105, spacecraft mass 1 and ε=2 px, integrated with leapfrog (velocity Verlet) at dt=0.004. Star and planet start on a circular orbit around their common center of mass, so the planet moves at U=G(M⋆+mp)/r, which is 31.7 px/s at the default radius of 200 px. Leapfrog is time-reversible, which is why the backward run lands the spacecraft exactly at the chosen closest approach.

In the planet’s frame the spacecraft follows a hyperbola. It arrives and leaves with the same speed v∞, turned by an angle δ that depends on the closest distance rp and the planet mass mp:

sin⁡δ2=11+rpv∞2/(Gmp).

In the star’s frame the velocity is 𝐯=𝐔+𝐯∞, so the encounter changes it by Δ𝐯=𝐯∞out−𝐯∞in, of magnitude 2v∞sin⁡(δ/2), and changes the energy per unit mass by

ΔE=𝐔⋅Δ𝐯.

Δ𝐯 points from the point of closest approach toward the planet. A pass straight behind the planet turns it along 𝐔, the largest gain; a pass straight in front turns it against 𝐔, the largest loss; a pass on the inside or outside of the planet’s orbit changes the direction but not the energy. Close to the planet, inside its Hill radius rH=r(mp/3M⋆)1/3, the planet’s pull dominates the star’s tide, and this picture holds.

Presets

Prograde (speed gain): the default flyby, 8 px behind the planet at 20 px/s relative to it, well inside the Hill radius of 24 px. The spacecraft’s energy rises by about 0.4U2; at the planet’s distance from the star that is a speed of 40 instead of 27 px/s. It stays bound to the star, on a wider orbit.

Retrograde (speed loss): the same flyby 8 px in front of the planet. The energy drops by the same amount, and the spacecraft falls onto a smaller orbit.

Voyager-1 style: a planet five times heavier (mass 5000, Hill radius 40 px), passed 14 px from its center at 35 px/s, 10° from straight behind. The energy rises by about 0.7U2, enough to turn a path bound to the star into one that escapes, as Jupiter’s gravity did for Voyager 1.

Without a preset, the prograde flyby is used.

Parameters

Planet mass: 100 to 10,000 (default 1000). A heavier planet turns the spacecraft more sharply at the same distance.

Orbital radius (px): the radius of the planet’s circular orbit, 80 to 320 px (default 200). It sets the planet’s speed U.

Flyby speed: the spacecraft’s speed relative to the planet at closest approach, 10 to 150 px/s (default 20). Below the escape speed from the planet at that distance, 2Gmp/rp, the spacecraft is captured instead of flying past.

Flyby distance (px): the closest approach to the planet’s center, 4 to 60 px (default 8).

Flyby point (°): where the closest approach lies around the planet, counterclockwise from straight behind it: 0° gains the most energy, 180° loses the most, and ±90° (outside or inside the planet’s orbit) change it least.

All five apply on Reset. Velocity arrows, Center of mass and the trail controls change only the drawing.