About Gravity
A sandbox of planets and stars pulling on each other. Pick a scene and press RUN. Speed runs the clock from 1× (an Earth year takes 8 seconds in the Sun and planets) up to 64× for the long scenes. Drag on the plate to fling in a new body: where you press is where it starts, and the drag sets its speed and direction (a drag of about a finger's length, square to the line from the middle of the scene, gives a roughly circular orbit round it; close to one star of a pair or a cluster it is only a rough guide). While you drag, a dotted line shows where it will go. Click a body to pick it, then make it heavier or lighter, or delete it. Scroll or use + and − to zoom.
Keys: Space play or pause, R reset the scene, C clear the trails, T trail length, V fixed or turning view, Delete remove the picked body, Esc drop it, + − 0 zoom, arrow keys move the view (with Shift, further), F follow the picked body. To move the view with the mouse, drag with the middle button (the scroll wheel), or hold Space and drag; a quick tap of Space still plays or pauses. On a touch screen, two fingers move and pinch to zoom. FOLLOW keeps the picked body in the middle while it runs; moving the view yourself, FIT or a new scene turns it off.
THE STORY
Johannes Kepler found that the planets move on ellipses, sweep out equal areas in equal times, and that the square of a planet's year goes with the cube of its distance from the Sun (1609 and 1619). In 1687 Isaac Newton's Principia explained all three with one rule: every mass pulls every other with a force that falls off with the square of the distance. For two bodies the answer is exact: an ellipse for ever if they are bound together, or a parabola or hyperbola if they fly apart. For three there is no general formula. Henri Poincaré showed in 1890 that their paths can be chaotic, so tiny changes grow until the future can't be predicted.
Some special three-body cases do have neat answers. Leonhard Euler found three points in a line with two bodies where a small third one can sit (about 1767), and Joseph-Louis Lagrange found two more in 1772, 60° ahead of and behind the smaller body: L4 and L5. In 1906 Max Wolf found the first asteroid sitting near Jupiter's L4 point, 588 Achilles; thousands of these "Trojans" are now known. In 1993 Cris Moore found, by computer, three equal masses chasing each other round a figure-of-eight; Alain Chenciner and Richard Montgomery proved it exists in 2000. The starting numbers used here are the ones from their paper, worked out by Carles Simó.
The slingshot (gravity assist) was worked out for spacecraft by Michael Minovitch at NASA's Jet Propulsion Laboratory in 1961. Mariner 10 was the first craft to use one to reach another planet, swinging past Venus on its way to Mercury in 1974; Voyager 2 used Jupiter, Saturn and Uranus to reach Neptune in 1989. Seen from the Sun, the craft steals a tiny part of the planet's orbital speed.
HOW IT WORKS
Every body pulls on every other by Newton's law. The units are astronomical units (Earth's distance from the Sun), years and Sun masses, so a planet 1 AU from the Sun goes round once a year. Time moves on in small steps by the leapfrog method (also called velocity Verlet): half a kick from the forces, a full move, then the other half kick. Loup Verlet made it famous for simulating molecules in 1967, though Carl Størmer had used it in the early 1900s for particles in the aurora. It keeps energy from creeping away even over thousands of orbits; when two bodies come close, the step is cut into smaller pieces. Energy drift shows how far the total energy has wandered since the last change, as a check on the sums. Bodies that touch merge into one, keeping their total mass and momentum; the energy the crash turns into heat is set aside, not counted as drift. A tiny softening stops the pull becoming infinite at zero distance.
Bodies are drawn far bigger than life (at this scale the real Sun would be smaller than a pixel), and everything moves in a flat plane. The turning view spins with one body (the scene's planet, or the body you've picked), which is how the Trojans' slow "tadpole" loops round L4 and L5 show up. The trails at the start were worked out by running each scene backwards in time.
FURTHER WATCHING AND READING