A high-performance 1D rocket flight simulation engine built with native C++20 and integrated into a real-time 2D graphical visualization interface in Python via pybind11.
This hybrid application models atmospheric flight dynamics from launch through powered ascent, coasting, apogee, and free-fall descent until touchdown, complete with real-time HUD telemetry and an adaptive dynamic camera system.
-
C++ Physics Engine Core: Blazing-fast numerical computation layer integrated natively into Python through high-performance
pybind11C-extension bindings. -
Dynamic Air Density Model: Calculates atmospheric drag based on current altitude using an exponential barometric model:
$$\rho(h) = \rho_0 \cdot e^{-h/H}$$ - Variable Mass & Thrust Dynamics: Simulates fuel mass depletion in real time, dynamically updating total vehicle mass ($m(t)$), motor thrust, and acceleration at each integration step.
-
Euler Integration Scheme: Solves state variables iteratively:
$$\text{Position} \longrightarrow \text{Acceleration} \longrightarrow \text{Velocity}$$ - Real-Time Pygame HUD & Visualizer: Renders flight animation with an integrated HUD display (altitude, velocity, acceleration, fuel level, engine status) and a dynamic tracking camera centered on the vehicle.
The engine models three core forces acting on the vehicle along the vertical axis:
-
Thrust (
$F_T$ ): Active during motor burn phase ($F_T = \dot{m} \cdot v_e$ ). -
Gravity (
$F_g$ ):$F_g = m(t) \cdot g$ -
Aerodynamic Drag (
$F_D$ ):$$F_D = \frac{1}{2} \cdot \rho(h) \cdot v \cdot |v| \cdot C_d \cdot A$$ where $A = \pi \cdot r^2$ is the cross-sectional area derived from vehicle diameter.
- Engine: C++20
- Visualizer: Python 3 (Pygame)
- Binding:
pybind11 - Build System: CMake 3.20+
- C++20 compatible compiler (
clang++,g++, or MSVC) - Python 3.10+ with
pygameandpybind11installed - CMake 3.20+
Clone the repository:
git clone [https://github.com/karinarosot/Rocket-Flight-Simulator-Program.git](https://github.com/karinarosot/Rocket-Flight-Simulator-Program.git)
cd Rocket-Flight-Simulator-Program
# Install Python Dependencies
pip install pygame pybind11
# Build the Native C++ Extension Module
mkdir build && cd build
cmake ..
cmake --build .
# Run Simulation
mkdir build && cd build
cmake ..
cmake --build .
# Controls & HUD Telemetry
During flight execution, the real-time telemetry HUD displays:
* Altitude
* Velocity
*Acceleration
*Fuel mass
*Engine stats: BURNING- during powered ascent and COASTING after burnout.