Astrophysics Orbital Mechanics FREE NEW

Orbital Mechanics Simulator

N-body leapfrog integrator with Kepler's three laws, orbital element readout, area-sweep visualisation, and five presets from the Solar System to the figure-8 choreography.

Preset:
Sim:
1.0×
Trail length: 300

Orbital Elements

Body
Mass
Speed (u/tu)
Semi-major axis a
Eccentricity e
Period T
Kinetic energy
Potential energy
Total energy

Keyboard

SpacePause / resume
RReset preset
SToggle sweep
LToggle labels
Speed up
Slow down
Click bodySelect for stats

Kepler's Three Laws of Planetary Motion

Published between 1609 and 1619, Kepler's three empirical laws revolutionised astronomy and later provided Newton with the observational foundation for the law of universal gravitation.

First Law — Elliptical Orbits

Every planet orbits the Sun in an ellipse, with the Sun at one of the two foci. A circle is the special case where eccentricity e = 0.

Second Law — Equal Areas

A line joining a planet to the Sun sweeps out equal areas in equal intervals of time. This is equivalent to conservation of angular momentum.

Third Law — Harmonic Law

The square of a planet's orbital period is proportional to the cube of its semi-major axis: T² ∝ a³. Exactly T² = 4π²a³ / (GM) in Newton's formulation.

Newtonian Gravity & the Vis-viva Equation

Newton's law of universal gravitation gives the force between two masses m1 and m2 separated by distance r:

F = G m₁ m₂ / r²

Combining this with conservation of energy produces the vis-viva equation, one of the most useful tools in orbital mechanics:

v² = GM ( 2/r − 1/a )

Here v is the orbital speed at distance r from the focus, M is the central mass, and a is the semi-major axis. Setting r = a gives the mean orbital speed; setting a → ∞ gives the escape velocity vesc = √(2GM/r).

Orbital Elements

Any Keplerian orbit is fully described by six orbital elements. The three scalar quantities displayed in the stats panel are derived from the current position and velocity via the vis-viva equation and specific angular momentum:

ElementSymbolDefinition
Semi-major axisaHalf the longest diameter of the ellipse; controls the orbital period via Kepler's 3rd law
EccentricityeShape: 0 = circle, 0–1 = ellipse, 1 = parabola, >1 = hyperbola
Orbital periodTT = 2π√(a³/GM); time for one complete orbit
InclinationiTilt of the orbital plane relative to a reference plane (3-D; not shown in 2-D sim)
Longitude of ascending nodeΩOrientation of the orbital plane in 3-D space
Argument of periapsisωOrientation of the ellipse within the orbital plane

Integration Method: Velocity Verlet (Leapfrog)

The simulator uses the Velocity Verlet (leapfrog) algorithm — a second-order symplectic integrator that exactly conserves a modified Hamiltonian, keeping orbits stable for thousands of periods without secular energy drift:

vₙ₊½ = vₙ + ½ aₙ Δt
xₙ₊₁ = xₙ + vₙ₊½ Δt
aₙ₊₁ computed from xₙ₊₁
vₙ₊₁ = vₙ₊½ + ½ aₙ₊₁ Δt

This contrasts with the non-symplectic 4th-order Runge-Kutta method, which — despite higher formal accuracy — slowly loses or gains energy, causing orbits to spiral inward or outward over long integrations.

Presets Explained

Solar System (5 bodies)

Sun, Mercury, Venus, Earth, and Mars at scaled distances proportional to their real orbital radii. Planet–planet interactions are included but negligible compared to solar gravity, so the orbits closely approximate Keplerian ellipses. Mercury's smaller orbital radius and higher eccentricity produce its faster, more elliptical path.

Binary Stars (3 bodies)

Two equal-mass stars orbiting their common centre-of-mass (barycentre) while a planet follows a circumbinary orbit far enough out to remain stable. The stability criterion for circumbinary orbits is approximately rplanet > 2–5 × rbinary, depending on the mass ratio and eccentricity.

Halley's Comet (3 bodies)

A highly eccentric orbit (e ≈ 0.97) with a small perihelion (close approach) and a large aphelion (far point). The vis-viva equation shows that the comet moves faster at perihelion and slower at aphelion, with the Sun at one focus. The Earth orbit serves as a reference scale.

Trojan Asteroids (4 bodies)

Jupiter's L4 and L5 Lagrange points lie 60° ahead and behind Jupiter on its orbit. Bodies placed exactly at these equilateral-triangle positions are gravitationally stable — this mirrors the real Trojan asteroid population (over 12,000 known). The simulation demonstrates the slow libration oscillations around L4 and L5.

Figure-8 Choreography (3 bodies)

The Chenciner–Montgomery periodic solution (2000) has three equal masses chasing each other along a figure-of-eight curve in their mutual gravitational field. The orbit has period T ≈ 6.3259 in natural units and requires a symplectic integrator to maintain stability for even a few periods, owing to the extreme sensitivity of the three-body problem to initial conditions.

The Three-Body Problem and Chaos

Henri Poincaré proved in 1889 that the general three-body problem has no closed-form analytical solution. The system is chaotic: exponentially sensitive to initial conditions with a positive Lyapunov exponent. The figure-8 choreography is one of the rare periodic solutions; typical three-body configurations eventually eject one body on a hyperbolic escape trajectory.

The Kolmogorov-Arnol'd-Moser (KAM) theorem shows that for nearly integrable systems (small planet-to-star mass ratios), most orbits remain quasi-periodic — this is why the Solar System has been roughly stable for 4.5 billion years. However, computer simulations by Laskar (1989) show that Mercury could be ejected or collide with Venus on a timescale of ~5 billion years.

Orbit typeEccentricity eTotal energy ξExample
Circle0ξ < 0Idealised planet at constant altitude
Ellipse0 < e < 1ξ < 0Earth (e ≈ 0.017), Halley (e ≈ 0.967)
Parabola1ξ = 0Minimum escape trajectory
Hyperbolae > 1ξ > 0Oumuamua (interstellar, e ≈ 1.2)

Space Mission Design

Orbital mechanics underlies all spaceflight. The Hohmann transfer orbit is the most fuel-efficient way to move between two circular orbits: two tangential burns, with the transfer ellipse touching both orbits at periapsis and apoapsis. The Δv (change in velocity) required is:

Δv₁ = √(GM/r₁)(√(2r₂/(r₁+r₂)) − 1)
Δv₂ = √(GM/r₂)(1 − √(2r₁/(r₁+r₂)))

Gravity assists (slingshot manoeuvres) exploit the swing-by of a planet to gain or lose speed relative to the Sun without using propellant — the spacecraft gains energy from the planet's orbital motion, limited by the planet's sphere of influence and its own orbital speed.