Visualizations
414 / 500

414 · Games

Grand Tour

Plan a probe's slingshot route past Jupiter, Saturn, Uranus and Neptune.

A probe flies patched conics through a live outer solar system. Between planets it feels only the Sun, stepped with a fixed-step symplectic leapfrog; inside a planet's sphere of influence the code switches frames and solves the hyperbolic pass exactly (eccentricity vector, turn angle, hyperbolic Kepler equation), then mirrors the entry state across the apse line to get the exit. Speed relative to the planet is unchanged, but in the Sun's frame the bent v-infinity adds to the planet's own orbital velocity, which the encounter panel shows as a velocity triangle and the speed chart shows as jumps above the solar escape curve. The planets sit in a 1977-like alignment found offline, so the autopilot replays a four-planet tour, correcting its aim after each flyby by Newton iteration on the same predictor you plan with.

Try it. Press Plan your own (or click the map), then drag from anywhere to aim Earth's departure: direction and length set v-infinity, and the dashed predictor shows every flyby ahead. Arrow keys trim the aim finely, [ and ] move the launch date, T (Solve) aims for the next planet, Space launches. In flight, drag to plan a burn and release to fire, or press Correct for a computed trajectory correction. A returns to the autopilot.

  • Patched conics
  • Hyperbolic Kepler equation
  • Symplectic leapfrog integration
  • Newton targeting on a trajectory predictor

View the source · one module, plus a small shared runtime for sizing, the animation loop and input

Build your own

Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.

Build a gravity assist simulator with JavaScript and the HTML canvas element. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.

Start simple:
- Make a full-window canvas that stays sharp on high-DPI screens. Draw a top-down solar system in AU and years (the Sun's GM is 4 pi squared), with Earth, Jupiter and Saturn on circular orbits at their real distances and periods (a^1.5 years).
- Map radius with a square-root scale so 1 AU and 10 AU both fit, and draw orbits as dotted circles.
- Launch a probe from Earth with Earth's velocity plus a launch vector you set by dragging from Earth. Move it with a leapfrog integrator (half kick, drift, half kick) at a fixed step of 0.002 years, feeling only the Sun.
- Give each planet a sphere of influence of radius a * (m / M)^0.4. When the probe enters one, switch to the planet's frame, find the hyperbola's eccentricity e, rotate the relative velocity by the turn angle 2 asin(1/e), and add the planet's velocity back.
- Run the same integrator ahead from the current aim and draw the predicted path as a dashed line, so dragging shows where the probe will go.

Once that works, make it beautiful:
- Style it like a 1970s vector display: near-black background, thin glowing amber and cyan lines (stroke wide and faint, then thin and bright), monospace labels.
- Slow time down near planets and show an inset of the flyby in the planet's frame, with the speed in and out of the encounter in the Sun's frame.
- Plot heliocentric speed against distance next to the solar escape speed curve sqrt(2GM/r), so the boosts show up as jumps.

Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as an exact hyperbolic pass using Kepler's equation instead of an instant turn, an autopilot that solves for the launch with Newton's method, or adding Uranus and Neptune for a full grand tour.
PreviousHanging Chain ArchesHang chains and weights, then flip the sheet to turn them into stone arches. NextRomanescoA romanesco head of cones on cones on cones, with a dive into its endless florets.

Related visualizations

  • Retrograde LoopsAstronomy Why Mars backs up against the stars, drawn by Copernicus and Ptolemy side by side.
  • RendezvousGames Dock a capsule with a station, where thrusting toward it sends you backward.
  • Kirkwood GapsAstronomy Thousands of asteroids and Jupiter's resonances carving gaps into a featureless belt.
  • Orbital ResonanceAstronomy A seven-planet resonant chain that chimes on every transit and weaves its own spirograph.
  • Ground TracksAstronomy The snakes, loops and figure eights real orbits trace over a turning world.
  • Transit HunterAstronomy Planets dim a spotted star; a box-least-squares search and RV fit find them.
  • CometAstronomy A comet rounds the Sun and grows a straight blue ion tail and a curved dust tail.
  • Starry MessengerAstronomy Jupiter's moons seen through a small telescope and sketched night by night in 1610.
  • Hyperbolic MazeGames A labyrinth in negatively curved space: the world glides past while you stay at the center.

Use ← and → to move between demos. While the canvas has focus, keys go to the demo instead.

← More from Emergent Mind Labs