Skip to content

Commit

Permalink
Added template method for mean surface event
Browse files Browse the repository at this point in the history
  • Loading branch information
gregjesl committed Dec 4, 2024
1 parent 5f964fc commit 42d4220
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/md/events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 42d4220

Please sign in to comment.