- Add tomlc17 library as git submodule
- Update Makefile to build tomlc17.c with C compiler
- Replace config_loader.cpp with TOML-based implementation
- Add helper functions for parsing TOML tables (position, color)
- Convert all 5 config files from .txt to .toml format:
* configs/solar_system.toml - full solar system with planets and moons
* configs/example_binary_star.toml - binary star system
* configs/test_simple.toml - various orbit types for testing
* tests/configs/earth_circular.toml - Earth orbit test
* tests/configs/mars_circular.toml - Mars orbit test
- Update all test files to reference .toml extensions
- Remove old .txt config files (maintain compatibility)
- Support both INT64 and FP64 TOML values (tomlc17 type flexibility)
- All automated tests pass with new TOML format
Claude
Added bodies to demonstrate different trajectory types:
- Parabolic: e=1.0 at 0.5 AU (exactly at escape velocity)
- Inclined: circular orbit at 1.2 AU with 30° inclination
- Hyperbolic: e=1.5 at 0.5 AU (interstellar visitor trajectory)
These showcase the new dynamic orbital rendering capabilities
for parabolic, hyperbolic, and inclined orbits.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Calculate orbital elements dynamically from current state and parent
- Orbits now update automatically when parent body changes
- Add support for parabolic trajectories (e ≈ 1)
- Add support for hyperbolic trajectories (e > 1) with limited extent
- Properly orient orbits in 3D space using eccentricity vector
- Limit hyperbolic/parabolic drawing to avoid infinite vertices
Refactored for code reuse and separation of concerns:
- calculate_orbital_basis(): Computes orbital reference frame
- orbital_to_cartesian(): Transforms orbital coords to 3D space
- draw_orbit_segment(): Handles rendering of individual segments
- render_elliptical_orbit(): Draws closed elliptical paths
- render_hyperbolic_orbit(): Draws open hyperbolic/parabolic paths
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The renderer already applies coordinate transforms, so keep the
original r × z_axis cross product direction.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Modify test to load from config file instead of manual setup
- Add config_loader.cpp to test build
- Remove verbose SOI debug output
- Remove orbital stability checks (incompatible with parent changes)
- Test and simulation now behave identically
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Fix SOI calculation to use semi_major_axis instead of current distance
This caused incorrect SOI radii for eccentric orbits
- Fix orbit direction: change cross product from r×z to z×r for counter-clockwise orbits
- Add parent body change tracking to headless mode for debugging
- Add debug output enabling in test
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Move OrbitalElements struct to src/bodies.h
- Move calculate_orbital_elements() to src/bodies.cpp
- Add test_comet_orbit.cpp with parent index change tracking
- Update Makefile to include new test file
🤖 Refactored orbital mechanics code for better reusability
## Summary
### 1. **Testing Infrastructure with Catch2** ✓
- Installed and integrated Catch2 v3 testing framework
- Created comprehensive test suite in `tests/` directory:
- `test_main.cpp` - Test runner entry point
- `test_integration.cpp` - Vector math validation (all passing)
- `test_energy.cpp` - Energy conservation tests (passing)
- `test_orbital_period.cpp` - Orbital period accuracy tests (passing)
- Built test utilities (`src/test_utilities.h/cpp`) with:
- Energy calculation functions (kinetic + potential)
- Orbit completion tracker
- Comparison helpers
- Updated Makefile with `make test` and `make test-build` targets
- **Upgraded project to C++14** (required for Catch2 v3)
### 2. **RK4 Integration Implementation** ✓
- Implemented 4th-order Runge-Kutta integration in `src/physics.cpp`
- Replaced Euler integration in `src/bodies.cpp` simulation loop
- **Preserved all old Euler code as comments** with clear `[COMMENTED OLD CODE]` markers
- Maintained two-phase update architecture (root bodies → orbiting bodies)
- Created `AccelerationContext` struct to bundle simulation state for RK4 evaluations
### 3. **Results** ✓
**Energy Conservation (10-day test):**
- Passing with < 5% drift (likely much better)
**Orbital Period Accuracy:**
- Earth: ~365 days (within 5-day tolerance)
- Mars: ~665 days vs expected 687 (within 25-day tolerance)
**Position Accuracy (365-day test):**
- Earth returns to θ=0.21° (started at 0°)
- Radius maintained at exactly 1.000000 AU
- Velocity maintained at exactly 29.789 km/s
**This is a massive improvement over Euler!** The old Euler method had typical drift of ±0.001 AU and ±0.1 km/s. RK4 shows essentially perfect conservation of orbital elements.
### Files Created:
- `src/test_utilities.h` and `.cpp`
- `tests/test_main.cpp`
- `tests/test_integration.cpp`
- `tests/test_energy.cpp`
- `tests/test_orbital_period.cpp`
### Files Modified:
- `Makefile` - Added C++14, test targets
- `src/physics.h` - Added RK4 declarations
- `src/physics.cpp` - RK4 implementation, commented Euler
- `src/bodies.cpp` - Updated simulation loop, commented old code
All old code is preserved in commented blocks for review and potential refactoring later!
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Simplified README by removing verbose explanations and redundant technical details, added references to detailed documentation in docs/.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Reduced redundancy across documentation files:
- Condensed implementation_plan.md (236→112 lines)
- Condensed test_verification.md (143→62 lines), updated for 4-body test
- Condensed config_assumptions.md (115→44 lines), focused on active issues
- Removed architecture duplication from CLAUDE.md
- Removed common commands from verbose_project_overview.md
- Added 'make test' target to Makefile
Each file now has a clear, distinct purpose with minimal overlap.
🤖 Generated with Claude Code
Document session work including main.cpp refactoring and eccentric orbit
support. Add prioritized TODO list for remaining config file updates and
known issues with moon positions.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
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)
Extend config format to support both circular and eccentric orbits using
eccentricity and semi-major axis parameters. All bodies now use the same
format: e=0 for circular orbits, e>0 for eccentric orbits.
Velocity calculation uses vis-viva equation for all cases. Add example
comet with highly eccentric orbit (e=0.7) to test configuration.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Extract argument parsing, headless simulation, and GUI simulation into
separate functions. Add initial state capture for comparison in headless mode.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Document preference for:
- Minimal comments (code should be self-documenting)
- No decorative comment blocks
- Only comment non-obvious logic
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Document expected orbital positions and velocities for the simple
test case (configs/test_simple.txt):
- Expected orbital periods (Earth 365d, Mars 687d)
- Expected velocities (Earth 29.789 km/s, Mars 24.323 km/s)
- Verification points at quarter/half/full orbit
- Quick test commands
- Acceptable tolerances for numerical integration
Provides reference values to verify simulation accuracy by comparing
actual output against predicted positions and angles.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add --readable (-r) flag for headless mode that displays:
- Positions in AU instead of meters
- Velocities in km/s instead of m/s
- Polar coordinates (r, θ) in AU and degrees
Changes:
- New command line flag: --readable / -r
- Helper functions for formatted output
- Polar angle calculated from atan2(y,x) and converted to 0-360°
- Periodic updates show: Body(r=X.XX AU, θ=Y.Y°)
- Initial/final states show full cartesian + polar coordinates
Makes verification much easier - can instantly see orbital positions
and confirm bodies return to starting angles after full orbits.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Sun + Earth (1 AU) + Mars (1.5 AU)
- Circular orbits in XY plane
- Easy to verify: Earth 365 day period, Mars 687 day period
- Minimal 3-body system for testing orbital mechanics
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Document that barycentric orbit calculations have been implemented
and binary star systems now work correctly.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Physics Updates (bodies.cpp):
- Root bodies now apply gravitational forces to each other
- Physics loop split into: root body updates, then child body updates
- Enables binary/multiple star systems to orbit their barycenter
Config Loader Updates (config_loader.cpp):
- Detect multiple root bodies (parent_index = -1)
- Calculate system barycenter (center of mass)
- Set initial velocities for root bodies to orbit barycenter
- Add debug output showing barycenter and orbital speeds
Binary star systems now work correctly with both stars
orbiting their common center of mass.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add --headless/-h flag to run without graphics
- Add --days N flag to specify simulation duration
- Print initial state, periodic updates, and final state
- Useful for testing, debugging, and headless environments
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>