Skip to content

Creating an accurate simulation of the first 4 planets of the solar system, using Kepler's laws, for SSDC competition 2025.

Notifications You must be signed in to change notification settings

AbhyudayaGup/Simulation-for-SSDC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Inner Solar System Simulation For SSDC 2025

A Physically Accurate Orbital Mechanics Simulator with Kepler's Equation Implementation

Live Demo GitHub

Kepler's Laws Real-time Orbital Mechanics Hohmann Transfer


Project Overview

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.


Core Mathematical Algorithms

Kepler's Equation Solver

The simulation implements Kepler's Equation to determine planetary positions:

$$M = E - e \sin(E)$$

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

True Anomaly Calculation

Converting eccentric anomaly to true anomaly (ν):

$$\nu = 2 \arctan\left(\sqrt{\frac{1+e}{1-e}} \tan\frac{E}{2}\right)$$

This yields the actual angular position of the planet in its orbit.

Heliocentric Distance Formula

Calculating orbital radius at any point:

$$r = a(1 - e \cos E)$$

Where:

  • a = Semi-major axis (AU)
  • r = Heliocentric distance at time t

Mean Motion & Orbital Period

Mean angular velocity (n):

$$n = \frac{2\pi}{T}$$

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

Advanced Features

Physically Accurate Elliptical Orbits

  • 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

Hohmann Transfer Simulation

  • 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

Dynamic Visual Systems

  • 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

Temporal Accuracy

  • 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

Interactive Control Interface

  • 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

Sophisticated Implementations

Mathematical Foundations

// 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

Orbital Mechanics Pipeline

  1. Mean Anomaly Propagation: Calculate M = n·t (mod 2π)
  2. Kepler Equation Solver: Iterate E = M + e·sin(E) until convergence
  3. True Anomaly Computation: Convert E → ν using two-argument arctangent
  4. Radius Calculation: Determine r from semi-major axis and eccentric anomaly
  5. Cartesian Conversion: Transform polar (r, ν) to Cartesian (x, y) coordinates
  6. Focal Translation: Offset by c = ae to position Sun at focus
  7. Screen Mapping: Scale AU to pixels and center on canvas

Space Settlement Trajectory Algorithm

// 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()

Astronomical Data Sources

  • JPL Horizons System: Orbital element data
  • IAU Standards: J2000.0 epoch reference frame
  • NASA: Planetary imagery and texture resources

Live Demo

Experience the simulation instantly: ssdc-simualtion.netlify.app

Educational Value

Physics Concepts Demonstrated

  • 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

Mathematical Principles

  • 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

Computer Science Concepts

  • 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

Author

Abhyudaya Gupta - Student & Developer

GitHub Live Demo

About

Creating an accurate simulation of the first 4 planets of the solar system, using Kepler's laws, for SSDC competition 2025.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published