This project aims to simulate how orbital mechanics work
![]() |
![]() |
![]() |
![]() |
| Earth around the Sun | Mercury, Venus, Earth and Mars orbiting the Sun | Geostationary orbit around earth | Two Massive objects orbiting a fixed point |
![]() |
| 3D animation of 3 planets in orbit |
usage: orbit_simulator [-h] [-3d] [-c] preset_name
positional arguments:
preset_name
options:
-h, --help show this help message and exit
-3d, --3d
-c, --coords
Run preset SOLAR_SYSTEM with 3d rendering
python3 orbit_simulator solar_system -3d
Planet mass:
Distance:
Speed & Velocity:
This is an aproximate value of
In a 2d matrix, celestial bodies have
And for a 3d matrix, you simply need to add the
To calculate the gravitational acceleration I decided to use Newton's universal gravitational law, since it's simpler and works well for the scenarios addressed by the simulator (Stars, planets, ships and natural or artificial satellites)
Using that equation, and considering that
Therefore,
Imagine you have a celestial body on the following XY coordinates:
That means the distance from the
That also means that
Now let's take into consideration that the speed of the celestial body is
The approximate distance it should move on each axis after 1 second is then
These are the distances we should substract from the coordinates, resulting into new coordinates of
The simulator uses the same trigonometry principles, where the target celestial body position
Also, the simulator uses a 3D matrix to simulate the




