Home▸Space & Astronomy▸Solar System 2D — Real N-Body Gravity

🪐 Solar System 2D — Real N-Body Gravity

A real top-down N-body gravity simulation of the Solar System: F=Gm1m2/r2 between the Sun and all eight planets, real masses, real semi-major axes and eccentricities, real orbital periods emerging from the physics. Adjustable time-scale, click any planet for data.

Space & Astronomy2DModerate60 FPS📱 Mobile-adapted⇄ 3D version
2d-solar-system ↗ Open standalone

A genuine top-down twin of the 3D Solar System simulation: instead of nine scripted circular orbits, every planet and the Sun pull on each other through real Newtonian gravity, with real masses, real semi-major axes and real eccentricities — so each orbital period emerges from the physics rather than being animated by hand.

🔬 What It Demonstrates

Direct N-body integration of F=Gm1m2/r2 between the Sun and all eight planets, advanced with a symplectic leapfrog integrator. Mercury's fast 0.24-year lap and Neptune's 165-year crawl both fall out of the same force law, matching Kepler's third law without it being hard-coded anywhere.

🎮 How to Use

Drag to pan, scroll or pinch to zoom, and click or tap any planet to see its real mass, distance, eccentricity and orbital period — including a live-measured period timed directly from the simulation. Adjust the time-scale slider to watch a full Jupiter year in seconds.

💡 Did You Know?

Because gravity here is mutual, Jupiter (about 318 Earth masses) subtly tugs on every other planet's orbit — the same wobble effect astronomers use to detect exoplanets by watching their host star shift.

About this simulation

This is the flat, top-down twin of Solar System (3D), but the mechanics underneath are genuinely different from a kinematic animation: it is a real N-body gravity integration. The Sun and all eight planets are given their real relative masses, real semi-major axes and real orbital eccentricities, then every simulated step every body's gravitational pull on every other is summed from F = G·m₁·m₂/r² and advanced with a symplectic leapfrog integrator. No orbital period is scripted anywhere — Mercury's fast lap and Neptune's slow crawl both fall directly out of the same force law, and you can watch a live-measured period confirm it.

🔬 What it shows

Real Newtonian N-body dynamics for the Sun plus eight planets: real masses in solar-mass units, real semi-major axes in AU and real eccentricities set each planet's exact perihelion position and velocity. Mutual gravity between every pair of bodies (not just Sun-planet) means Jupiter measurably perturbs its neighbours over long runs.

🎮 How to use

The Time scale slider sets how many simulated years pass per real second (0.05–20); Zoom and drag control the view. Toggle orbit trails and labels, and click or tap any planet for a live info card with its real mass, distance, eccentricity, and both its textbook orbital period and the period the simulation itself just measured.

💡 Why a 2D twin?

Viewed from directly above, relative orbital speeds and the very different orbital periods of the inner and outer planets are easy to read at a glance, and a flat canvas with no WebGL scene to composite runs lighter on low-power and mobile devices than the 3D original.

Frequently asked questions

Is this really an N-body simulation, or just planets moving on fixed circles?

It is a real N-body integration. Every step, the gravitational force between every pair of bodies (Sun-planet and planet-planet) is computed from Newton's law and used to update velocities and positions with a leapfrog integrator. Nothing about a planet's speed or path is scripted; both emerge from the physics, which is why the app can measure each planet's period directly from its motion and compare it to the textbook value.

How are the orbital periods and speeds determined?

Each planet starts at its real perihelion distance with the exact perihelion velocity for its real eccentricity, then gravity does the rest. Kepler's third law, T squared proportional to a cubed, is never hard-coded; it is a consequence of integrating F=Gm1m2/r2 over time, which is confirmed by the live "simulated period" readout converging to the real value.

What units does the simulation use?

Distance is measured in astronomical units (AU, Earth's average Sun distance), time in years, and mass in solar masses, chosen so that G times the Sun's mass equals exactly 4*pi^2 — a standard convention in celestial mechanics that keeps the numbers manageable while remaining physically exact.

Why does the simulation take many sub-steps per frame?

Mercury completes an orbit in about a quarter of a year, so at high time-scale a single large step per frame would be too coarse and the symplectic leapfrog integrator would drift or become unstable. The simulation automatically splits each frame's requested time jump into many smaller sub-steps (capped for performance) so even Mercury's orbit stays accurate and energy-conserving.

How is this different from the 3D Solar System simulation?

The 3D version places each planet on a circular path with a hand-tuned angular speed for visual effect. This 2D version instead simulates real gravity between real masses on real elliptical orbits, so the motion — including each orbit's eccentricity and every planet's measured period — is a genuine physical result rather than an animation.

⚙ Under the hood

A real top-down N-body gravity simulation of the Solar System: the Sun and all eight planets pull on each other through F=Gm1m2/r2, with real relative masses, real semi-major axes and real orbital eccentricities. Orbital periods emerge from the physics itself, verified live against real values, rather than being scripted like the 3D original.

solar systemN-body gravityKepler's lawsorbital mechanicsleapfrog integratorcanvas 2dtop-down

2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)