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.
Data classes
ClassicElements
Container for classical (Keplerian) orbital elements.Semi-major axis.
Eccentricity.
Inclination [rad].
Right ascension of the ascending node [rad].
Argument of periapsis [rad].
True anomaly [rad].
Orbit radius magnitude (populated by
rv2elem).Radius at periapsis (populated by
rv2elem).Radius at apoapsis (populated by
rv2elem).EquinoctialElements
Container for equinoctial orbital elements (a, P1, P2, Q1, Q2, l, L).
Anomaly conversion functions
Converts eccentric anomaly to true anomaly for elliptic orbits (Returns
0 <= e < 1).f (true anomaly, rad). Raises ValueError for out-of-range eccentricity.Converts eccentric anomaly to mean elliptic anomaly (
0 <= e < 1).Converts true anomaly to eccentric anomaly for elliptic orbits.
Converts true anomaly to hyperbolic anomaly (
e > 1).Converts hyperbolic anomaly to true anomaly (
e > 1).Converts hyperbolic anomaly to mean hyperbolic anomaly.
Solves Kepler’s equation iteratively: converts mean elliptic anomaly to eccentric anomaly.
Solves the hyperbolic Kepler equation: converts mean hyperbolic anomaly to hyperbolic anomaly.
Element ↔ state-vector transformations
Converts classical orbital elements to inertial position and velocity vectors. Handles circular, elliptic (2-D and 1-D), parabolic, and hyperbolic orbits.Returns
(rVec, vVec) as numpy.ndarray shapes (3,).Gravitational constants
All values are in km³/s² (from SPICE kernels at naif.jpl.nasa.gov).| Constant | Value (km³/s²) |
|---|---|
MU_SUN | 132712440023.310 |
MU_EARTH | 398600.436 |
MU_MOON | 4902.799 |
MU_MARS | 42828.314 |
MU_JUPITER | 126712767.881 |
MU_SATURN | 37940626.068 |
MU_VENUS | 324858.599 |
MU_MERCURY | 22032.080 |
MU_URANUS | 5794559.128 |
MU_NEPTUNE | 6836534.065 |
MU_PLUTO | 983.055 |
Planetary radii and J2 coefficients
Selected constants (all in km unless noted):| Constant | Value |
|---|---|
REQ_EARTH | 6378.1366 km |
J2_EARTH | 1082.616e-6 |
OMEGA_EARTH | 7.292115e-5 rad/s |
REQ_MARS | 3396.19 km |
J2_MARS | 1960.45e-6 |
AU | 149597870.693 km |
D2R | π / 180 |