Skip to main content

Overview

orbitalMotion provides pure-Python implementations of two-body orbital mechanics: anomaly conversions, orbital element ↔ state-vector transformations, and a comprehensive set of gravitational constants and planetary radii sourced from JPL SPICE kernels.
from Basilisk.utilities import orbitalMotion

Data classes

ClassicElements

Container for classical (Keplerian) orbital elements.
oe = orbitalMotion.ClassicElements()
oe.a     = 7000e3   # [m]   semi-major axis
oe.e     = 0.001    # [-]   eccentricity
oe.i     = 0.5      # [rad] inclination
oe.Omega = 0.0      # [rad] right ascension of ascending node
oe.omega = 0.0      # [rad] argument of periapsis
oe.f     = 0.0      # [rad] true anomaly
a
float
Semi-major axis.
e
float
Eccentricity.
i
float
Inclination [rad].
Omega
float
Right ascension of the ascending node [rad].
omega
float
Argument of periapsis [rad].
f
float
True anomaly [rad].
rmag
float | None
Orbit radius magnitude (populated by rv2elem).
rPeriap
float | None
Radius at periapsis (populated by rv2elem).
rApoap
float | None
Radius at apoapsis (populated by rv2elem).

EquinoctialElements

Container for equinoctial orbital elements (a, P1, P2, Q1, Q2, l, L).

Anomaly conversion functions

E2f(Ecc, e)
function
Converts eccentric anomaly to true anomaly for elliptic orbits (0 <= e < 1).
f = orbitalMotion.E2f(Ecc, e)  # [rad]
Returns f (true anomaly, rad). Raises ValueError for out-of-range eccentricity.
E2M(Ecc, e)
function
Converts eccentric anomaly to mean elliptic anomaly (0 <= e < 1).
M = orbitalMotion.E2M(Ecc, e)  # [rad]
f2E(f, e)
function
Converts true anomaly to eccentric anomaly for elliptic orbits.
Ecc = orbitalMotion.f2E(f, e)  # [rad]
f2H(f, e)
function
Converts true anomaly to hyperbolic anomaly (e > 1).
H = orbitalMotion.f2H(f, e)  # [rad]
H2f(H, e)
function
Converts hyperbolic anomaly to true anomaly (e > 1).
f = orbitalMotion.H2f(H, e)  # [rad]
H2N(H, e)
function
Converts hyperbolic anomaly to mean hyperbolic anomaly.
N = orbitalMotion.H2N(H, e)  # [rad]
M2E(M, e)
function
Solves Kepler’s equation iteratively: converts mean elliptic anomaly to eccentric anomaly.
Ecc = orbitalMotion.M2E(M, e)  # [rad]
N2H(N, e)
function
Solves the hyperbolic Kepler equation: converts mean hyperbolic anomaly to hyperbolic anomaly.
H = orbitalMotion.N2H(N, e)  # [rad]

Element ↔ state-vector transformations

elem2rv_parab(mu, elements)
function
Converts classical orbital elements to inertial position and velocity vectors. Handles circular, elliptic (2-D and 1-D), parabolic, and hyperbolic orbits.
rVec, vVec = orbitalMotion.elem2rv_parab(mu, oe)
Returns (rVec, vVec) as numpy.ndarray shapes (3,).

Gravitational constants

All values are in km³/s² (from SPICE kernels at naif.jpl.nasa.gov).
ConstantValue (km³/s²)
MU_SUN132712440023.310
MU_EARTH398600.436
MU_MOON4902.799
MU_MARS42828.314
MU_JUPITER126712767.881
MU_SATURN37940626.068
MU_VENUS324858.599
MU_MERCURY22032.080
MU_URANUS5794559.128
MU_NEPTUNE6836534.065
MU_PLUTO983.055

Planetary radii and J2 coefficients

Selected constants (all in km unless noted):
ConstantValue
REQ_EARTH6378.1366 km
J2_EARTH1082.616e-6
OMEGA_EARTH7.292115e-5 rad/s
REQ_MARS3396.19 km
J2_MARS1960.45e-6
AU149597870.693 km
D2Rπ / 180

Usage example

from Basilisk.utilities import orbitalMotion, macros

mu = orbitalMotion.MU_EARTH  # [km^3/s^2]

oe = orbitalMotion.ClassicElements()
oe.a     = orbitalMotion.REQ_EARTH + 400.0   # [km]
oe.e     = 0.0001
oe.i     = 51.6 * macros.D2R                 # [rad]
oe.Omega = 0.0
oe.omega = 0.0
oe.f     = 0.0

rVec, vVec = orbitalMotion.elem2rv_parab(mu, oe)
print("r =", rVec, "[km]")
print("v =", vVec, "[km/s]")

Build docs developers (and LLMs) love