From 8b9a06e361c1e3b1ce88fea6babf25fa3660fe87 Mon Sep 17 00:00:00 2001 From: cinnaboot Date: Sat, 3 Jan 2026 13:29:35 -0500 Subject: [PATCH] Update documentation for eccentric orbit support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update README with new 12-field config format and examples showing both circular and eccentric orbits. Update config_assumptions.md to reflect fixed issues and new capabilities. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- README.md | 20 ++++++++++++++------ docs/config_assumptions.md | 26 +++++++++++++++++--------- 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index cf53dd0..04927d2 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ A 3D orbital mechanics simulation using a 2-body gravitational model with sphere ## Features - **2-body gravitational physics** with Euler integration +- **Eccentric orbit support** - circular and elliptical orbits using vis-viva equation - **Sphere of influence (SOI)** transitions between gravitational parents - **3D real-time visualization** using raylib - **Configurable star systems** via simple text files @@ -99,22 +100,29 @@ Configuration files define celestial bodies in a simple text format: ``` # Comments start with # -# Format: name mass(kg) radius(m) x(m) y(m) z(m) parent_index r g b +# Format: name mass(kg) radius(m) x(m) y(m) z(m) parent_index r g b eccentricity semi_major_axis(m) -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 -Moon 7.342e22 1.737e6 1.500e11 0 0 1 0.7 0.7 0.7 +# Sun at origin +Sun 1.989e30 6.96e8 0 0 0 -1 1.0 1.0 0.0 0 0 + +# Earth - circular orbit (e=0) +Earth 5.972e24 6.371e6 1.496e11 0 0 0 0.0 0.5 1.0 0 1.496e11 + +# Comet - eccentric orbit (e=0.7) +Comet 1e14 5e3 1.122e11 0 0 0 0.5 0.8 1.0 0.7 3.74e11 ``` Fields: - **name**: Body name (string, no spaces) - **mass**: Mass in kilograms - **radius**: Radius in meters -- **x, y, z**: Initial position in meters +- **x, y, z**: Initial position in meters (absolute coordinates) - **parent_index**: Index of gravitational parent (-1 for root bodies like stars) - **r, g, b**: RGB color values (0.0 to 1.0) +- **eccentricity**: Orbital eccentricity (0 = circular, >0 = elliptical) +- **semi_major_axis**: Semi-major axis in meters (for e=0, use orbital radius) -Velocities are calculated automatically for circular orbits. +Velocities are calculated automatically using the vis-viva equation based on position and orbital parameters. ## Technical Details diff --git a/docs/config_assumptions.md b/docs/config_assumptions.md index 45d628b..1bda30f 100644 --- a/docs/config_assumptions.md +++ b/docs/config_assumptions.md @@ -1,11 +1,16 @@ # Configuration File Assumptions and Issues +## Recent Updates: +- ✅ **FIXED**: Eccentric orbit support added via eccentricity and semi_major_axis parameters +- ✅ **FIXED**: Binary star barycenter calculation +- ⚠️ **TODO**: Moon and Jupiter's moons positions still incorrect in solar_system.txt + ## Key Assumptions Found: ### **1. Format Assumptions (from config_loader.cpp)** -- Line buffer limited to 256 characters (config_loader.cpp:30) -- Name limited to 64 characters (config_loader.cpp:31) -- All 10 fields must be present: `name mass radius x y z parent_index r g b` (config_loader.cpp:19) +- Line buffer limited to 256 characters (config_loader.cpp:39) +- Name limited to 64 characters (config_loader.cpp:40) +- All 12 fields must be present: `name mass radius x y z parent_index r g b eccentricity semi_major_axis` (config_loader.cpp:16-20) - File format is space-delimited ### **2. Solar System Configuration Issues:** @@ -36,12 +41,15 @@ The moon positions appear to use **absolute coordinates** matching their orbital **Problem 2: Planet positions** - PlanetA1 is at `(3.5e11, 0, 0)` while StarA is at `(3.0e11, 0, 0)` - only 50 million km apart - PlanetB1 is at `(-4.2e11, 0, 0)` while StarB is at `(-3.7e11, 0, 0)` - only 50 million km apart -- These seem reasonable as absolute positions, but the velocity calculation assumes circular orbits - -### **4. Velocity Calculation Assumptions (config_loader.cpp:63-118):** -- All orbits are assumed to be **circular** -- Orbits are calculated in the XY plane perpendicular to Z-axis (config_loader.cpp:92) -- Root bodies (parent_index = -1) get zero velocity +- These seem reasonable as absolute positions (now supports both circular and eccentric orbits) + +### **4. Velocity Calculation Assumptions (config_loader.cpp:78-245):** +- ~~All orbits are assumed to be **circular**~~ - **FIXED**: Now supports both circular (e=0) and eccentric (e>0) orbits +- Velocities calculated using **vis-viva equation**: `v = sqrt(G*M*(2/r - 1/a))` + - For circular orbits: e=0, a=orbital_radius + - For eccentric orbits: e>0, a=semi_major_axis +- Orbits are calculated in the XY plane perpendicular to Z-axis (config_loader.cpp:219-226) +- Root bodies (parent_index = -1) get zero velocity (or orbit barycenter if multiple roots) - Velocities are calculated relative to parent, then parent's velocity is added ### **5. Critical Assumption:**