Skip to content

Orbital Math from Live Constants

The useful orbital numbers are already in /sim. Read them from the current parent, once, and leave the old 9.8 habit on the launchpad.

For an orbit with centre-to-vessel radius rr, circular speed is vc=μ/rv_c = \sqrt{\mu/r}. Here, mu is m³/s², radius is metres, and an apoapsis or periapsis is an altitude above the surface.

Terminal window
parent=$(cat /sim/vessels/active/parent)
mu=$(cat "/sim/bodies/$parent/mu")
radius=$(cat "/sim/bodies/$parent/radius")
altitude=120000
awk "BEGIN { r=$radius + $altitude; print sqrt($mu / r) \" m/s\" }"
cat /sim/vessels/active/orbit/apoapsis
cat /sim/vessels/active/orbit/periapsis
cat /sim/vessels/active/orbit/period

The vis-viva equation is v2=μ(2/r1/a)v^2 = \mu(2/r - 1/a). Use metres and seconds throughout. Angles from the orbit files are degrees, so convert before feeding them to sin or cos.

Next: turn a future UT and a CCI Δv into a scheduled burn.