Solar System Rocket Simulator

Embark on a customizable journey through a pocket-sized solar system! This interactive simulator lets you launch rockets from Earth and watch them navigate the gravitational pulls of the Sun and planets. More than just a launch-and-watch experience, it's a dynamic physics sandbox where you control the fundamental forces governing your rockets' trajectories.

How to Play / Experiment:

Start by setting your desired Launch Position, Launch Angle, and Initial Speed using the sliders in the "Rocket Launch Control" panel. Hit the yellow LIFT OFF button to send your rocket on its way! Watch its colorful trail paint its path across the system. While the rocket is flying, experiment by adjusting the Gravity Settings sliders – notice how changes to the Gravity Amplifier, Sun Mass Factor, and Planet Mass Factor immediately alter the rocket's trajectory in real-time! Use the Time Speed Multiplier to fast-forward through long journeys or slow down for crucial moments near planets. Navigate your view using drag-to-pan (mouse or touch) and the mouse wheel (or Zoom Level slider) to get a closer look or a wider perspective. Toggle the Show Rocket Speed button to see live velocity data next to active rockets. Need to take a break or examine the current state? Hit the Pause button to freeze the simulation; press it again (Resume) to continue. When you want to start fresh or try a completely new setup, just hit the red Refresh button to clear all rockets and reset all controls and gravity parameters to their defaults.

Key Features:

Multi-Rocket Launches: Launch as many rockets as you like! Each gets a unique color and follows its own path.

Customizable Launch Parameters: Precisely set the launch position on Earth, the launch angle (relative to Earth's tangent), and the initial speed of your rocket using intuitive sliders.

Dynamic Gravity Controls: This is where the real fun begins! Adjust sliders to:

Amplify or reduce the overall strength of gravity in the system (Gravity Amplifier).

Modify the effective gravitational pull of the Sun on your rockets (Sun Mass Factor).

Dramatically boost the effective gravitational pull of planets (excluding Earth) on your rockets (Planet Mass Factor).

Time Control: Speed up or slow down the simulation (Time Speed Multiplier) to observe long journeys or fine-tune close encounters.

Elapsed Time Indicator: Tracks the simulated time passed in Earth Years, displayed in the top-right corner.

Pause/Resume Simulation: Freeze the simulation state at any moment using the dedicated button. The button text and appearance will change to indicate the current state (Pause/Resume). Press again to continue the simulation.

Pan & Zoom: Freely explore the solar system by dragging the view (mouse or touch) and zooming in/out using the mouse wheel or the zoom slider. Zoom focuses on the cursor's position for intuitive navigation.

Visual Feedback:

Toggle real-time speed display (km/s) for each active rocket.

Rockets leave persistent trails, even after impacting a celestial body, painting their journey across space.

Collision Detection: Rockets are removed from the simulation (visually disappear, leaving their trail) upon impacting the physical radius of the Sun or planets.

Instant Reset: A dedicated "Refresh" button instantly clears all rockets and resets all sliders and view parameters to their default state, allowing for quick experimentation.

Under the Hood: Physics & Math (Simplified)

This simulator uses core physics principles but applies significant simplifications and user-controlled modifications for gameplay and visual clarity.

Gravitational Force:

Core Concept: The simulation calculates the gravitational force between each celestial body (Sun, planets) and each rocket using a modified form inspired by Newton's Law of Universal Gravitation (F = G * m1 * m2 / r²).

The Twist (Effective Mass): To make planetary interactions visible despite the Sun's overwhelming real mass and the non-realistic scaling, the calculation for the force exerted on the rocket uses an "effective mass" for the celestial bodies, determined by sliders:

Sun's Force on Rocket: Uses Sun_Mass * SUN_EFFECTIVE_MASS_FACTOR. A lower factor reduces the Sun's dominance.

Earth's Force on Rocket: Uses Earth_Mass (its real mass) without any extra boosting factor. This is crucial to allow rockets to actually escape Earth without needing impossibly high initial speeds when planetary gravity is boosted.

Other Planets' Force on Rocket: Uses Planet_Mass * PLANET_EFFECTIVE_MASS_FACTOR. This allows significantly boosting the gravitational influence of other planets (like Jupiter, Mars, etc.) on the rocket's path.

Final Amplification: The calculated force for all bodies is then multiplied by the GRAVITY_AMPLIFIER slider value, scaling the overall intensity of gravity in the simulation.

Note: These "effective mass" adjustments only affect the force on the rockets. The planets themselves follow their own predefined paths and are not influenced by these factors or by the rockets.

Motion Calculation (Integration):

Newton's Second Law: For each rocket, the total gravitational force from all celestial bodies is calculated (as described above). This net force (F) is used to find the rocket's acceleration (a) using a = F / m (where m is the rocket's fixed mass).

Euler Integration: The simulation updates the rocket's velocity and position in discrete time steps (effectiveTimeStep = TIME_STEP * timeMultiplier).

new_velocity = old_velocity + acceleration * effectiveTimeStep

new_position = old_position + new_velocity * effectiveTimeStep

This is a basic numerical integration method, suitable for this type of simulation but less accurate than more complex methods (like Runge-Kutta) for high-precision orbital mechanics.

Planetary Orbits:

The planets follow simplified, perfectly circular orbits around the Sun at a constant orbital speed.

Their positions are updated based on their fixed orbital distance, speed, and the elapsed effectiveTimeStep. They do not interact gravitationally with each other in this simulation.

Rocket Initial Launch:

The rocket starts slightly above Earth's physical surface at the specified launchPosition.

Its initial velocity is the vector sum of:

Earth's own orbital velocity at that point.

The user-defined launch speed, directed according to the launchAngle relative to the local tangent of Earth's surface.

Collision Detection:

Collision is detected when the distance between the center of the rocket and the center of a celestial body becomes less than the body's physicsRadius (its actual physical radius in meters, not the visual representation).

Upon collision, the rocket's isActive flag is set to false. The update function stops processing it, and the draw function stops rendering the rocket itself and its speed label, but continues rendering its existing trail.

Simulation Parameters & Scaling (Assumptions & Details)

Distances: Real average distances (in Astronomical Units, AU) are used as a base but are heavily scaled down by the SCALE factor (influenced by window size and the Zoom slider) to fit the screen. Distances between objects on screen are not proportionally accurate to reality.

Sizes:

radius (used for drawing): These are arbitrary pixel values chosen for visual clarity and are not to scale with real planet sizes, distances, or each other.

physicsRadius: These values (in meters) represent the approximate real physical radii and are used only for collision detection.

Gravity Factors (User Controlled):

GRAVITY_AMPLIFIER (Default: 1.0, Range: 0.1-10.0): Scales all calculated rocket forces.

SUN_EFFECTIVE_MASS_FACTOR (Default: 1.0, Range: 0.1-10.0): Multiplies the Sun's real mass when calculating its force on rockets. Allows tuning the Sun's dominance.

PLANET_EFFECTIVE_MASS_FACTOR (Default: 10000.0, Range: 1-50000): Multiplies the real mass of planets (excluding Earth) when calculating their force on rockets. Allows significantly exaggerating planetary influence for visual effect.

Mass:

Rocket: Fixed at 100 tons (ROCKET_FIXED_MASS_KG). The previous mass slider was removed as its effect was negligible compared to planetary masses and complicated the gravity balancing.

Planets/Sun: Use their real approximate masses (kg) as the base for force calculations (which are then modified by the factors above for rocket interactions).

Time: Uses a base TIME_STEP of 1 hour, multiplied by the timeMultiplier slider (0.5x to 10x) for variable simulation speed.

Realism vs. Simulation - Key Differences:

What's (Relatively) Realistic:

The fundamental concept of gravity decreasing with the square of distance.

The use of real masses as a base for calculations.

Vector addition for initial launch velocity.

Basic numerical integration (Euler) to approximate motion under forces.

What's Intentionally Unrealistic (for Gameplay/Visuals):

Planetary Orbits: Planets are in perfect, non-interacting circular orbits, not ellipses.

Gravity Scaling: The use of SUN_EFFECTIVE_MASS_FACTOR and PLANET_EFFECTIVE_MASS_FACTOR drastically alters the gravitational forces felt by the rockets compared to reality. Earth's force on the rocket is not boosted like other planets. This is a core gameplay mechanic for balancing escape and planetary encounters.

Visual Scaling: Distances and planet sizes are not proportionally accurate. Visual sizes are arbitrary.

N-Body Problem: Planets do not gravitationally affect each other. Rockets do not affect planets. Only bodies affect rockets.

Other Forces: No atmospheric drag, solar radiation pressure, relativity, etc.

No Fuel/Thrust: Rockets have an initial velocity but cannot perform burns or maneuvers after launch.

Instantaneous Force: Gravity is calculated as if it acts instantaneously across distances.

Controls Summary:

Sliders: Adjust Launch Position, Launch Angle, Initial Speed, Zoom, Time Speed, and Gravity Factors.

Buttons: Launch Rocket, Toggle Speed Display, Pause/Resume Simulation, Refresh Simulation.

Mouse/Touch: Drag to pan the view.

Mouse Wheel: Zoom in/out (centered on cursor).

Who Is This for?

This simulator is perfect for students, educators, or anyone curious about basic orbital mechanics and gravitational interactions in a fun, hands-on way. It's a sandbox to experiment with "what if" scenarios by tweaking fundamental physics parameters.

Disclaimer: This is a simplified simulation designed for educational and entertainment purposes. It does not represent a high-fidelity orbital mechanics tool and makes significant abstractions from real-world physics for the sake of interaction and visualization.

Comments

Log in with itch.io to leave a comment.

(+1)

cool project congrats 

thanks. hope you enjoy