Physics simulation2025

Three Body Problem

Gravity simulator with a velocity-Verlet integrator, six orbital presets and live energy readout.

Figure-eight

A three-body gravity simulator built on a velocity-Verlet integrator with gravitational softening, six named orbital presets, and a live total-energy readout that shows the integrator conserving energy — or failing to, when you push it. Zero dependencies.

ContributionSole author.

6Orbital presets
2,000Max trail length
0Dependencies

How it works

  • Integrator is velocity-Verlet: accelerations computed, positions advanced by v·dt + ½a·dt², accelerations recomputed, velocities corrected.
  • Gravitational softening avoids singular forces at close approach.
  • Pairwise force accumulation is O(n²) exploiting Newton’s third law reciprocity.
  • Six orbital presets, including the figure-eight solution.
  • Trails capped at 2,000 points; no runtime dependencies.
Three Body Problem — Alejandro Newport