From 98e2d5f360bc6b3156f774d310283758009623d6 Mon Sep 17 00:00:00 2001 From: cinnaboot Date: Wed, 7 Jan 2026 17:35:46 -0500 Subject: [PATCH] Update implementation_plan.md to reflect current code: RK4 integration, TOML config format, add missing structures, move completed features --- docs/implementation_plan.md | 73 +++++++++++++++++++++++++++++-------- 1 file changed, 58 insertions(+), 15 deletions(-) diff --git a/docs/implementation_plan.md b/docs/implementation_plan.md index 73d18f7..348e961 100644 --- a/docs/implementation_plan.md +++ b/docs/implementation_plan.md @@ -5,7 +5,7 @@ ## Technical Constraints - C-style C++ only: structs and functions, no classes or templates -- Euler integration for physics +- RK4 (Runge-Kutta 4th order) integration for physics - Simple rotations (quaternions deferred) - raylib for 3D visualization @@ -55,22 +55,60 @@ struct RenderState { }; ``` +### OrbitalElements (bodies.h) +```cpp +struct OrbitalElements { + double time_days; + double semi_major_axis_au; + double eccentricity; + double specific_energy; + double distance_to_sun_au; + double distance_to_ref_body_au; + double velocity_magnitude; +}; +``` + +### AccelerationContext (physics.h) +```cpp +struct AccelerationContext { + SimulationState* sim; + CelestialBody* current_body; + int body_index; +}; +``` + ## Module Overview ### Physics (physics.cpp/h) -Vector math and gravity calculations. Euler integration with `euler_step()`. +Vector math and gravity calculations. RK4 (Runge-Kutta 4th order) integration with `rk4_step()`. ### Bodies (bodies.cpp/h) Simulation state management and updates. SOI detection using Hill sphere: `r_soi = a * (m/M)^(2/5)` ### Config Loader (config_loader.cpp/h) -Text-based config parser. Auto-calculates circular orbit velocities and SOI radii. - -**Config format:** -``` -# name mass(kg) radius(m) x(m) y(m) z(m) parent_index r g b -Sun 1.989e30 6.96e8 0 0 0 -1 1.0 1.0 0.0 -Earth 5.972e24 6.371e6 1.496e11 0 0 0 0.0 0.5 1.0 +TOML-based config parser using tomlc17 library. Auto-calculates circular orbit velocities and SOI radii. + +**Config format (TOML):** +```toml +[[bodies]] +name = "Sun" +mass = 1.989e30 +radius = 6.96e8 +position = { x = 0.0, y = 0.0, z = 0.0 } +parent_index = -1 +color = { r = 1.0, g = 1.0, b = 0.0 } +eccentricity = 0.0 +semi_major_axis = 0.0 + +[[bodies]] +name = "Earth" +mass = 5.972e24 +radius = 6.371e6 +position = { x = 1.496e11, y = 0.0, z = 0.0 } +parent_index = 0 +color = { r = 0.0, g = 0.5, b = 1.0 } +eccentricity = 0.0 +semi_major_axis = 1.496e11 ``` ### Renderer (renderer.cpp/h) @@ -82,13 +120,17 @@ Raylib 3D visualization with logarithmic distance scaling and size scaling for v - Phase 1-4: Core physics, simulation, config loading, and rendering - Raylib integration with 3D camera - Distance and size scaling for visualization -- Config file system with solar_system.txt +- TOML config file system with solar_system.toml, example_binary_star.toml, test_simple.toml +- RK4 (Runge-Kutta 4th order) integration for improved accuracy +- Time scaling controls (speed up/slow down simulation) +- Pause/resume functionality +- Orbital elements calculation +- Binary/multiple star system support with barycentric orbits ### 🔨 Remaining/Future Work -- Time scaling controls (speed up/slow down) -- Pause/resume functionality -- Additional config files (binary star, etc.) -- Time step tuning for stability +- More accurate integration methods (Newton-Raphson propagation) +- Interactive body selection +- Reference frame switching ## Technical Notes @@ -103,6 +145,7 @@ Raylib 3D visualization with logarithmic distance scaling and size scaling for v - May need multiple physics sub-steps per render frame ## Future Enhancements -- More accurate integration (RK4, Verlet), NOTE: try Newton-Raphson propagation method with testing first +- More accurate integration methods (Newton-Raphson propagation) - Interactive body selection - Reference frame switching +- 3D orbital visualization with inclination