Gravity simulator
Scientific softwareC++ desktop simulation
An interactive orbital sandbox
An interactive two-dimensional gravitational simulator with body selection, camera tracking, asteroid launch controls, collision merging, and adjustable simulation speed.
System architecture
- 01Body states
- 02Pairwise gravity
- 03Velocity Verlet
- 04Collision merging
- 05Interactive rendering

Orbital simulation in motion
Recorded demonstration of the gravity simulator, with orbiting bodies and visible motion trails.
Numerical dynamics
The simulation calculates pairwise gravitational acceleration and advances the system using velocity Verlet. Close encounters and fast flybys limit the timestep through bounded subdivisions, helping resolve rapid changes in the interaction geometry.
Collision handling
Swept collision checks identify contact during the position update. Merged bodies use mass-weighted position and velocity; the implementation also accounts for kinetic energy lost in the merge. The model is a Newtonian sandbox, not a relativistic astrophysics solver.
Interactive experimentation
The desktop interface supports launching bodies, changing launch mass and radius, selecting and following a body, pausing, resetting, and inspecting performance or accuracy displays. The animation shows the desktop simulator in operation; the linked repository contains the application. A live browser simulation is deferred.