The spacecraft accelerates under Newton's inverse-square law toward the planet, integrated with a fixed-step semi-implicit (symplectic) Euler scheme so orbits stay closed over long runs instead of slowly spiraling from numerical energy drift:
a = -μ · r̂ / |r|²
μ = G·M (standard gravitational parameter)
Every frame the orbital elements are recomputed directly from the current position and velocity vectors using the vis-viva relation and the eccentricity vector:
ε = v²/2 - μ/r (specific orbital energy)
a = -μ / (2ε) (semi-major axis, if ε<0)
e_vec = ((v² - μ/r)·r - (r·v)·v) / μ
e = |e_vec|
r_p = a(1-e), r_a = a(1+e)
T = 2π√(a³/μ)
- e = 0 — perfect circle. 0 < e < 1 — ellipse (bound orbit).
- e ≥ 1 — parabolic/hyperbolic: the craft escapes and never returns.
- Prograde burn raises the opposite side of the orbit (apoapsis); retrograde lowers it — exactly how real orbit-raising maneuvers work.