- Add solve_barker_equation() function using cubic formula: D + D³/3 = M
- Integrate Barker's equation into propagate_orbital_elements() for parabolic orbits
- Add comprehensive test suite (11 tests, 239 assertions) following TDD
- Use cbrt() for cube root (handles negative numbers properly)
- Parabolic propagation now uses exact analytical solution instead of iterative solver
- All 93 tests passing (239,872 assertions)
- Add 16 minimal comments documenting formulas in orbital_mechanics.cpp
- Fix parabolic test to use orbital_elements_to_cartesian() instead of manual velocity
- Tighten parabolic test tolerance from 1e10 to 1e3 (7 orders of magnitude)
- Reduce parabolic test error from 6.5% to machine precision
- Add near-parabolic detection for |1-e| < 0.01
- Use cosine/sine formulation with atan2() to preserve quadrant
- Avoid catastrophic cancellation in sqrt((1+e)/(1-e)) factor
- Clamp values to [-1,1] to handle precision issues
- Maintain original formula for well-behaved orbits
- Add PARABOLIC_TOLERANCE = 1e-3 constant for consistent detection
- Replace inconsistent thresholds (0.005, 0.98, 1.02) across 5 files
- Refactor orbital_elements_to_cartesian() to use semi-latus rectum as primary parameter
- Eliminate 3 separate code branches with unified formulas for all orbit types
- Improve numerical stability for parabolic and near-parabolic orbits
- Reduce code complexity: -23 lines net
- Convert 64 test assertions from Approx() to WithinAbs() in 2 new test files
- Add WithinAbs() testing guidelines to AGENTS.md
- Fix cartesian_to_orbital_elements(): eccentricity vector calculation,
true anomaly normalization, parabolic semi-latus rectum handling
- Add 2 new test files for edge cases and quadrature points
New modular API:
- solve_kepler_elliptical(M, e): Newton-Raphson for E - e·sin(E) = M
- solve_kepler_hyperbolic(M, e): Solver for H - e·sinh(H) = M
- eccentric_to_true_anomaly(E, e): Convert eccentric to true anomaly
- hyperbolic_to_true_anomaly(H, e): Convert hyperbolic to true anomaly
- mean_anomaly_to_true_anomaly(M, e): Unified wrapper (dispatches based on e)
Changes:
- Renamed solve_kepler_equation() → solve_kepler_elliptical() for clarity
- Extracted KEPLER_TOLERANCE and KEPLER_MAX_ITERATIONS constants
- Separated hyperbolic solver logic from combined function
- Fixed test_newton_raphson_convergence to verify Kepler's equation
(instead of incorrectly expecting E ≈ M for small e)
- Added TODO comment for future cartesian_to_orbital_elements refactoring
New validation function validate_true_anomaly_ranges() checks that
hyperbolic orbits (e > 1) have true anomalies within physically valid
range: |ν| < arccos(-1/e)
This prevents configs from specifying starting positions that would
cause negative radius values (1 + e·cos(ν) ≤ 0).
Config changes:
- 'Slightly_Hyperbolic': e=1.05, a=-1.3e8 (perigee at 6.5e6 m)
- 'Near_Parabolic': e=0.99, a=7.0e8 (perigee at 7e6 m)
Test changes:
- Added check for hyperbolic orbit anomaly limits (|ν| < arccos(-1/e))
- Skip testing ν=π and 3π/2 when they exceed valid range for e>1
Bug: r_dot_e was incorrectly divided by mu instead of r_mag*e_mag,
causing cos_nu values of ~7.5e6 (far outside [-1,1]) which made acos() return NaN.
Fix: Calculate cos_nu correctly as r_dot_e/(r_mag*e_mag) and clamp
to [-1, 1] to handle floating-point precision errors.
This fixes all cartesian <-> orbital elements round-trip conversion tests.
Added 6 test files for Newton-Raphson solver and analytical propagation:
- test_cartesian_to_elements_basic.cpp: Tests state vector ↔ orbital elements conversion
- test_newton_raphson_convergence.cpp: Tests Newton-Raphson solver convergence behavior
- test_analytical_propagation_apsides.cpp: Tests propagation through orbital apsides
- test_analytical_propagation_timesteps.cpp: Tests propagation with various timesteps
- test_extreme_eccentricity.cpp: Tests near-parabolic and hyperbolic orbits
- test_precision_boundaries.cpp: Tests exact boundary value handling
Implemented core orbital mechanics functions:
- solve_kepler_equation(): Newton-Raphson solver with 1e-10 tolerance
- get_initial_trial_value(): Series expansion initial guess
- cartesian_to_orbital_elements(): State vectors to orbital elements conversion
- propagate_orbital_elements(): Analytical propagation using Kepler's equation
Updated test plan document with current progress and remaining tests.
Test status: 66 passed, 14 failed (out of 80 test cases)
- Failing tests are expected: implementation needs debugging
- Config validation issues fixed by adjusting orbital parameters
- Add StabilityResult struct to capture per-body results
- Add print_summary() function that displays formatted test results
- Summary includes:
- Stability criteria explanation
- Per-body results table with stability status
- Overall analysis with recommendations
- Current time step assessment
- Status shows current dt=60s is very stable with good margin
- Can be increased significantly if needed for faster simulation
- Create tests/informational/ for diagnostic/informational tests not in main suite
- Move test_time_step_stability.{cpp,toml} from tests/ to informational/
- Add README.md documenting informational tests purpose and usage
- Add dedicated Makefile for building informational tests separately
- Tests find maximum stable time step for RK4 integration across different orbital regimes
- Limiting factor is Mercury orbiter (12h period): max stable dt = 270s
- Current default 60s is very stable with good margin
- Remove unconditional reset of ui_state.selected_craft_index in render_body_list_ui()
- Only reset ui_state.selected_craft_index to -1 when body is selected
- This prevents panel from disappearing in subsequent frames when spacecraft remains selected