My attempt at simulating gravity via classical mechanics and specifically Newton’s law of universal gravitation (Euler’s formula):
Earth and Moon ~month
This Gif shows a simulated trip for the moon (orange) around the earth (blue). The red vector shows the direction of the applied force while the blue one shows the velocity of the object.
Config : Frames: 686, Steplength: 1s, Seconds/Frame: 60 * 60 (1 Hour / Frame),
Objects:
Data | Earth | Moon |
---|---|---|
X-Pos | 0 | 0 |
Y-Pos | 0 | 369671000 |
X-Vel | 0 | 1082 |
Y-Vel | 0 | 0 |
Mass | 6 * 10 ** 24 | 7.3 * 10 ** 22 |
Earth and Moon ~Year
Frames: 365, Steplength: 1s, Seconds/Frame: 60 * 60 * 24 (1 Day / Frame),
- Clone this repo
- Make sure your python env has the required dependencies, otherwise install with pip install
- imageio
- matplotlib
- Configure setting and indata in Simulation.py
- Run Simulation.py with: Python3 Simulation.py
- Simulation gif should be in the "Gifs" folder
This project was made to practice object-oriented programming in Python.