Skip to content

feat(astro): apsis radii from orbital elements#403

Merged
nochallenge merged 1 commit into
masterfrom
feat/astro-apsis-radii-from-elements
Jun 8, 2026
Merged

feat(astro): apsis radii from orbital elements#403
nochallenge merged 1 commit into
masterfrom
feat/astro-apsis-radii-from-elements

Conversation

@nochallenge

Copy link
Copy Markdown
Owner

What

Adds the apsis-radius pair from orbital elements:

// r_a = a*(1+e)   (m)   farthest distance from the focus
pub fn apoapsis_radius_from_elements(semi_major_axis: f64, eccentricity: f64) -> Result<f64, AstroError>
// r_p = a*(1-e)   (m)   closest distance to the focus
pub fn periapsis_radius_from_elements(semi_major_axis: f64, eccentricity: f64) -> Result<f64, AstroError>

Why

orbit.rs has eccentricity_from_apsides (#372) and semi_major_axis_from_apsides (#378) — the apsides -> (e, a) inverses — but not the forward direction. These two complete the apsides <-> elements bijection: (a, e) -> apsides. Guard mirrors semi_latus_rectum_from_elements (a > 0, 0 <= e < 1).

Test

apsis_radius_from_elements_completes_the_apsides_bijection:

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

Add orbit::apoapsis_radius_from_elements(a, e) = a*(1+e) and
periapsis_radius_from_elements(a, e) = a*(1-e), the farthest and closest
orbital radii (m) from the conic elements. Together they are the forward
(a, e) -> apsides direction, completing the apsides<->elements bijection:
eccentricity_from_apsides (#372) and semi_major_axis_from_apsides (#378)
go apsides -> (e, a); these go (a, e) -> apsides. Guard mirrors
semi_latus_rectum_from_elements (a > 0, 0 <= e < 1).

Analytic test apsis_radius_from_elements_completes_the_apsides_bijection:
(a) worked a=7e6, e=0.1 -> r_a=7.7e6, r_p=6.3e6;
(b) double round-trip threading #372 + #378 (non-tautological): the
    computed apsides recover BOTH e and a;
(c) threads semi_latus_rectum_from_elements (#384): the harmonic mean of
    the apsides is the semi-latus rectum p = a(1-e^2);
(d) ordering r_p <= a <= r_a and r_a + r_p = 2a;
(e) circular: e=0 -> both apsides collapse to a;
(f) Err guards for a<=0, e>=1, non-finite (both fns).

Free fns in orbit.rs (reached via valenx_astro::orbit::), no lib.rs change.
valenx-astro 222 lib tests (was 221), cargo clippy --all-targets
-D warnings clean.
@nochallenge nochallenge merged commit 2c2a4a6 into master Jun 8, 2026
@nochallenge nochallenge deleted the feat/astro-apsis-radii-from-elements branch June 8, 2026 18:42
nochallenge added a commit that referenced this pull request Jun 8, 2026
Add report::mach_from_stagnation_pressure_ratio(p0_over_p, gamma), the
Mach number recovered from a measured total-to-static pressure ratio:

  M = sqrt(2*((p0/p)^((gamma-1)/gamma) - 1)/(gamma - 1))

the inverse of isentropic_stagnation_pressure_ratio -- the SUBSONIC
pitot-static (Rayleigh-pitot) airspeed reduction, the most common
compressible airspeed measurement. Mirrors the #403 temperature-ratio
inverse's sentinel style: returns the at-rest 0.0 (the inverse of the
ratio's 1.0 no-rise identity) for non-physical input (non-finite,
p0/p < 1, or gamma <= 1).

Analytic test mach_from_stagnation_pressure_ratio_inverts_the_ratio:
(a) round-trip threading isentropic_stagnation_pressure_ratio (both
    directions);
(b) worked: at M=1, gamma=1.4 the critical ratio p0/p = 1.2^3.5 -> M=1;
(c) consistency with the temperature-ratio inverse (#403): for the same
    Mach, the pressure-ratio and temperature-ratio reductions agree;
(d) at rest: p0/p = 1 -> M = 0;
(e) 0-sentinel guard for p0/p < 1, gamma <= 1, non-finite.

Free fn in report.rs (not re-exported), no lib.rs change. valenx-aero 213
lib tests (was 212), cargo clippy --all-targets -D warnings clean.
nochallenge added a commit that referenced this pull request Jun 8, 2026
…421)

Add report::mach_from_stagnation_density_ratio(rho0_over_rho, gamma), the
Mach number recovered from a measured total-to-static density ratio:

  M = sqrt(2*((rho0/rho)^(gamma-1) - 1)/(gamma - 1))

the inverse of isentropic_stagnation_density_ratio. With the temperature-
(#403) and pressure-ratio (#409) inverses it completes the stagnation-
ratio inverse trio. Mirrors their sentinel style: returns the at-rest 0.0
(the inverse of the ratio's 1.0 no-compression identity) for non-physical
input (non-finite, rho0/rho < 1, or gamma <= 1).

Analytic test mach_from_stagnation_density_ratio_inverts_the_ratio:
(a) round-trip threading isentropic_stagnation_density_ratio (both
    directions);
(b) worked: at M=1, gamma=1.4 the sonic ratio rho0/rho = 1.2^2.5 -> M=1;
(c) consistency with the temperature- and pressure-ratio inverses: for the
    same Mach all three stagnation-ratio reductions return the same Mach;
(d) at rest: rho0/rho = 1 -> M = 0;
(e) 0-sentinel guard for rho0/rho < 1, gamma <= 1, non-finite.

Free fn in report.rs (not re-exported), no lib.rs change. valenx-aero 214
lib tests (was 213), cargo clippy --all-targets -D warnings clean.
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