From 42d42209c2173c5e65d90d730e487e403ee4ebd3 Mon Sep 17 00:00:00 2001 From: Gregory Eslinger Date: Wed, 4 Dec 2024 01:05:31 -0500 Subject: [PATCH] Added template method for mean surface event --- src/md/events/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/md/events/mod.rs b/src/md/events/mod.rs index 4d79fe10..545958eb 100644 --- a/src/md/events/mod.rs +++ b/src/md/events/mod.rs @@ -26,6 +26,7 @@ use crate::linalg::DefaultAllocator; use crate::time::{Duration, Unit}; use crate::State; use anise::prelude::{Almanac, Frame}; +use anise::structure::planetocentric::ellipsoid::Ellipsoid; #[cfg(feature = "python")] use pyo3::prelude::*; use std::default::Default; @@ -154,6 +155,12 @@ impl Event { Self::new(StateParameter::Apoapsis, 180.0) } + /// Match the central body's mean equatorial radius. + /// This is useful for detecting when an object might impact the central body. + pub fn mean_surface(body: &Ellipsoid) -> Self { + Self::new(StateParameter::Rmag, body.mean_equatorial_radius_km()) + } + /// Match a specific event in another frame, using the default epoch precision and value. pub fn in_frame(parameter: StateParameter, desired_value: f64, target_frame: Frame) -> Self { warn!("Searching for an event in another frame is slow: you should instead convert the trajectory into that other frame");