Home / Visualizations / N-Body Gravity Simulation

Controls

Preset Scenarios

Statistics

Bodies 0
Total Energy 0.00
Energy Conservation 100.00%
Max Velocity 0.00
Simulation Time 0.00

Instructions

  • Click and drag on canvas to add celestial bodies
  • Drag line length represents initial velocity
  • Drag direction represents velocity direction
  • Select preset scenario for quick start
  • View energy conservation in real-time

Newton's Law of Universal Gravitation

F = G·m₁·m₂/r²: Any two point masses attract each other with a force proportional to the product of their masses and inversely proportional to the square of the distance between them.

The N-Body Problem

The N-body problem studies the motion of multiple celestial bodies under mutual gravitational attraction. Even with just three bodies, the system can exhibit unpredictable chaotic behavior. This is a classic example in chaos theory.

Chaos Theory

Chaotic systems are extremely sensitive to initial conditions. In the three-body problem, tiny differences in initial conditions lead to completely different orbital evolutions. This is the famous 'butterfly effect'.

Energy Conservation

In an isolated system, total energy (kinetic + potential) remains constant. This is an important metric for validating numerical integrator accuracy.

Orbital Mechanics Basics

Kepler's laws describe three rules governing planetary motion: elliptical orbits, equal areas swept in equal time, and the square of the period being proportional to the cube of the semi-major axis.

1687: Newton's Principia
Newton published the law of universal gravitation and three laws of motion, laying the foundation for classical mechanics.
1772: Lagrange Points
Lagrange found five special solutions to the three-body problem, known as the Lagrange points.
1890: Poincaré's Chaos Discovery
Poincaré proved the non-integrability of the three-body problem, pioneering the study of chaos theory.
Modern Applications
N-body simulations are widely used in space missions, galaxy formation, planetary system evolution, and more.

1. Create a Stable Orbit

Click and drag to add a small mass body, giving it a tangential velocity. Watch how it orbits around the large mass. Adjust the initial velocity until you achieve a nearly circular orbit.

2. Three-Body Chaos Demonstration

Select the 'Chaotic Three-Body' preset. Observe the complex motion of three similar-mass bodies. Slightly change one body's initial position and run again to see the huge difference in results.

3. Gravity Assist Slingshot

Select the 'Gravity Assist' preset. Watch how a small body gains speed by approaching a large body. This is how spacecraft use planetary gravity to accelerate toward outer planets.

4. Orbital Resonance

Create two small bodies orbiting the same central body. Adjust their orbital radii so their periods form a simple integer ratio (like 2:1). Watch how they periodically interact with each other.