The planet's motion is integrated directly from Newton's law of gravitation, not drawn as a fixed ellipse — so eccentric and near-circular orbits both emerge naturally from the same physics. The moon orbits the planet the same way, one level down.
a = -G·M · r̂ / r²
v(t+dt) = v(t) + a·dt
r(t+dt) = r(t) + v(t+dt)·dt
v_circular = sqrt(G·M / r)
- Star mass (G·M) — scales gravitational pull; higher mass means faster, tighter orbits.
- Velocity vs. circular — launches the planet faster or slower than a perfect circular orbit, producing an elliptical path (1.0× = circular).
- Moon distance — sets the moon's orbital radius around the planet; watch its period scale with distance (Kepler's third law).
- Time scale — speeds up or slows down the simulated clock.
Real-world application: this semi-implicit Euler integration is a simplified version of the numerical propagators used by mission designers (e.g. JPL's Horizons/SPICE tools) to plan real spacecraft trajectories and moon flybys.