Live physics lab

Gravity Simulator

A real N-body gravity sandbox. Throw planets and stars, build your own solar system, watch orbits, slingshots and collisions, and try the famous figure-8 three-body orbit. Every body pulls on every other with Newton's law of gravity.

TIME0
BODIES0
ENERGY DRIFT0%

Throw: drag in space — the arrow is the speed and direction, the dotted line shows where it will go. A short click places a body on a circular orbit. Scroll or pinch to zoom.

Bodies

    Space play/pause · F full screen · +/− zoom

    How the simulation works
    1. Gravity: every body pulls on every other body with F = G·m₁·m₂/r². Heavier and closer means a stronger pull.
    2. Motion: each small time step, velocities change from the pull and positions change from the velocities (leapfrog / velocity-Verlet method).
    3. Orbits happen when a body moves sideways fast enough to keep "missing" what pulls it. Too slow and it falls in; too fast and it escapes.
    4. Collisions (optional) merge two touching bodies into one, keeping their total mass and momentum.

    Units are simplified (G = 1) and the drawn sizes are not to scale. Everything runs in your browser.

    Using Gravity Simulator

    A real N-body gravity sandbox. Drag to throw planets, build solar systems, try binary stars and the famous figure-8 three-body orbit, and watch slingshots and collisions. Energy and momentum charts show how accurate the physics is.

    1. Pick an example such as Solar system, Binary stars, Figure-8 or Slingshot, or start from an empty space.
    2. Choose Throw and drag in space: the arrow sets the speed and direction, and a dotted line predicts the path before you let go. Choose the new body's mass first.
    3. Use the speed slider and Play/Pause. Scroll or pinch to zoom, and choose a body to follow.
    4. Toggle trails, velocity arrows, collisions that merge bodies and the center-of-mass view in View.
    5. Watch energy and momentum in Charts and download the data as CSV or a PNG snapshot.

    Example

    Solar system: planets orbit a heavy star at different speeds — inner planets are faster, as Kepler's laws say.
    Figure-8: three equal masses chase each other on a figure-eight path, a famous stable solution of the three-body problem.

    Questions & answers

    How does the simulation calculate gravity?

    Every body pulls on every other with F = G·m₁·m₂/r². Positions and velocities are updated with the leapfrog (velocity Verlet) method, which keeps orbits stable over long times. A small softening avoids infinite forces when bodies get very close.

    Why does total energy change a little?

    Numbers are calculated in small time steps, so tiny errors add up. The Charts tab shows the drift; lowering the speed or the time step makes it smaller. Collisions that merge bodies also turn kinetic energy into heat, which is not tracked.

    What is the three-body problem?

    With three or more bodies there is no general formula for their motion, and most arrangements become chaotic. The figure-8 is a rare stable solution found in 1993 and proven in 2000.

    What is a gravitational slingshot?

    A small body passing close to a moving planet can gain or lose speed by borrowing a tiny bit of the planet's momentum. Space probes like Voyager used this to reach the outer planets.

    Are the units real?

    The sandbox uses simple units (G = 1) so the numbers are easy to read. Distances, masses and times are relative.

    Can I export the data?

    Yes. Download a CSV of time, energy and momentum, or a PNG snapshot.

    Does it run offline?

    Everything runs in your browser; nothing is uploaded.

    Help improve this tool

    Report a problem or suggest an improvement

    Describe the issue without pasting private tool input. Feedback goes to our admin inbox.

    Find another tool · Read practical guides