This repository builds upon my previous work on 3-Body Simulation. While the core implementation remains unchanged, this version introduces support for both spherical and Cartesian coordinate systems. Note that the angle
-
Clone the repository and navigate to the project directory:
git clone https://github.com/oadultradeepfield/three-body-simulation.git cd three-body-simulation
-
Create a build directory, generate the Makefile with CMake, and build the project:
mkdir build cd build cmake .. make
-
Install Python dependencies for visualization:
pip install -r python/requirements.txt
-
Configure the simulation by editing
config.txt
andbodies_cartesian.txt
orbodies_spherical.txt
:-
config.txt
G=6.6743e-11 dt=1000 total_time=3.16e7 filename=results/example_sun_earth_lagrangian_points.txt
-
bodies_spherical.txt
# Sun 1.989e30 0.0 0.0 1.5707963268 0.0 0.0 0.0 # Earth 5.972e24 1.496e11 0.0 1.5707963268 0.0 2.9788e4 0.0 # L1 6.500e3 1.481e11 0.0 1.5707963268 0.0 2.9489e4 0.0 ...
-
-
Run the simulation (change
spherical
tocartesian
if you wish to do so):build/NBodySimulation config.txt bodies_spherical.txt spherical
-
Generate trajectory plots (optional):
python3 python/plot.py --filename ./results/example_sun_earth_lagrangian_points.txt --N 7 --labels Sun,Earth,L1,L2,L3,L4,L5
The output plot will be saved in the same directory as the .txt
file.
Example 3D Trajectory | Example XY Projection |
---|---|