A Physically Accurate Orbital Mechanics Simulator with Kepler's Equation Implementation
Inner Solar System Simulation is a celestial mechanics simulator implementing authentic Keplerian orbital dynamics to model the motion of Mercury, Venus, Earth, and Mars. It has been specifically made to model a Space settlement traveling between lunar and martian orbits for the SSDC competetion 2025-26.The system solves Kepler's Equation iteratively using Newton-Raphson methods, accurately rendering elliptical orbits with the Sun positioned at the focal point.
The simulation implements Kepler's Equation to determine planetary positions:
Where:
- M = Mean Anomaly (angle swept at constant angular velocity)
- E = Eccentric Anomaly (angle from ellipse center)
- e = Orbital Eccentricity (0 = circular, <1 = elliptical)
Newton-Raphson Iterative Solution:
E[n+1] = E[n] + (M - E[n] + e·sin(E[n])) / (1 - e·cos(E[n]))
Converges to 10⁻¹⁰ accuracy in ~10 iterations
Converting eccentric anomaly to true anomaly (ν):
This yields the actual angular position of the planet in its orbit.
Calculating orbital radius at any point:
Where:
- a = Semi-major axis (AU)
- r = Heliocentric distance at time t
Mean angular velocity (n):
Where T = orbital period in Earth years
Planetary Data (Take literature values for accurate orbits):
- Mercury: T = 0.2408 years, e = 0.2056
- Venus: T = 0.6152 years, e = 0.0068
- Earth: T = 1.0000 years, e = 0.0167
- Mars: T = 1.8808 years, e = 0.0934
- Focal Point Positioning: Sun placed at one focus of each ellipse (not center)
- Eccentricity Visualization: Observable difference between circular (Venus) and elliptical (Mercury) orbits
- Real Orbital Parameters: Uses JPL Horizons data for semi-major axes and eccentricities
- 80-Day Transfer Windows: Calculates future planetary positions using propagated mean anomaly
- Space Settlement Pathfinding: Simulates Earth↔Mars transport with optimal timing
- Rest Period Dynamics: Configurable surface time (default: 5 days) before return journey
- Trajectory Visualization: Real-time dotted lines showing transfer paths
- Twinkling Starfield: 180+ procedurally animated stars with 4 different shapes (circles, squares, diamonds, crosses)
- Parametric Orbit Colors: User-selectable orbital path colors with glow effects
- Ghost Planet Indicators: 35% opacity future positions showing 80-day ahead predictions
- Canvas Optimization: RequestAnimationFrame for smooth 60 FPS rendering
- Multi-Layered Rendering: Background stars → Sun → Orbits → Planets → UI hierarchy
- J2000.0 Epoch Reference: Calculations referenced to January 1, 2000, 12:00 TT
- Simulation Start Date: May 31, 2081 (81.414 years from J2000)
- Time Conversion: Precise Julian day calculations with leap year accounting
- Variable Speed Control: 1-60 seconds per Earth year simulation rate
- Real-Time Speed Adjustment: Dynamic time-step modification without simulation restart
- Orbital Visibility Toggle: Show/hide individual planet orbits and paths
- Planet Selection: Enable/disable Mercury and Venus for focused viewing
- Color Customization: Live orbital path color modification with hex picker
- Space Settlement Control: Toggle interplanetary transport simulation
// Kepler's Equation (Newton-Raphson iteration)
E = M + e·sin(E)
// True Anomaly from Eccentric Anomaly
ν = 2·arctan(√((1+e)/(1-e))·tan(E/2))
// Heliocentric Position
r = a(1 - e·cos(E))
x = r·cos(ν)
y = r·sin(ν)
// Future Position Prediction (80-day Hohmann transfer)
M_future = M_current + n·Δt
where Δt = 80/365.25 years- Mean Anomaly Propagation: Calculate M = n·t (mod 2π)
- Kepler Equation Solver: Iterate E = M + e·sin(E) until convergence
- True Anomaly Computation: Convert E → ν using two-argument arctangent
- Radius Calculation: Determine r from semi-major axis and eccentric anomaly
- Cartesian Conversion: Transform polar (r, ν) to Cartesian (x, y) coordinates
- Focal Translation: Offset by c = ae to position Sun at focus
- Screen Mapping: Scale AU to pixels and center on canvas
// Phase 1: Traveling (Linear Interpolation)
position(t) = start_pos + (end_pos - start_pos)·progress
where progress = (t - t_departure) / t_transfer
// Phase 2: Resting (Planet Tracking)
position(t) = current_planet_position(t)
// Phase 3: Departure Trigger
if (t ≥ t_rest_end):
new_destination = future_position_of_other_planet
transition_to_traveling_phase()- JPL Horizons System: Orbital element data
- IAU Standards: J2000.0 epoch reference frame
- NASA: Planetary imagery and texture resources
Experience the simulation instantly: ssdc-simualtion.netlify.app
- Kepler's Three Laws: Elliptical orbits, equal areas, harmonic law
- Two-Body Problem: Classical celestial mechanics solution
- Orbital Elements: Semi-major axis, eccentricity, mean motion
- Hohmann Transfers: Minimum-energy interplanetary trajectories
- True vs Mean Anomaly: Angular position representation methods
- Transcendental Equations: Kepler's equation solution via iteration
- Numerical Methods: Newton-Raphson convergence analysis
- Coordinate Transforms: Polar ↔ Cartesian conversions
- Conic Sections: Ellipse parameterization and focal geometry
- Trigonometric Identities: Half-angle formulas for true anomaly
- Real-Time Rendering: Frame-rate management with requestAnimationFrame
- Iterative Algorithms: Convergence and error bounds
- Temporal Integration: Time-step based state propagation
- Spatial Interpolation: Linear blending for smooth motion
- Event-Driven Architecture: UI control event handling
Abhyudaya Gupta - Student & Developer