Orbit Sandbox
Fling a planet into orbit and watch the n-body dance.
IntermediateWeb appCreative10–22hAI-buildable 4/5no setup
Place bodies with a mass and an initial velocity, then let gravity do the rest. Trails reveal the orbits. Simple Euler integration visibly loses energy over time, so this is a great excuse to implement a better integrator and see the difference.
UI
Logic
Useful
Hosting · Free forever
Deploys free on GitHub Pages, Cloudflare Pages or Vercel Hobby.
Deploy it and share a link.
Core features · 7
- Place bodies by dragging to set position and initial velocity
- Gravitational attraction computes between all bodies
- Orbital trails render and fade
- Mass is adjustable and reflected in body size
- Simulation speed is adjustable and pausable
- Preset scenarios like a stable binary can be loaded
- Total system energy is displayed so drift is visible
The interesting part
- Euler integration loses energy visibly, so a symplectic integrator is needed
- Numerical instability when bodies pass very close
- n-body attraction is O(n²) per step
Once it works
- Add collision and merging of bodies
- Add a camera that follows a chosen body
- Add a Lagrange point visualisation
Suggested stack
reacttypescripttailwindcanvas-api