A dynamic and visually engaging n-body simulation inspired by 'The Three-Body Problem'. This application simulates gravitational interactions between stars, planets, and particles, supporting features such as zooming, time control, camera movement, and preloaded systems like the Solar System and Alpha Centauri system.
- Realistic Gravitational Physics:
- Leapfrog integration and Plummer softening for stability and accuracy.
- Celestial Bodies:
- Stars: Color-coded by mass and size based on astrophysical principles.
- Planets: Radius and color based on type (rocky, gas giant, etc.).
- Particles: Lightweight objects for additional realism in systems.
- Interactive UI:
- Zoom & Scale: Adjust scale from astronomical units to planetary levels.
- Time Control: Change simulation speed or pause.
- Camera Movement: Focus on specific objects or freely navigate the simulation.
- Body Addition: Dynamically add stars and planets with mass and velocity control via mouse interactions.
- Labels: Mass, velocity, and type of focused bodies displayed on-screen.
- Preset Systems:
- Solar System: Includes the Sun, planets, and Pluto.
- Alpha Centauri: Binary stars with hypothetical planets and Proxima Centauri with known planet proxima centauri b.
- Particle Cloud: Dense particle systems for clustering and visualizing formation of planets naturally. (still experimental, large amount of particles slow down the simulation significantly)
- Velocity Calculations:
- Computes and displays escape velocity and orbital velocity during body addition.
- Custom Visuals:
- Dynamic rendering of body size and color.
Space: Pause/Resume simulation.=: Zoom in.-: Zoom out.Arrow Up/Down: Adjust time speed.R: Reset the simulation.
W/A/S/D: Move camera when unfocused.Arrow Left/Right: Cycle focus between bodies.U: Unfocus the camera.
- Add Bodies:
C: Switch to "Star" mode.P: Switch to "Planet" mode.- Left-Click + Drag: Set velocity for a new body based on drag direction.
- Drag velocity is relative w.r.t the focused body and raw velocity otherwise
- Hold Left-Click: Incrementally increase body mass.
X: Delete the currently focused body.
1: Load Solar System.2: Load Alpha Centauri system.3: Load particle cloud.
- Solar System Simulation
- Python 3.8+
- Libraries:
pygame,numpy
- Install required libraries:
pip install pygame numpy
- Run
python main.py



