2025-06-02 08:27:45 -04:00
2025-06-02 21:29:10 -04:00
2025-06-02 21:29:10 -04:00
2025-06-01 19:38:37 -04:00
2025-06-02 08:27:45 -04:00
2025-06-02 21:29:10 -04:00
2025-06-01 19:38:37 -04:00
2025-06-01 10:36:07 -04:00

Orbital Simulator

A C++ implementation of an N-body orbital simulator with high-precision calculations.

Dependencies

  • C++17 compatible compiler
  • CMake 3.10 or higher
  • Boost library (for high-precision decimal arithmetic)
  • Optional: ncurses (for terminal plotting)

Building

  1. Create a build directory:
mkdir build
cd build
  1. Configure with CMake:
cmake ..
  1. Build the project:
make

To enable terminal plotting with ncurses, configure with:

cmake -DENABLE_NCURSES=ON ..

Usage

The simulator can be used to simulate orbital mechanics with high precision. The main components are:

  • Body: Represents a celestial body with position, velocity, and mass
  • Simulator: Manages the simulation of multiple bodies
  • units.hpp: Contains physical constants and unit conversion utilities

Example usage:

#include "simulator.hpp"
#include "units.hpp"

int main() {
    // Create bodies
    std::vector<Body> bodies;
    
    // Earth
    Position earth_pos{Decimal(0), Decimal(0), Decimal(0)};
    Velocity earth_vel{Decimal(0), Decimal(0), Decimal(0)};
    bodies.emplace_back(earth_pos, earth_vel, EARTH_MASS, "Earth");
    
    // Moon
    Position moon_pos{AU, Decimal(0), Decimal(0)};
    Velocity moon_vel{Decimal(0), MOON_ORBITAL_VELOCITY, Decimal(0)};
    bodies.emplace_back(moon_pos, moon_vel, MOON_MASS, "Moon");
    
    // Create simulator
    Simulator sim(bodies, 0.1, 100, "output.txt");
    
    // Run simulation
    sim.run(1000);
    
    return 0;
}

Features

  • High-precision decimal arithmetic using Boost.Multiprecision
  • N-body gravitational simulation
  • Progress tracking and checkpointing
  • Optional terminal visualization
  • Configurable simulation parameters

License

This project is open source and available under the MIT License.

Description
Basic orbital mechanics simulator and visualization
Readme 6.7 MiB
Languages
Rust 28.6%
TypeScript 28.5%
Python 25.1%
Shell 10.3%
CSS 5.5%
Other 2%