Gravity Orbit Simulator

Watch Newtonian gravity run in real time. Load the Sun, Earth and Moon, a binary star, the famous figure-8 three-body choreography or a chaotic tangle of worlds — then drag on empty space to slingshot in new planets and see how their orbits play out. Nothing is uploaded; the whole N-body simulation runs on your device.

You are in the Physics lab.

Drag on empty space to launch a planet
Bodies0
Time0.0 yr
System energy0
The three-body problem has no general solution. Two bodies orbiting under gravity trace a tidy, predictable ellipse — but add a third and there is no closed-form formula for their motion. The system is chaotic: shift a starting position by a hair and the orbits diverge into a completely different future. Load the Chaotic three-body preset and reset it a few times to see it.

How It Works

Real Newtonian gravity, integrated step by step in your browser.

1

Newton's law of gravitation

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. Each frame the simulator sums those pulls to get the acceleration on each body, with a small "softening" term so near-collisions stay numerically stable.

2

The Velocity-Verlet integrator

Positions and velocities advance with Velocity-Verlet: compute accelerations, nudge the positions forward, recompute accelerations at the new positions, then update velocities using the average. This time-symmetric scheme conserves energy far better than naive stepping, so orbits don't spiral out over time.

3

Stable vs chaotic orbits

A light planet around a heavy star settles into a near-perfect ellipse. Give several bodies similar masses and the mutual tugging turns chaotic — orbits swing wildly, and a body may even be flung out of the system. Drag on empty space to launch your own planet and see which regime it lands in.

How is gravity calculated in the simulator?
Every body pulls on every other body using Newton's law of universal gravitation: the force grows with the product of the two masses and falls off with the square of the distance between them. The simulator sums these forces for each body and advances the motion with a Velocity-Verlet integrator, using a small softening term so bodies that pass very close don't blow up numerically.
What is the three-body problem?
It asks how three masses move under their mutual gravity. Unlike the two-body problem, it has no general closed-form solution: for almost all starting conditions the motion can only be found by numerical integration, and tiny changes in the initial positions or velocities lead to wildly different orbits.
What is the figure-8 orbit?
The figure-8 is a rare stable solution to the three-body problem — discovered by Cris Moore in 1993 and proven by Chenciner and Montgomery in 2000 — in which three equal masses chase each other around a single figure-eight-shaped path. It is one of the few known periodic three-body "choreographies," and it is included here as a preset.
Can I put this on my own website?
Yes. There is an embeddable version at lkforge.com/embed/orbit-simulator/ that you can drop into an <iframe>. It runs entirely client-side with no tracking.