Orbits & Gravity Simulation

Controls

1 yr every 6 s

Newton's laws work both ways: every body retraces its path (B).

Scene

Missions: fly a probe to a goal on a fuel budget. Random system: a new star with planets; how long will they last?

Bodies

Choose a body for its buttons; double-click one to view from it. N and Shift+N step through them. In the list the arrow keys choose a body, Enter opens its menu and Delete deletes it.

Show

Pull lines split the chosen body's force into one arrow for each body pulling on it (G).

Gravity well: how deep each body's pull reaches, as shading and contour lines (W).

Kepler's laws

Each law draws on the chosen body's orbit and measures it in a card, top right.

Orbit of Earth

Reshapes the orbit through where it is now: 0 is a circle, near 1 a long thin ellipse.

View from

Watch the motion from any body, or turn with one as it orbits.

Physics

True sizes, Einstein's relativity (orbits slowly turn, black holes spiral together) and tides that tear stars apart.

More options

Bodies you drop or move

Each starts on a circular orbit round the body it would orbit there.

Also show

The Hill sphere, Roche limit and Lagrange points are the chosen body's. The stability timer runs until a body is flung out or two collide.

Collisions

Download data (CSV)

Tables for a spreadsheet, with units in the headings.

Save and share

A link opens this exact setup. Your work is also saved in this browser as you go.

N chooses the next body and Shift+N the one before. Enter opens the chosen body's menu, Z zooms to its orbit and the arrow keys push it. Space pauses. Question mark lists every key.

FPS: 0
Eartharound the Sun
Time: 0.00 yr
Distance: – AU
Speed: – km/s
Gravity: – N
Period: –
Eccentricity: –
About this simulation

Every mass pulls on every other mass. This simulation adds up those pulls for every pair of bodies, thousands of times per orbit, in real units: distances in AU (Earth to Sun), times in years, masses in Suns and Earths. With hundreds of bodies, the pulls of far-off groups of small bodies are added up together, as if each group were one body (a Barnes–Hut tree), which keeps it quick. Two bodies passing very close follow their exact two-body orbit for a moment, so a near miss doesn't slow everything else down.

What you're seeing

  • Pink arrows: the gravitational force on each body. The Sun pulls Earth exactly as hard as Earth pulls the Sun. Teal arrows: velocities. The key in the bottom corner gives each arrow's scale.
  • Pull lines (G) split the chosen body's pink arrow into one arrow for each body pulling on it, joined tip to tail.
  • Trails show recent paths. Bodies are drawn larger than life, or the planets would be invisible dots (unless realistic physics is on).
  • Cards in the top-right corner measure what you have switched on (Kepler's laws, the Hill sphere, the stability timer, a mission). If they would cover too much of the canvas, the lowest turn compact, then fold into a "+2 more" line.
  • Flat, in 2D: everything moves in one plane, as if seen from straight above. Real orbits are tilted a little to each other (the planets' by a few degrees), so in space bodies usually pass above or below one another. The tilt hardly changes an orbit's size, shape or period, and gravity still falls off as 1/r2; but here nothing can pass over anything else, so close passes and collisions happen more often than they would in space.

The key idea

Newton's law of gravitation, F = Gm1m2/r2: twice the distance, a quarter of the pull. A planet is always falling towards the Sun, but it moves sideways so fast that it keeps missing. That gives Kepler's laws: orbits are ellipses with the Sun at one focus (1st), a planet sweeps out equal areas in equal times (2nd), and T2/a3 is the same for every planet of a star (3rd).

How to use it

Build and move

  • Add a body: drag it from the strip into space, or click or tap it to add it at a free spot. Drag a body to move it. Drag empty space to pan; scroll or pinch to zoom; Fit view brings everything back into view.
  • Aim a velocity: drag the tip of a body's teal arrow (hold Shift for fine control; on a touch screen, hold the tip still for a moment first). It snaps to the exact circular and escape speeds, and a dashed line shows where the body will go.
  • Throw a body: in More options choose Throw it, then flick a body (or one from the strip) as you let go: it keeps the speed of your pointer.

Choose and change a body

  • Choose a body: click or tap it. The info bar shows its distance, speed, pull and period (with a tick once the period has been measured over a whole orbit). Double-click or double-tap a body to view the motion from it.
  • Its menu: press Edit, or right-click or long-press the body (or press Enter). Body sets its mass, size and colour; Velocity takes a typed speed and direction (0° is sideways, as in a circle; + is outward) or a push; Orbit sets its period, which scales the whole orbit, or its closest and farthest distances, which keep it where it is; Gravity lists who pulls on it. The arrow keys push the chosen body: ↑ faster, ↓ slower, → outward, ← inward (Shift finer, Alt coarser).
  • Find a body: open the settings and Bodies to list them all, with what each orbits, its mass, distance, speed and period. Find one by name, sort them, and choose one for buttons to zoom to its orbit, view from it, edit or delete it. N and Shift+N step through the bodies, heaviest first with moons after their planet; Z zooms to the chosen body's orbit.

Time

  • Speed: Space pauses. [ and ] (or the slider in the settings) go from a hundredth of normal speed to a hundred times; the note under the slider says what that means in real time. or the . key moves on a moment at a time.
  • Run backwards: tick Run backwards under the speed (or press B) and the clock counts down while every body retraces its path.
  • Try again: Undo (Ctrl+Z, or ⌘Z on a Mac) takes back a change, a whole drag or slider sweep at a time, and Redo (Ctrl+Y) puts it back; even Restart and a change of scene can be undone. (or R) runs the motion again from your last change, always forwards, so you can tweak a velocity, watch and try again. Delete removes the chosen body.

See gravity at work

  • Kepler's laws: each switch draws its law on the chosen body's orbit and measures it in a card.
  • Who pulls: press G, or turn on Pull lines, to split the chosen body's force arrow into one arrow for each body pulling on it. The menu's Gravity tab lists the pulls, their sizes and their shares of the net force.
  • Gravity wells and rotating views: turn on Gravity well (or press W) to see each body's well as shading and contour lines. In View from, choose "Rotating with …" to turn with the chosen body and what it orbits; arrows then show velocities in that turning view. Lagrange points (in More options) marks L1 to L5: hover over or tap one to read about it.
  • Realistic physics: with it on, a card measures how far the chosen body's orbit turns each time round, against Einstein's formula, and follows the gravitational waves of close black holes and neutron stars.

Scenes, missions and sharing

  • Scenes: choose one in the settings; many open with a tip in the line under the canvas (tap More to read a long one on a phone). In "The Solar System on a date", pick any start date from 1800 to 2050: the info bar then shows the date as the planets move. Crowded scenes show their small bodies as dots, without names or arrows: click one to follow it.
  • Missions: press Missions in the settings, or pick one at the end of the scene list. Only your probe's engine can change anything: burn with the arrow keys, the menu's pushes or its arrow. Every burn uses fuel, Undo gives it back, and the card shows what's left.
  • Random systems: Random system, beside Missions, makes a star with 2 to 8 planets, and the stability timer counts how long they last. Its number goes into a shared link.
  • Save and share: Copy a link, at the end of the settings, copies a link to this exact setup; opening it shows the same setup, paused, and Undo goes back. Your work is also saved in this browser as you go: next time, "Carry on where you left off" appears under the canvas for a while. Download data (CSV), in More options or under the graphs, saves Kepler's 3rd law table, the graphs' data or every body's position and velocity for a spreadsheet.
  • Buttons: opens the settings, goes fullscreen, shows energy graphs, restarts the scene, and ? (or Help in the settings) lists every key and gesture.

Things to try

  • Raise the eccentricity and turn on the 2nd law: the planet speeds up near the Sun but the shaded areas stay equal.
  • Press Edit, open the Orbit tab and give Earth a period of 2 years: Kepler's 3rd law moves its orbit out to 1.59 AU.
  • In "The Solar System on a date", turn on the 3rd law and speed it up: T2/a3 comes out close to 1.00 for every planet, out to Pluto. Download the table (More options) and plot T2 against a3: a straight line through the origin.
  • Set the Solar System's start date to your birthday and see where the planets were.
  • Aim a velocity at the escape speed (it snaps there): the body only just gets away.
  • In "Inner planets", choose the Sun and open its Gravity tab: each planet pulls on the Sun exactly as hard as the Sun pulls on it.
  • In "Slingshot", press G as the probe passes Jupiter: Jupiter's pull and the Sun's add up, tip to tail. Jupiter only turns the probe, yet its speed relative to the Sun doubles.
  • In "Jupiter's Trojans and Hildas", set View from to "Rotating with Jupiter and the Sun": the Trojans swing slowly round L4 and L5, and the Hildas' triangle stands still.
  • Run "Three stars: chaos" until one star is flung out, then run it backwards (B): rounding errors grow until the stars miss their true past.
  • In the mission "Escape the Sun", burn at the far end of your orbit, then Undo and burn at the closest point: the same push does far more when you're moving fast.
  • Make a random system and speed it up: will its planets last 10,000 years?
  • Open "Mercury's orbit turns" and speed it up: the card measures the 43″ a century by which relativity turns Mercury's orbit.

Realistic physics

Off, gravity is Newton's alone. On, every body is drawn at its true size (a ring marks the tiny ones); Einstein's general relativity adds its first correction to gravity, so an orbit close to a neutron star or black hole slowly turns, tracing a rosette (Mercury's turns too, by 43″ a century); and a star or planet that strays inside the Roche limit of a much denser body is torn apart by tides. Its pieces still pull on each other, so some may gather into clumps again. Either way, bodies merge when their real surfaces touch and a black hole swallows anything that crosses its event horizon.

A card in the corner measures how far the chosen body's orbit turns each time round and compares it with Einstein's formula, 6πGM/(c2a(1 − e2)); where other planets pull on it too, it shows how much of the turn is Einstein's. Two black holes or neutron stars close together also give off gravitational waves (with relativity's next, smaller terms as well): the waves carry off energy, so their orbit shrinks and becomes rounder and they go round faster and faster, a rising “chirp”, until they plunge together at their innermost stable orbit, about 6GM/c2. Two black holes become one a little lighter than the two: some of their mass leaves as waves (E = mc2). The energy graph shows the energy carried off.

The Solar System on a date

The planets start where they really were, or will be, on the start date, worked out from NASA JPL's table of the planets' orbits for 1800 to 2050 (E. M. Standish's “Keplerian Elements for Approximate Positions of the Major Planets”), with masses from the International Astronomical Union. From then on it is the simulation's own gravity that moves them. The real orbits are tilted a few degrees to Earth's (Pluto's 17°); here each is laid flat, keeping its size, shape and period.

Missions

Seven missions, easy to hard, are at the end of the scene list (or press Missions in the settings). Each gives your probe a goal, such as reaching Mars or parking at Jupiter's L4 point, and a fuel budget measured as the change of speed (Δv) its engine can give. Only burns of the engine may change anything, and each one uses fuel; Undo gives it back. Par, the Δv of the classic route, comes from v2 = GM(2/r − 1/a), and the closer you get to it the more stars you earn.

Running time backwards

Newton's laws work just as well backwards: reverse every velocity and each body retraces its path. Tick Run backwards (or press B) and the clock counts down as the bodies go back along their trails; the velocity arrows still show each body's velocity, so now they point against its motion. In a chaotic system such as "Three stars: chaos", the tiny rounding errors of any computer grow at every close encounter, so after a long run the backward motion drifts away from the true past, and faint dashed discs show where the stars really were. A merger, or a star torn apart, can't run backwards by itself: the simulation puts the bodies back as they were just before.

Gravity wells and rotating views

Turn on Gravity well (or press W) to see each body's well as a map: darker is deeper, and each line joins points at the same depth, like the contour lines of a map of hills. Where the lines crowd together, the slope is steep and the pull is strong. In View from, a rotating view turns with a body and the body it orbits, so both stand still. Velocity arrows then show motion as seen in that turning view, and the well includes the outward push you feel on a roundabout. It gains hilltops 60° ahead of and behind the body, and passes on the line through the pair: the five Lagrange points (under More options), where a small body can keep pace with the pair. Surprisingly, the hilltops L4 and L5 are the stable ones: a body that starts to roll off is steered round by the turning (the Coriolis effect), which is why Jupiter's Trojan asteroids gather there. For an elliptical orbit the view keeps the pair on one line, so the body slides in and out along it.

Keys and gestures

The keys work once you have clicked or tabbed into the simulation, but not while you are typing in a box. Everything here can also be done with the buttons and the settings.

On a touch screen

Drag from the strip
Add a body where you let go, or tap one to add it at a free spot. Swipe the strip sideways for more
Tap a body
Choose it: the info bar shows its distance, speed and period
Double-tap a body
View the motion from it (double-tap empty space to go back)
Long-press a body
Open its menu: its mass and colour, velocity, orbit and pulls
Drag a body
Move it
Drag an arrow's tip
Aim its velocity. Hold the tip still for a moment first for fine aim
Drag space · pinch
Move around · zoom in or out
Tap a long tip
Read all of it (a tip cut short ends in More)

Choose and look

N · Shift+N
Choose the next or previous body: heaviest first, moons after their planet
Z
Zoom to the chosen body's orbit
Bodies list
In the settings: find a body by name, then zoom to it, view from it, edit or delete it
Click · double-click
Choose a body · view the motion from it
Drag space · scroll
Move around · zoom in or out
Tab
Move between the simulation and its buttons

Change a body

Enter · right-click
Open the chosen body's menu
↑ ↓
Push it faster or slower (in a mission, fire the probe's engine)
→ ←
Push it outward or inward (with Shift finer, Alt coarser)
Drag
Move a body, or aim it by its arrow's tip (hold Shift for fine aim)
Delete
Delete the chosen body (Ctrl+Z brings it back)

Time

Space
Pause or play
[ ]
Slower · faster
.
Pause, then step forward a moment at a time
B
Run backwards, or forwards again
R
Run again from your last change (always forwards)
Ctrl+Z · Ctrl+Y
Undo · redo (on a Mac ⌘+Z · ⇧+⌘+Z)

Show

G
Pull lines: who pulls on the chosen body
W
Gravity well: shading and contour lines
F
Frame rate
?
This list (or Help in the settings)
Esc
Close a menu, the settings or fullscreen