Build a system and watch its orbits.
Gravity game: six orbit challenges
Choose Gravity challenges in the scene list. A card over the scene gives the goal, shows how close you are and offers a hint; Next challenge moves on, and finished challenges are marked in this browser. Each goal is checked from the simulation itself, and any edit starts the check again.
| Challenge | Goal | What it shows |
|---|---|---|
| Make an orbit | Put a planet in orbit around the Sun and let it go round once. | A click gives the exact speed for a circular orbit: about 30 km/s at Earth's distance. |
| Escape the Sun | Launch an asteroid from near Earth fast enough to leave for good. | Escape speed is √2 times the circular speed: about 42 km/s at Earth's distance. |
| Give Jupiter a moon | Keep a moon going round Jupiter three times. | Within about 0.15 AU of Jupiter, its pull beats the Sun's. Farther out, the Sun takes the moon away. |
| Reach Mars | Launch from near Earth and pass within 0.1 AU of Mars. | A half-orbit trip to Mars takes about 260 days, so Mars must start about 44° ahead of Earth: a launch window. |
| A planet with two suns | Keep a planet around both stars for five years. | Too close to a pair of stars, a planet is thrown out. Kepler-16b circles its two stars at 0.7 AU. |
| Jupiter slingshot | Re-aim a comet so a pass by Jupiter throws it out of the solar system. | A gravity assist: seen from Jupiter the comet leaves as fast as it came, only turned, and seen from the Sun that turn adds speed. |
How to use the gravity simulator
Choose a scene from the list to open it at its starting view. On a phone, swipe the list near the bottom for more scenes and open Details for measurements. Drag to look around, scroll or pinch to zoom, and use the time controls at the bottom to choose a speed, pause or run time backward. Step pauses and advances up to one day (0.1 million years in the galaxy scene); close encounters can shorten a step to keep the calculation accurate. Reset returns to the loaded scene's starting state, paused.
To add a body, press Add in the toolbar (or use Add a body in the details panel) and choose an asteroid, a moon, an Earth, a Jupiter, a red dwarf, a Sun or a black hole. A bar over the scene names the body, shows the launch speed while you drag and has Cancel. Then:
- Click or tap anywhere in space to place it on a circular orbit, moving the usual way round. It orbits what pulls on it hardest: usually the heaviest body, a planet when you click close to one (within about 0.15 AU of Jupiter), or both stars of a close pair when you click well outside them.
- Drag from where you want it to start. The arrow sets its launch speed and direction: one astronomical unit of drag is 30 km/s, about Earth's speed around the Sun.
To name a whole system first, the planet name generator opens its names here as a star and three planets.
Click a body or choose it in Details to inspect its mass, speed and nearest neighbour, follow it, delete it or edit its mass and velocity. Once a body is selected you can work on it directly in the scene:
- Drag the body to move it. It keeps its velocity, so moving a planet outward without slowing it stretches its orbit.
- Drag the gold dot at the tip of its arrow to aim it. The arrow shows where the body would be after one second at the current speed setting, so a longer arrow is a faster launch.
- While the scene is paused, and while you place, move or aim a body, a dotted line shows the path it will follow: one full orbit if it is bound, or where it heads if it escapes. The line ends early at a collision.
- The Mass slider changes the body's mass from an asteroid's to a hundred Suns, and Circular orbit gives it exactly the speed for a circular orbit around the same body a click would choose.
Moving or aiming pauses the scene until you let go. From the keyboard, Alt + arrow keys move the selected body (hold Shift for bigger steps). Typed edits in Edit this body pause it until you press Play. The View from above button beside the zoom buttons looks straight down on the orbits, like a map, which makes placing and aiming easier; press it again to return. Undo restores the state before a manual change; Ctrl/Cmd + Z works while the simulator is focused. Press Esc or Cancel to put the add tool away, and Space to pause. More → Focus mode hides the panels while keeping playback and Show controls available.
Share copies a link that holds the whole scene, including bodies you added and their speeds; it opens paused, and Undo returns to the starting scene. The scene travels after the # in the link, which browsers never send to a website. Scenes with thousands of stars or asteroids, such as the colliding galaxies and Jupiter's Trojans, are too large for a link: use Scenes → Save scene to share a file instead.
Velocity draws arrows on every body showing how far it would travel at its current velocity during one second at the selected simulation speed. Gravity bends the actual path; the dotted line, not the arrow, is the prediction.
The camera buttons zoom in, zoom out and enter Focus mode. In More, graphics detail can stay on Auto or use High for sharper edges. High may run slower; pictures save at full detail in either mode.
Try an orbit, then an escape
Open the orbit experiment. It starts with an Earth-mass planet 1 AU from a star of one solar mass.
- Choose Circular. The relative speed is about 29.8 km/s and the planet completes an orbit in about one year.
- Predict what a faster launch will do, then choose Escape. This starts the same pair with 1.42 times the circular speed, about 42.3 km/s, and its path is unbound.
- Use Undo to return to the previous experiment. Change a velocity component in Details and test your own prediction.
For a two-body system, circular relative speed is √(G(M + m)/r). Escape speed at the same separation is √2 times larger. The experiment uses the same tested Newtonian engine as the other scenes; drawn planet sizes remain exaggerated.
Save, reopen and share an experiment
Choose Scenes → Save scene for a local .gravity.json file. It includes the masses, positions, velocities, particles, units, time and view settings. Send that file to someone who can use Open scene here; no account or scene upload is needed. Opened files start paused, and their trails rebuild when played.
The browser also keeps an autosave on this device and offers Resume on a later visit. It asks before replacing the newly opened scene. Clear autosave removes that browser copy and pauses autosaving for the visit. Use downloaded scene files for a lasting copy; clearing browser data removes its autosave.
Undo retains up to 20 manual changes within a memory limit, so large galaxy scenes retain fewer. It restores snapshots rather than recording every moment of continuous motion. Invalid files leave your current experiment intact.
The scenes
| Scene | What to watch for |
|---|---|
| The solar system today | The planets start from their real positions and speeds at this moment, taken from the same tested ephemeris as the solar system simulator. Add a star or a black hole and see how quickly the orbits unravel. |
| Inner planets | Mercury's orbit is the most eccentric of the planets: it swings from 46 to 70 million km from the Sun. |
| Binary star with a planet | A planet circling two stars, like Kepler-16b. Its orbit wobbles with each turn of the stars. |
| Three stars in a figure eight | A rare stable solution of the three-body problem found in 1993 and proved in 2000: three equal stars chase each other around one figure-eight path. |
| Jupiter's Trojan asteroids | Asteroids 60° ahead of and behind Jupiter, at the Lagrange points L4 and L5, stay with the planet, while the main belt circles inside. |
| A star passes through | A Sun-like star crosses the outer solar system at 20 km/s. Which planets keep their orbits depends on how close it comes. |
| Two galaxies collide | Two spiral galaxies swing past each other, throw out tidal tails and fall back together. |
| Empty space | A single Sun. Build a system of your own. |
| Orbit or escape? | The same two bodies at the same separation, with circular or escaping launch speed. |
The physics
Every body attracts every other with a force proportional to the product of their masses and inversely proportional to the square of the distance between them: Newton's law of universal gravitation. The simulator adds up all of those pulls directly, pair by pair, with no shortcuts.
Positions and speeds are advanced with the leapfrog method, which alternates half-steps of acceleration with full steps of motion. Leapfrog is symplectic: it keeps energy from creeping up or down over long runs and conserves angular momentum exactly, so orbits stay closed instead of spiralling away. The size of each step adapts to the closest pair of bodies, and each step is chosen symmetrically in time (the method of Hut, Makino and McMillan, 1995), so eccentric orbits keep their energy through every close pass.
Units are astronomical units, days and solar masses. In those units the gravitational constant is the square of Gauss's constant, 0.01720209895, the same value astronomers used to compute planetary orbits for two centuries.
How we check it
The physics engine is tested every time the site is built:
- A planet at 1 AU from one solar mass completes its orbit in 365.26 days and returns to its starting point.
- Over a simulated century, energy changes by less than one part in a million and angular momentum by less than one part in a trillion.
- A comet on an orbit with eccentricity 0.91 passes within 0.05 AU of the Sun again and again with its energy held steady.
- The figure-eight returns to its starting positions after one period, keeps its energy to one part in a hundred million over ten periods, and runs backward exactly to where it began.
- Collisions conserve total mass and momentum.
- The path preview of a circular orbit closes on itself after one period without moving the real scene, a launch above escape speed heads away, and a fall into the Sun stops at the collision.
- Trails cover the same stretch of simulated time whether your screen draws 30, 60 or 144 frames a second.
- Every challenge is played through with a move a visitor can make, and the wrong moves do not count: a launch from too far away, a body dropped onto Mars, or a comet sped up to escape on its own.
The solar-system presets use instantaneous velocity vectors from the ephemeris. Additional checks cover overlapping starting bodies and small, fast bodies that would otherwise cross one another between steps. The solver bounds approaching contacts and merges overlapping centres before evaluating their mutual force.
Limits
This is Newtonian gravity: there is no relativity, so a black hole here behaves like any other very heavy point, without an event horizon. The black hole light-bending model separately traces light around a non-rotating black hole. Collisions merge bodies rather than shattering them (for what a real asteroid does to Earth, try the asteroid impact simulator), bodies are drawn larger than life, and the galaxy stars feel the galaxies' cores but not each other. For the real, measured motion of the planets, open the solar system simulator. The model comparison explains which tests apply to each view.
Questions
Is there a gravity game with goals?
Yes. Choose Gravity challenges in the scene list for six orbit puzzles: make an orbit, escape the Sun, give Jupiter a moon, reach Mars, keep a planet around two stars, and throw a comet out of the solar system with a Jupiter slingshot. The simulation itself checks each goal, and finished challenges are marked in this browser.
Is this gravity simulator physically accurate?
It uses Newton's law of gravitation between every pair of bodies and a time-symmetric leapfrog integrator, the kind used in research N-body codes. We test it on problems with known answers: a planet at 1 AU around one solar mass takes one sidereal year, energy stays within a millionth over a century, and three stars in the figure-eight orbit return to their starting points after one period.
What does the energy change number mean?
For an isolated system without collisions or edits, total energy should stay constant. The readout shows change since the current baseline; adding, deleting or editing a body, or merging a pair, starts a new baseline. Close encounters can require smaller steps, so the simulator slows down to keep the calculation accurate.
Why do planets look so big?
At true scale a planet would be far smaller than a pixel at these distances, so bodies are drawn larger than life. Collisions use the drawn size: two bodies merge when their spheres touch, keeping their combined mass and momentum.
Can I reverse time?
The backward button reverses the orbital integration. A merged body stays merged; reversing does not reconstruct its earlier parts. Undo separately restores a complete snapshot before your last manual edit, which can also return to a state before later collisions.
How is the galaxy collision simulated with thousands of stars?
Each galaxy's mass sits in a softened central core, and its 6,000 stars move in that gravity without pulling on each other. This restricted method is how Alar and Juri Toomre first explained tidal tails in 1972, and it reproduces the long curved streams seen in real merging galaxies.