This project simulates a planet orbiting a star using Newton's Law of Universal Gravitation and basic physics.
You can watch the orbit evolve over time with a live animation and even see a fading trail behind the planet!
- Realistic gravitational physics
- Adjustable orbital parameters (mass, velocity, distance, etc.)
- Fading orbit trail for a cool visual effect
- Uses
matplotlibfor animation - Based on Earth's orbit around the Sun
main.py— Main simulation scriptREADME.md— You're here!
The force between the star and the planet is calculated using: F = G * (m1 * m2) / r²
Where:
Gis the gravitational constantm1andm2are the massesris the distance between them
This force updates the planet’s velocity and position using basic kinematics.
You’ll need Python and these libraries:
matplotlibmath
Install them using:
pip install matplotlib