Explicit Euler Earths

Feb 23 2024
Physics Simulation/Animation (C++)


This simulation embraces the unstable nature of Explicit Euler for gravity simulations. The large yellow circle in the center represents the Sun, and the rest of the particles (initially arranged on a line), represent various Earths. The representation is not just symbolic: the sun in this simulation is also 0.331436 × 10^6 times heavier than the Earths. Each Earth leaves behind a trail of the same color.

The simulation was achieved using a bare-bones animation engine given to us in my Computer Animation class, with me having completed the Explicit Euler implementation. The engine only supported hard-coded simulation properties and objects in XML:

<duration time="5.0"/> <integrator type="explicit-euler" dt="0.005"/> <maxsimfreq max="15.0"/>
 
<particle m="1.0" px="1.34" py="0.0" vx="0.0" vy="6.28316" fixed="0" radius="0.02"/>
<gravitationalforce i="0" j="1" G="0.000118419"/>
<particlecolor i="1" r="1.0" g="0.0" b="0.0"/>
<particlepath i="1" duration="20.0" r="1.0" g="0.0" b="0.0"/>

So I wrote a short program that allowed me to automate the coloring and placements of the Earths such that they were lined up and had colors mapped from red to blue according to how many Earths there were and their relative position.

The simulation time step is set to dt = 0.005, and a maximum simulation time of t = 5. There are 50 Earths in this particular simulation.

Stills from the simulation:







A gif of the simulation: