Skip to content

KeplerianElements

Defined in: kepler.rs:207

pub struct KeplerianElements {
pub semi_major_axis: f64,
pub eccentricity: f64,
pub inclination: f64,
pub raan: f64,
pub argument_of_periapsis: f64,
pub true_anomaly: f64,
}

Classical Keplerian orbital elements.

Two of the six angles are undefined when the orbit is circular and/or equatorial. KeplerianElements::from_state_vector resolves this with the classical singular conventions (Vallado, Fundamentals of Astrodynamics and Applications, §2.4), which fold the undefined angle into the next well-defined one so that the state is still fully recoverable by KeplerianElements::to_state_vector:

geometryraanargument_of_periapsistrue_anomaly
generalΩων
circular inclined (e ≈ 0)Ω0argument of latitude u = ω + ν
eccentric equatorial (i ≈ 0 or π)0true longitude of periapsis ϖ = Ω + ων
circular equatorial00true longitude λ = Ω + ω + ν

For the retrograde equatorial cases (i ≈ π) the stored angle is the negated in-plane longitude, because to_state_vector maps i = π, Ω = 0 onto a clockwise sweep of the x-y plane. That keeps the round trip exact for both i ≈ 0 and i ≈ π.

semi_major_axis: f64

Semi-major axis [km]


eccentricity: f64

Eccentricity (dimensionless)


inclination: f64

Inclination [rad]


raan: f64

Right ascension of ascending node (RAAN) [rad]


argument_of_periapsis: f64

Argument of periapsis [rad]


true_anomaly: f64

True anomaly [rad]


fn from_state_vector(pos: &Vector3<f64>, vel: &Vector3<f64>, mu: f64) -> Self

Convert a Cartesian state vector (position, velocity) to Keplerian elements.

Degenerate geometries (circular and/or equatorial) follow the singular conventions documented on KeplerianElements.

  • pos - Position vector [km]
  • vel - Velocity vector [km/s]
  • mu - Gravitational parameter [km^3/s^2]

fn to_state_vector(&self, mu: f64) -> (Vector3<f64>, Vector3<f64>)

Convert Keplerian elements to a Cartesian state vector (position, velocity).

A tuple of (position [km], velocity [km/s])


fn from_mean_anomaly(semi_major_axis: f64, eccentricity: f64, inclination: f64, raan: f64, argument_of_periapsis: f64, mean_anomaly: f64) -> Self

Create Keplerian elements from mean anomaly (converting to true anomaly internally).

This is useful when working with TLE data which provides mean anomaly.


fn period(&self, mu: f64) -> f64

Orbital period [s]: T = 2π√(a³/μ)


fn energy(&self, mu: f64) -> f64

Specific orbital energy [km²/s²]: ε = -μ/(2a)