Skip to content

feat(astro): specific orbital angular momentum from elements#397

Merged
nochallenge merged 1 commit into
masterfrom
feat/astro-specific-angular-momentum
Jun 8, 2026
Merged

feat(astro): specific orbital angular momentum from elements#397
nochallenge merged 1 commit into
masterfrom
feat/astro-specific-angular-momentum

Conversation

@nochallenge

Copy link
Copy Markdown
Owner

What

Adds orbit::specific_angular_momentum_from_elements(semi_major_axis, eccentricity) — the conserved specific orbital angular momentum:

// h = sqrt(mu * a * (1 - e^2)) = sqrt(mu * p)   (m^2/s)
pub fn specific_angular_momentum_from_elements(semi_major_axis: f64, eccentricity: f64) -> Result<f64, AstroError>

Why

The orbit.rs conic-elements cluster has eccentricity_from_apsides (#372), semi_major_axis_from_apsides (#378), and semi_latus_rectum_from_elements (#384), but not the angular momentum. h = sqrt(mu*a*(1-e^2)) is the conserved angular momentum per unit mass (twice the areal velocity, Kepler's 2nd law). Equivalently sqrt(mu*p) with p the semi-latus rectum; at the apsides h = r*v (r and v are perpendicular there); and for a circle (e=0) it reduces to circular_angular_momentum sqrt(mu*a) (#348). Guard mirrors semi_latus_rectum_from_elements (a > 0, 0 <= e < 1).

Test

specific_angular_momentum_from_elements_is_sqrt_mu_p:

Free fn in orbit.rs (reached via valenx_astro::orbit::), no lib.rs change. valenx-astro 221 lib tests (was 220); cargo clippy -p valenx-astro --all-targets -- -D warnings clean. Research-grade two-body primitive.

Add orbit::specific_angular_momentum_from_elements(semi_major_axis, eccentricity),
the conserved specific orbital angular momentum:

  h = sqrt(mu * a * (1 - e^2)) = sqrt(mu * p)   (m^2/s)

the angular momentum per unit mass of the two-body orbit (twice the areal
velocity, Kepler's second law; mu = MU_EARTH). Equivalently sqrt(mu*p)
with p the semi_latus_rectum_from_elements (#384); at the apsides h = r*v,
and for a circle (e=0) it reduces to circular_angular_momentum sqrt(mu*a)
(#348). Guard mirrors semi_latus_rectum_from_elements (a > 0, 0 <= e < 1).

Analytic test specific_angular_momentum_from_elements_is_sqrt_mu_p:
(a) worked a=7e6, e=0.1 -> h = sqrt(mu*6.93e6);
(b) cross-check threading semi_latus_rectum_from_elements (#384):
    h^2 = mu*p across three (a,e);
(c) circular cross-check threading circular_angular_momentum (#348):
    h(a,0) = sqrt(mu*a);
(d) periapsis cross-check threading orbital_speed: h = r_p*v_p;
(e) Err guards for a<=0, e>=1, non-finite.

Free fn in orbit.rs (reached via valenx_astro::orbit::), no lib.rs change.
valenx-astro 221 lib tests (was 220), cargo clippy --all-targets
-D warnings clean.
@nochallenge nochallenge merged commit be6c97b into master Jun 8, 2026
@nochallenge nochallenge deleted the feat/astro-specific-angular-momentum branch June 8, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant