Please create a live 3D simulation of a rocket traveling from Earth to Mars, using real orbital dynamics to accurately model its trajectory. Then, visualize the rocket's path with Matplotlib, displaying its position relative to Earth and Mars over time in a clear, concise plot
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Here's a Python solution using poliastro for orbital mechanics and matplotlib for 3D visualization. This simulation models a real Earth-to-Mars transfer orbit using Lambert's method and includes planetary positions:
Models elliptical orbits with correct 3D inclinations
Based on actual 2020 Earth-Mars transfer window
Visualization Components:
3D plot showing orbital planes in different colors
Animated progression of spacecraft and planets
Persistent trajectory trail behind the spacecraft
Properly scaled astronomical units (AU)
Dynamic viewpoint showing orbital inclinations
Technical Details:
207-day transfer trajectory (July 30, 2020 - Feb 18, 2021)
Transfer orbit calculated using impulsive maneuver
Positions sampled at regular time intervals
Smooth animation with 100 frames
To run this code, you'll need to install:
code
pip install astropy poliastro matplotlib numpy
The animation will show:
Blue: Earth's orbit and position
Red: Mars' orbit and position
Green: Transfer trajectory
Black dot: Spacecraft position with trailing path
The viewpoint shows the 3D nature of the transfer - note the slight inclination change between Earth's and Mars' orbital planes. The trajectory follows a minimum-energy path known as a Hohmann transfer orbit.