From d19d07a0b2d9a73b91ed83bc97668fd8b30659a2 Mon Sep 17 00:00:00 2001 From: Christopher Rabotin Date: Wed, 16 Oct 2024 00:31:28 -0600 Subject: [PATCH] Fix #340 --- anise/src/astro/utils.rs | 2 +- anise/tests/astro/orbit.rs | 24 ++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/anise/src/astro/utils.rs b/anise/src/astro/utils.rs index ba55ad06..46f06f5e 100644 --- a/anise/src/astro/utils.rs +++ b/anise/src/astro/utils.rs @@ -15,7 +15,7 @@ use crate::errors::{MathError, PhysicsError}; use super::PhysicsResult; /// Mean anomaly f64::EPSILON -pub const MA_EPSILON: f64 = 1e-16; +pub const MA_EPSILON: f64 = 1e-12; /// Computes the true anomaly from the given mean anomaly for an orbit. /// diff --git a/anise/tests/astro/orbit.rs b/anise/tests/astro/orbit.rs index bf6af2a9..cc70ca88 100644 --- a/anise/tests/astro/orbit.rs +++ b/anise/tests/astro/orbit.rs @@ -1,12 +1,12 @@ extern crate pretty_env_logger as pel; use anise::astro::orbit::Orbit; -use anise::constants::frames::EARTH_J2000; +use anise::constants::frames::{EARTH_J2000, MOON_J2000}; use anise::constants::usual_planetary_constants::MEAN_EARTH_ANGULAR_VELOCITY_DEG_S; use anise::math::angles::{between_0_360, between_pm_180}; use anise::math::Vector3; use anise::prelude::*; -use anise::time::{Epoch, Unit}; +use anise::time::{Epoch, TimeSeries, Unit}; use rstest::*; @@ -835,3 +835,23 @@ fn b_plane_davis(almanac: Almanac) { // The following is a regression test. assert!(dbg!(orbit.hyperbolic_anomaly_deg().unwrap() - 149.610128737).abs() < 1e-9); } + +#[rstest] +fn gh_regression_340(almanac: Almanac) { + let moon_j2k = almanac.frame_from_uid(MOON_J2000).unwrap(); + + let start = Epoch::from_str("2024-10-16").unwrap(); + + let orbit = Orbit::keplerian( + 6142.400, // sma + 0.6, 57.7, 270.0, 270.0, 0.0, start, moon_j2k, + ); + + for epoch in TimeSeries::inclusive( + start, + Epoch::from_str("2024-10-17").unwrap(), + Unit::Minute * 1, + ) { + assert!(orbit.at_epoch(epoch).is_ok(), "error on {epoch}"); + } +}