use super::common::{DBinaryEvent, DValueEvent, SBinaryEvent, SValueEvent};
use super::traits::{
DEventCallback, DEventDetector, EdgeType, EventAction, EventDirection, SEventCallback,
SEventDetector,
};
use crate::access::PolygonLocation;
use crate::constants::AngleFormat;
use crate::coordinates::{point_in_polygon, position_ecef_to_geodetic, state_eci_to_koe};
use crate::frames::position_eci_to_ecef;
use crate::orbit_dynamics::{eclipse_conical, sun_position};
use crate::orbits::{anomaly_mean_to_eccentric, anomaly_mean_to_true};
use crate::propagators::EphemerisSource;
use crate::spice::{SPKKernel, sun_position_de};
use crate::time::Epoch;
use nalgebra::{DVector, SVector, Vector3, Vector6};
use std::sync::Arc;
macro_rules! impl_sevent_detector_delegate {
($struct:ty, $inner:ident, $s:ident, $p:ident) => {
impl<const $s: usize, const $p: usize> SEventDetector<$s, $p> for $struct {
fn evaluate(
&self,
t: Epoch,
state: &SVector<f64, $s>,
params: Option<&SVector<f64, $p>>,
) -> f64 {
self.$inner.evaluate(t, state, params)
}
fn target_value(&self) -> f64 {
self.$inner.target_value()
}
fn name(&self) -> &str {
self.$inner.name()
}
fn direction(&self) -> EventDirection {
self.$inner.direction()
}
fn time_tolerance(&self) -> f64 {
self.$inner.time_tolerance()
}
fn value_tolerance(&self) -> f64 {
self.$inner.value_tolerance()
}
fn step_reduction_factor(&self) -> f64 {
self.$inner.step_reduction_factor()
}
fn callback(&self) -> Option<&SEventCallback<$s, $p>> {
self.$inner.callback()
}
fn action(&self) -> EventAction {
self.$inner.action()
}
}
};
}
macro_rules! impl_devent_detector_delegate {
($struct:ty, $inner:ident) => {
impl DEventDetector for $struct {
fn evaluate(
&self,
t: Epoch,
state: &DVector<f64>,
params: Option<&DVector<f64>>,
) -> f64 {
self.$inner.evaluate(t, state, params)
}
fn target_value(&self) -> f64 {
self.$inner.target_value()
}
fn name(&self) -> &str {
self.$inner.name()
}
fn direction(&self) -> EventDirection {
self.$inner.direction()
}
fn time_tolerance(&self) -> f64 {
self.$inner.time_tolerance()
}
fn value_tolerance(&self) -> f64 {
self.$inner.value_tolerance()
}
fn step_reduction_factor(&self) -> f64 {
self.$inner.step_reduction_factor()
}
fn callback(&self) -> Option<&DEventCallback> {
self.$inner.callback()
}
fn action(&self) -> EventAction {
self.$inner.action()
}
}
};
}
pub struct SAltitudeEvent<const S: usize, const P: usize> {
inner: SValueEvent<S, P>,
}
impl<const S: usize, const P: usize> SAltitudeEvent<S, P> {
pub fn new(value_altitude: f64, name: impl Into<String>, direction: EventDirection) -> Self {
let altitude_fn = |t: Epoch, state: &SVector<f64, S>, _params: Option<&SVector<f64, P>>| {
let r_eci = state.fixed_rows::<3>(0).into_owned();
let r_ecef = position_eci_to_ecef(t, r_eci);
let geodetic = position_ecef_to_geodetic(r_ecef, AngleFormat::Radians);
geodetic[2]
};
Self {
inner: SValueEvent::new(name, altitude_fn, value_altitude, direction),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: SEventCallback<S, P>) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_sevent_detector_delegate!(SAltitudeEvent<S, P>, inner, S, P);
pub struct DAltitudeEvent {
inner: DValueEvent,
}
impl DAltitudeEvent {
pub fn new(value_altitude: f64, name: impl Into<String>, direction: EventDirection) -> Self {
let altitude_fn = |t: Epoch, state: &DVector<f64>, _params: Option<&DVector<f64>>| {
use nalgebra::Vector3;
let r_eci = Vector3::new(state[0], state[1], state[2]);
let r_ecef = position_eci_to_ecef(t, r_eci);
let geodetic = position_ecef_to_geodetic(r_ecef, AngleFormat::Radians);
geodetic[2]
};
Self {
inner: DValueEvent::new(name, altitude_fn, value_altitude, direction),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: DEventCallback) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_devent_detector_delegate!(DAltitudeEvent, inner);
pub struct SSemiMajorAxisEvent<const S: usize, const P: usize> {
inner: SValueEvent<S, P>,
}
impl<const S: usize, const P: usize> SSemiMajorAxisEvent<S, P> {
pub fn new(value: f64, name: impl Into<String>, direction: EventDirection) -> Self {
let value_fn = |_t: Epoch, state: &SVector<f64, S>, _params: Option<&SVector<f64, P>>| {
let state6 = Vector6::new(state[0], state[1], state[2], state[3], state[4], state[5]);
let koe = state_eci_to_koe(state6, AngleFormat::Radians);
koe[0] };
Self {
inner: SValueEvent::new(name, value_fn, value, direction),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: SEventCallback<S, P>) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_sevent_detector_delegate!(SSemiMajorAxisEvent<S, P>, inner, S, P);
pub struct DSemiMajorAxisEvent {
inner: DValueEvent,
}
impl DSemiMajorAxisEvent {
pub fn new(value: f64, name: impl Into<String>, direction: EventDirection) -> Self {
let value_fn = |_t: Epoch, state: &DVector<f64>, _params: Option<&DVector<f64>>| {
let state6 = Vector6::new(state[0], state[1], state[2], state[3], state[4], state[5]);
let koe = state_eci_to_koe(state6, AngleFormat::Radians);
koe[0]
};
Self {
inner: DValueEvent::new(name, value_fn, value, direction),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: DEventCallback) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_devent_detector_delegate!(DSemiMajorAxisEvent, inner);
pub struct SEccentricityEvent<const S: usize, const P: usize> {
inner: SValueEvent<S, P>,
}
impl<const S: usize, const P: usize> SEccentricityEvent<S, P> {
pub fn new(value: f64, name: impl Into<String>, direction: EventDirection) -> Self {
let value_fn = |_t: Epoch, state: &SVector<f64, S>, _params: Option<&SVector<f64, P>>| {
let state6 = Vector6::new(state[0], state[1], state[2], state[3], state[4], state[5]);
let koe = state_eci_to_koe(state6, AngleFormat::Radians);
koe[1] };
Self {
inner: SValueEvent::new(name, value_fn, value, direction),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: SEventCallback<S, P>) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_sevent_detector_delegate!(SEccentricityEvent<S, P>, inner, S, P);
pub struct DEccentricityEvent {
inner: DValueEvent,
}
impl DEccentricityEvent {
pub fn new(value: f64, name: impl Into<String>, direction: EventDirection) -> Self {
let value_fn = |_t: Epoch, state: &DVector<f64>, _params: Option<&DVector<f64>>| {
let state6 = Vector6::new(state[0], state[1], state[2], state[3], state[4], state[5]);
let koe = state_eci_to_koe(state6, AngleFormat::Radians);
koe[1]
};
Self {
inner: DValueEvent::new(name, value_fn, value, direction),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: DEventCallback) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_devent_detector_delegate!(DEccentricityEvent, inner);
pub struct SInclinationEvent<const S: usize, const P: usize> {
inner: SValueEvent<S, P>,
}
impl<const S: usize, const P: usize> SInclinationEvent<S, P> {
pub fn new(
value: f64,
name: impl Into<String>,
direction: EventDirection,
angle_format: AngleFormat,
) -> Self {
let value_rad = match angle_format {
AngleFormat::Degrees => value.to_radians(),
AngleFormat::Radians => value,
};
let value_fn = |_t: Epoch, state: &SVector<f64, S>, _params: Option<&SVector<f64, P>>| {
let state6 = Vector6::new(state[0], state[1], state[2], state[3], state[4], state[5]);
let koe = state_eci_to_koe(state6, AngleFormat::Radians);
koe[2] };
Self {
inner: SValueEvent::new(name, value_fn, value_rad, direction),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: SEventCallback<S, P>) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_sevent_detector_delegate!(SInclinationEvent<S, P>, inner, S, P);
pub struct DInclinationEvent {
inner: DValueEvent,
}
impl DInclinationEvent {
pub fn new(
value: f64,
name: impl Into<String>,
direction: EventDirection,
angle_format: AngleFormat,
) -> Self {
let value_rad = match angle_format {
AngleFormat::Degrees => value.to_radians(),
AngleFormat::Radians => value,
};
let value_fn = |_t: Epoch, state: &DVector<f64>, _params: Option<&DVector<f64>>| {
let state6 = Vector6::new(state[0], state[1], state[2], state[3], state[4], state[5]);
let koe = state_eci_to_koe(state6, AngleFormat::Radians);
koe[2]
};
Self {
inner: DValueEvent::new(name, value_fn, value_rad, direction),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: DEventCallback) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_devent_detector_delegate!(DInclinationEvent, inner);
pub struct SArgumentOfPerigeeEvent<const S: usize, const P: usize> {
inner: SValueEvent<S, P>,
}
impl<const S: usize, const P: usize> SArgumentOfPerigeeEvent<S, P> {
pub fn new(
value: f64,
name: impl Into<String>,
direction: EventDirection,
angle_format: AngleFormat,
) -> Self {
let value_rad = match angle_format {
AngleFormat::Degrees => value.to_radians(),
AngleFormat::Radians => value,
};
let value_fn = |_t: Epoch, state: &SVector<f64, S>, _params: Option<&SVector<f64, P>>| {
let state6 = Vector6::new(state[0], state[1], state[2], state[3], state[4], state[5]);
let koe = state_eci_to_koe(state6, AngleFormat::Radians);
koe[4] };
Self {
inner: SValueEvent::new(name, value_fn, value_rad, direction),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: SEventCallback<S, P>) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_sevent_detector_delegate!(SArgumentOfPerigeeEvent<S, P>, inner, S, P);
pub struct DArgumentOfPerigeeEvent {
inner: DValueEvent,
}
impl DArgumentOfPerigeeEvent {
pub fn new(
value: f64,
name: impl Into<String>,
direction: EventDirection,
angle_format: AngleFormat,
) -> Self {
let value_rad = match angle_format {
AngleFormat::Degrees => value.to_radians(),
AngleFormat::Radians => value,
};
let value_fn = |_t: Epoch, state: &DVector<f64>, _params: Option<&DVector<f64>>| {
let state6 = Vector6::new(state[0], state[1], state[2], state[3], state[4], state[5]);
let koe = state_eci_to_koe(state6, AngleFormat::Radians);
koe[4]
};
Self {
inner: DValueEvent::new(name, value_fn, value_rad, direction),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: DEventCallback) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_devent_detector_delegate!(DArgumentOfPerigeeEvent, inner);
pub struct SMeanAnomalyEvent<const S: usize, const P: usize> {
inner: SValueEvent<S, P>,
}
impl<const S: usize, const P: usize> SMeanAnomalyEvent<S, P> {
pub fn new(
value: f64,
name: impl Into<String>,
direction: EventDirection,
angle_format: AngleFormat,
) -> Self {
let value_rad = match angle_format {
AngleFormat::Degrees => value.to_radians(),
AngleFormat::Radians => value,
};
let value_fn = |_t: Epoch, state: &SVector<f64, S>, _params: Option<&SVector<f64, P>>| {
let state6 = Vector6::new(state[0], state[1], state[2], state[3], state[4], state[5]);
let koe = state_eci_to_koe(state6, AngleFormat::Radians);
koe[5] };
Self {
inner: SValueEvent::new(name, value_fn, value_rad, direction),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: SEventCallback<S, P>) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_sevent_detector_delegate!(SMeanAnomalyEvent<S, P>, inner, S, P);
pub struct DMeanAnomalyEvent {
inner: DValueEvent,
}
impl DMeanAnomalyEvent {
pub fn new(
value: f64,
name: impl Into<String>,
direction: EventDirection,
angle_format: AngleFormat,
) -> Self {
let value_rad = match angle_format {
AngleFormat::Degrees => value.to_radians(),
AngleFormat::Radians => value,
};
let value_fn = |_t: Epoch, state: &DVector<f64>, _params: Option<&DVector<f64>>| {
let state6 = Vector6::new(state[0], state[1], state[2], state[3], state[4], state[5]);
let koe = state_eci_to_koe(state6, AngleFormat::Radians);
koe[5]
};
Self {
inner: DValueEvent::new(name, value_fn, value_rad, direction),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: DEventCallback) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_devent_detector_delegate!(DMeanAnomalyEvent, inner);
pub struct SEccentricAnomalyEvent<const S: usize, const P: usize> {
inner: SValueEvent<S, P>,
}
impl<const S: usize, const P: usize> SEccentricAnomalyEvent<S, P> {
pub fn new(
value: f64,
name: impl Into<String>,
direction: EventDirection,
angle_format: AngleFormat,
) -> Self {
let value_rad = match angle_format {
AngleFormat::Degrees => value.to_radians(),
AngleFormat::Radians => value,
};
let value_fn = |_t: Epoch, state: &SVector<f64, S>, _params: Option<&SVector<f64, P>>| {
let state6 = Vector6::new(state[0], state[1], state[2], state[3], state[4], state[5]);
let koe = state_eci_to_koe(state6, AngleFormat::Radians);
let e = koe[1];
let m = koe[5];
anomaly_mean_to_eccentric(m, e, AngleFormat::Radians).unwrap_or(m)
};
Self {
inner: SValueEvent::new(name, value_fn, value_rad, direction),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: SEventCallback<S, P>) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_sevent_detector_delegate!(SEccentricAnomalyEvent<S, P>, inner, S, P);
pub struct DEccentricAnomalyEvent {
inner: DValueEvent,
}
impl DEccentricAnomalyEvent {
pub fn new(
value: f64,
name: impl Into<String>,
direction: EventDirection,
angle_format: AngleFormat,
) -> Self {
let value_rad = match angle_format {
AngleFormat::Degrees => value.to_radians(),
AngleFormat::Radians => value,
};
let value_fn = |_t: Epoch, state: &DVector<f64>, _params: Option<&DVector<f64>>| {
let state6 = Vector6::new(state[0], state[1], state[2], state[3], state[4], state[5]);
let koe = state_eci_to_koe(state6, AngleFormat::Radians);
let e = koe[1];
let m = koe[5];
anomaly_mean_to_eccentric(m, e, AngleFormat::Radians).unwrap_or(m)
};
Self {
inner: DValueEvent::new(name, value_fn, value_rad, direction),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: DEventCallback) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_devent_detector_delegate!(DEccentricAnomalyEvent, inner);
pub struct STrueAnomalyEvent<const S: usize, const P: usize> {
inner: SValueEvent<S, P>,
}
impl<const S: usize, const P: usize> STrueAnomalyEvent<S, P> {
pub fn new(
value: f64,
name: impl Into<String>,
direction: EventDirection,
angle_format: AngleFormat,
) -> Self {
let value_rad = match angle_format {
AngleFormat::Degrees => value.to_radians(),
AngleFormat::Radians => value,
};
let value_fn = |_t: Epoch, state: &SVector<f64, S>, _params: Option<&SVector<f64, P>>| {
let state6 = Vector6::new(state[0], state[1], state[2], state[3], state[4], state[5]);
let koe = state_eci_to_koe(state6, AngleFormat::Radians);
let e = koe[1];
let m = koe[5];
anomaly_mean_to_true(m, e, AngleFormat::Radians).unwrap_or(m)
};
Self {
inner: SValueEvent::new(name, value_fn, value_rad, direction),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: SEventCallback<S, P>) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_sevent_detector_delegate!(STrueAnomalyEvent<S, P>, inner, S, P);
pub struct DTrueAnomalyEvent {
inner: DValueEvent,
}
impl DTrueAnomalyEvent {
pub fn new(
value: f64,
name: impl Into<String>,
direction: EventDirection,
angle_format: AngleFormat,
) -> Self {
let value_rad = match angle_format {
AngleFormat::Degrees => value.to_radians(),
AngleFormat::Radians => value,
};
let value_fn = |_t: Epoch, state: &DVector<f64>, _params: Option<&DVector<f64>>| {
let state6 = Vector6::new(state[0], state[1], state[2], state[3], state[4], state[5]);
let koe = state_eci_to_koe(state6, AngleFormat::Radians);
let e = koe[1];
let m = koe[5];
anomaly_mean_to_true(m, e, AngleFormat::Radians).unwrap_or(m)
};
Self {
inner: DValueEvent::new(name, value_fn, value_rad, direction),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: DEventCallback) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_devent_detector_delegate!(DTrueAnomalyEvent, inner);
pub struct SArgumentOfLatitudeEvent<const S: usize, const P: usize> {
inner: SValueEvent<S, P>,
}
impl<const S: usize, const P: usize> SArgumentOfLatitudeEvent<S, P> {
pub fn new(
value: f64,
name: impl Into<String>,
direction: EventDirection,
angle_format: AngleFormat,
) -> Self {
let value_rad = match angle_format {
AngleFormat::Degrees => value.to_radians(),
AngleFormat::Radians => value,
};
let value_fn = |_t: Epoch, state: &SVector<f64, S>, _params: Option<&SVector<f64, P>>| {
let state6 = Vector6::new(state[0], state[1], state[2], state[3], state[4], state[5]);
let koe = state_eci_to_koe(state6, AngleFormat::Radians);
let e = koe[1];
let omega = koe[4]; let m = koe[5];
let nu = anomaly_mean_to_true(m, e, AngleFormat::Radians).unwrap_or(m);
let u = omega + nu;
u.rem_euclid(2.0 * std::f64::consts::PI)
};
Self {
inner: SValueEvent::new(name, value_fn, value_rad, direction),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: SEventCallback<S, P>) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_sevent_detector_delegate!(SArgumentOfLatitudeEvent<S, P>, inner, S, P);
pub struct DArgumentOfLatitudeEvent {
inner: DValueEvent,
}
impl DArgumentOfLatitudeEvent {
pub fn new(
value: f64,
name: impl Into<String>,
direction: EventDirection,
angle_format: AngleFormat,
) -> Self {
let value_rad = match angle_format {
AngleFormat::Degrees => value.to_radians(),
AngleFormat::Radians => value,
};
let value_fn = |_t: Epoch, state: &DVector<f64>, _params: Option<&DVector<f64>>| {
let state6 = Vector6::new(state[0], state[1], state[2], state[3], state[4], state[5]);
let koe = state_eci_to_koe(state6, AngleFormat::Radians);
let e = koe[1];
let omega = koe[4];
let m = koe[5];
let nu = anomaly_mean_to_true(m, e, AngleFormat::Radians).unwrap_or(m);
let u = omega + nu;
u.rem_euclid(2.0 * std::f64::consts::PI)
};
Self {
inner: DValueEvent::new(name, value_fn, value_rad, direction),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: DEventCallback) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_devent_detector_delegate!(DArgumentOfLatitudeEvent, inner);
pub struct SAscendingNodeEvent<const S: usize, const P: usize> {
inner: SValueEvent<S, P>,
}
impl<const S: usize, const P: usize> SAscendingNodeEvent<S, P> {
pub fn new(name: impl Into<String>) -> Self {
let value_fn = |_t: Epoch, state: &SVector<f64, S>, _params: Option<&SVector<f64, P>>| {
let state6 = Vector6::new(state[0], state[1], state[2], state[3], state[4], state[5]);
let koe = state_eci_to_koe(state6, AngleFormat::Radians);
let e = koe[1];
let omega = koe[4]; let m = koe[5];
let nu = anomaly_mean_to_true(m, e, AngleFormat::Radians).unwrap_or(m);
let u = omega + nu;
(u + std::f64::consts::PI).rem_euclid(2.0 * std::f64::consts::PI) - std::f64::consts::PI
};
Self {
inner: SValueEvent::new(name, value_fn, 0.0, EventDirection::Increasing),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: SEventCallback<S, P>) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_sevent_detector_delegate!(SAscendingNodeEvent<S, P>, inner, S, P);
pub struct DAscendingNodeEvent {
inner: DValueEvent,
}
impl DAscendingNodeEvent {
pub fn new(name: impl Into<String>) -> Self {
let value_fn = |_t: Epoch, state: &DVector<f64>, _params: Option<&DVector<f64>>| {
let state6 = Vector6::new(state[0], state[1], state[2], state[3], state[4], state[5]);
let koe = state_eci_to_koe(state6, AngleFormat::Radians);
let e = koe[1];
let omega = koe[4];
let m = koe[5];
let nu = anomaly_mean_to_true(m, e, AngleFormat::Radians).unwrap_or(m);
let u = omega + nu;
(u + std::f64::consts::PI).rem_euclid(2.0 * std::f64::consts::PI) - std::f64::consts::PI
};
Self {
inner: DValueEvent::new(name, value_fn, 0.0, EventDirection::Increasing),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: DEventCallback) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_devent_detector_delegate!(DAscendingNodeEvent, inner);
pub struct SDescendingNodeEvent<const S: usize, const P: usize> {
inner: SValueEvent<S, P>,
}
impl<const S: usize, const P: usize> SDescendingNodeEvent<S, P> {
pub fn new(name: impl Into<String>) -> Self {
let value_fn = |_t: Epoch, state: &SVector<f64, S>, _params: Option<&SVector<f64, P>>| {
let state6 = Vector6::new(state[0], state[1], state[2], state[3], state[4], state[5]);
let koe = state_eci_to_koe(state6, AngleFormat::Radians);
let e = koe[1];
let omega = koe[4]; let m = koe[5];
let nu = anomaly_mean_to_true(m, e, AngleFormat::Radians).unwrap_or(m);
let u = omega + nu;
let u_shifted = u - std::f64::consts::PI;
(u_shifted + std::f64::consts::PI).rem_euclid(2.0 * std::f64::consts::PI)
- std::f64::consts::PI
};
Self {
inner: SValueEvent::new(name, value_fn, 0.0, EventDirection::Increasing),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: SEventCallback<S, P>) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_sevent_detector_delegate!(SDescendingNodeEvent<S, P>, inner, S, P);
pub struct DDescendingNodeEvent {
inner: DValueEvent,
}
impl DDescendingNodeEvent {
pub fn new(name: impl Into<String>) -> Self {
let value_fn = |_t: Epoch, state: &DVector<f64>, _params: Option<&DVector<f64>>| {
let state6 = Vector6::new(state[0], state[1], state[2], state[3], state[4], state[5]);
let koe = state_eci_to_koe(state6, AngleFormat::Radians);
let e = koe[1];
let omega = koe[4];
let m = koe[5];
let nu = anomaly_mean_to_true(m, e, AngleFormat::Radians).unwrap_or(m);
let u = omega + nu;
let u_shifted = u - std::f64::consts::PI;
(u_shifted + std::f64::consts::PI).rem_euclid(2.0 * std::f64::consts::PI)
- std::f64::consts::PI
};
Self {
inner: DValueEvent::new(name, value_fn, 0.0, EventDirection::Increasing),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: DEventCallback) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_devent_detector_delegate!(DDescendingNodeEvent, inner);
pub struct SSpeedEvent<const S: usize, const P: usize> {
inner: SValueEvent<S, P>,
}
impl<const S: usize, const P: usize> SSpeedEvent<S, P> {
pub fn new(value: f64, name: impl Into<String>, direction: EventDirection) -> Self {
let value_fn = |_t: Epoch, state: &SVector<f64, S>, _params: Option<&SVector<f64, P>>| {
let v = Vector3::new(state[3], state[4], state[5]);
v.norm()
};
Self {
inner: SValueEvent::new(name, value_fn, value, direction),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: SEventCallback<S, P>) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_sevent_detector_delegate!(SSpeedEvent<S, P>, inner, S, P);
pub struct DSpeedEvent {
inner: DValueEvent,
}
impl DSpeedEvent {
pub fn new(value: f64, name: impl Into<String>, direction: EventDirection) -> Self {
let value_fn = |_t: Epoch, state: &DVector<f64>, _params: Option<&DVector<f64>>| {
let v = Vector3::new(state[3], state[4], state[5]);
v.norm()
};
Self {
inner: DValueEvent::new(name, value_fn, value, direction),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: DEventCallback) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_devent_detector_delegate!(DSpeedEvent, inner);
pub struct SLongitudeEvent<const S: usize, const P: usize> {
inner: SValueEvent<S, P>,
}
impl<const S: usize, const P: usize> SLongitudeEvent<S, P> {
pub fn new(
value: f64,
name: impl Into<String>,
direction: EventDirection,
angle_format: AngleFormat,
) -> Self {
let value_rad = match angle_format {
AngleFormat::Degrees => value.to_radians(),
AngleFormat::Radians => value,
};
let value_fn = |t: Epoch, state: &SVector<f64, S>, _params: Option<&SVector<f64, P>>| {
let r_eci = state.fixed_rows::<3>(0).into_owned();
let r_ecef = position_eci_to_ecef(t, r_eci);
let geodetic = position_ecef_to_geodetic(r_ecef, AngleFormat::Radians);
geodetic[0] };
Self {
inner: SValueEvent::new(name, value_fn, value_rad, direction),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: SEventCallback<S, P>) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_sevent_detector_delegate!(SLongitudeEvent<S, P>, inner, S, P);
pub struct DLongitudeEvent {
inner: DValueEvent,
}
impl DLongitudeEvent {
pub fn new(
value: f64,
name: impl Into<String>,
direction: EventDirection,
angle_format: AngleFormat,
) -> Self {
let value_rad = match angle_format {
AngleFormat::Degrees => value.to_radians(),
AngleFormat::Radians => value,
};
let value_fn = |t: Epoch, state: &DVector<f64>, _params: Option<&DVector<f64>>| {
let r_eci = Vector3::new(state[0], state[1], state[2]);
let r_ecef = position_eci_to_ecef(t, r_eci);
let geodetic = position_ecef_to_geodetic(r_ecef, AngleFormat::Radians);
geodetic[0]
};
Self {
inner: DValueEvent::new(name, value_fn, value_rad, direction),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: DEventCallback) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_devent_detector_delegate!(DLongitudeEvent, inner);
pub struct SLatitudeEvent<const S: usize, const P: usize> {
inner: SValueEvent<S, P>,
}
impl<const S: usize, const P: usize> SLatitudeEvent<S, P> {
pub fn new(
value: f64,
name: impl Into<String>,
direction: EventDirection,
angle_format: AngleFormat,
) -> Self {
let value_rad = match angle_format {
AngleFormat::Degrees => value.to_radians(),
AngleFormat::Radians => value,
};
let value_fn = |t: Epoch, state: &SVector<f64, S>, _params: Option<&SVector<f64, P>>| {
let r_eci = state.fixed_rows::<3>(0).into_owned();
let r_ecef = position_eci_to_ecef(t, r_eci);
let geodetic = position_ecef_to_geodetic(r_ecef, AngleFormat::Radians);
geodetic[1] };
Self {
inner: SValueEvent::new(name, value_fn, value_rad, direction),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: SEventCallback<S, P>) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_sevent_detector_delegate!(SLatitudeEvent<S, P>, inner, S, P);
pub struct DLatitudeEvent {
inner: DValueEvent,
}
impl DLatitudeEvent {
pub fn new(
value: f64,
name: impl Into<String>,
direction: EventDirection,
angle_format: AngleFormat,
) -> Self {
let value_rad = match angle_format {
AngleFormat::Degrees => value.to_radians(),
AngleFormat::Radians => value,
};
let value_fn = |t: Epoch, state: &DVector<f64>, _params: Option<&DVector<f64>>| {
let r_eci = Vector3::new(state[0], state[1], state[2]);
let r_ecef = position_eci_to_ecef(t, r_eci);
let geodetic = position_ecef_to_geodetic(r_ecef, AngleFormat::Radians);
geodetic[1]
};
Self {
inner: DValueEvent::new(name, value_fn, value_rad, direction),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: DEventCallback) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_devent_detector_delegate!(DLatitudeEvent, inner);
fn get_sun_position(t: Epoch, source: Option<EphemerisSource>) -> Vector3<f64> {
match source {
None | Some(EphemerisSource::LowPrecision) => sun_position(t),
Some(source) => {
let kernel =
SPKKernel::try_from(source).expect("DE ephemeris source should map to a DE kernel");
sun_position_de(t, kernel).unwrap_or_else(|_| sun_position(t))
}
}
}
pub struct SUmbraEvent<const S: usize, const P: usize> {
inner: SBinaryEvent<S, P>,
}
impl<const S: usize, const P: usize> SUmbraEvent<S, P> {
pub fn new(
name: impl Into<String>,
edge: EdgeType,
ephemeris_source: Option<EphemerisSource>,
) -> Self {
let condition_fn =
move |t: Epoch, state: &SVector<f64, S>, _params: Option<&SVector<f64, P>>| {
let r_eci = Vector3::new(state[0], state[1], state[2]);
let r_sun = get_sun_position(t, ephemeris_source);
let illumination = eclipse_conical(r_eci, r_sun);
illumination == 0.0
};
Self {
inner: SBinaryEvent::new(name, condition_fn, edge),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: SEventCallback<S, P>) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_sevent_detector_delegate!(SUmbraEvent<S, P>, inner, S, P);
pub struct DUmbraEvent {
inner: DBinaryEvent,
}
impl DUmbraEvent {
pub fn new(
name: impl Into<String>,
edge: EdgeType,
ephemeris_source: Option<EphemerisSource>,
) -> Self {
let condition_fn = move |t: Epoch, state: &DVector<f64>, _params: Option<&DVector<f64>>| {
let r_eci = Vector3::new(state[0], state[1], state[2]);
let r_sun = get_sun_position(t, ephemeris_source);
let illumination = eclipse_conical(r_eci, r_sun);
illumination == 0.0
};
Self {
inner: DBinaryEvent::new(name, condition_fn, edge),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: DEventCallback) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_devent_detector_delegate!(DUmbraEvent, inner);
pub struct SPenumbraEvent<const S: usize, const P: usize> {
inner: SBinaryEvent<S, P>,
}
impl<const S: usize, const P: usize> SPenumbraEvent<S, P> {
pub fn new(
name: impl Into<String>,
edge: EdgeType,
ephemeris_source: Option<EphemerisSource>,
) -> Self {
let condition_fn =
move |t: Epoch, state: &SVector<f64, S>, _params: Option<&SVector<f64, P>>| {
let r_eci = Vector3::new(state[0], state[1], state[2]);
let r_sun = get_sun_position(t, ephemeris_source);
let illumination = eclipse_conical(r_eci, r_sun);
illumination > 0.0 && illumination < 1.0
};
Self {
inner: SBinaryEvent::new(name, condition_fn, edge),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: SEventCallback<S, P>) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_sevent_detector_delegate!(SPenumbraEvent<S, P>, inner, S, P);
pub struct DPenumbraEvent {
inner: DBinaryEvent,
}
impl DPenumbraEvent {
pub fn new(
name: impl Into<String>,
edge: EdgeType,
ephemeris_source: Option<EphemerisSource>,
) -> Self {
let condition_fn = move |t: Epoch, state: &DVector<f64>, _params: Option<&DVector<f64>>| {
let r_eci = Vector3::new(state[0], state[1], state[2]);
let r_sun = get_sun_position(t, ephemeris_source);
let illumination = eclipse_conical(r_eci, r_sun);
illumination > 0.0 && illumination < 1.0
};
Self {
inner: DBinaryEvent::new(name, condition_fn, edge),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: DEventCallback) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_devent_detector_delegate!(DPenumbraEvent, inner);
pub struct SEclipseEvent<const S: usize, const P: usize> {
inner: SBinaryEvent<S, P>,
}
impl<const S: usize, const P: usize> SEclipseEvent<S, P> {
pub fn new(
name: impl Into<String>,
edge: EdgeType,
ephemeris_source: Option<EphemerisSource>,
) -> Self {
let condition_fn =
move |t: Epoch, state: &SVector<f64, S>, _params: Option<&SVector<f64, P>>| {
let r_eci = Vector3::new(state[0], state[1], state[2]);
let r_sun = get_sun_position(t, ephemeris_source);
let illumination = eclipse_conical(r_eci, r_sun);
illumination < 1.0
};
Self {
inner: SBinaryEvent::new(name, condition_fn, edge),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: SEventCallback<S, P>) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_sevent_detector_delegate!(SEclipseEvent<S, P>, inner, S, P);
pub struct DEclipseEvent {
inner: DBinaryEvent,
}
impl DEclipseEvent {
pub fn new(
name: impl Into<String>,
edge: EdgeType,
ephemeris_source: Option<EphemerisSource>,
) -> Self {
let condition_fn = move |t: Epoch, state: &DVector<f64>, _params: Option<&DVector<f64>>| {
let r_eci = Vector3::new(state[0], state[1], state[2]);
let r_sun = get_sun_position(t, ephemeris_source);
let illumination = eclipse_conical(r_eci, r_sun);
illumination < 1.0
};
Self {
inner: DBinaryEvent::new(name, condition_fn, edge),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: DEventCallback) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_devent_detector_delegate!(DEclipseEvent, inner);
pub struct SSunlitEvent<const S: usize, const P: usize> {
inner: SBinaryEvent<S, P>,
}
impl<const S: usize, const P: usize> SSunlitEvent<S, P> {
pub fn new(
name: impl Into<String>,
edge: EdgeType,
ephemeris_source: Option<EphemerisSource>,
) -> Self {
let condition_fn =
move |t: Epoch, state: &SVector<f64, S>, _params: Option<&SVector<f64, P>>| {
let r_eci = Vector3::new(state[0], state[1], state[2]);
let r_sun = get_sun_position(t, ephemeris_source);
let illumination = eclipse_conical(r_eci, r_sun);
illumination == 1.0
};
Self {
inner: SBinaryEvent::new(name, condition_fn, edge),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: SEventCallback<S, P>) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_sevent_detector_delegate!(SSunlitEvent<S, P>, inner, S, P);
pub struct DSunlitEvent {
inner: DBinaryEvent,
}
impl DSunlitEvent {
pub fn new(
name: impl Into<String>,
edge: EdgeType,
ephemeris_source: Option<EphemerisSource>,
) -> Self {
let condition_fn = move |t: Epoch, state: &DVector<f64>, _params: Option<&DVector<f64>>| {
let r_eci = Vector3::new(state[0], state[1], state[2]);
let r_sun = get_sun_position(t, ephemeris_source);
let illumination = eclipse_conical(r_eci, r_sun);
illumination == 1.0
};
Self {
inner: DBinaryEvent::new(name, condition_fn, edge),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: DEventCallback) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_devent_detector_delegate!(DSunlitEvent, inner);
fn prepare_aoi_vertices(
vertices: &[(f64, f64)],
angle_format: AngleFormat,
) -> Arc<Vec<(f64, f64)>> {
let radians_vertices: Vec<(f64, f64)> = match angle_format {
AngleFormat::Degrees => vertices
.iter()
.map(|(lon, lat)| (lon.to_radians(), lat.to_radians()))
.collect(),
AngleFormat::Radians => vertices.to_vec(),
};
Arc::new(radians_vertices)
}
fn polygon_location_to_vertices(polygon: &PolygonLocation) -> Vec<(f64, f64)> {
polygon
.vertices()
.iter()
.map(|v| {
(v.x.to_radians(), v.y.to_radians())
})
.collect()
}
pub struct SAOIEntryEvent<const S: usize, const P: usize> {
inner: SBinaryEvent<S, P>,
}
impl<const S: usize, const P: usize> SAOIEntryEvent<S, P> {
pub fn from_polygon(polygon: &PolygonLocation, name: impl Into<String>) -> Self {
let vertices = polygon_location_to_vertices(polygon);
let vertices_arc = Arc::new(vertices);
let condition_fn =
move |t: Epoch, state: &SVector<f64, S>, _params: Option<&SVector<f64, P>>| {
let r_eci = Vector3::new(state[0], state[1], state[2]);
let r_ecef = position_eci_to_ecef(t, r_eci);
let geodetic = position_ecef_to_geodetic(r_ecef, AngleFormat::Radians);
let lon = geodetic[0];
let lat = geodetic[1];
point_in_polygon(lon, lat, &vertices_arc)
};
Self {
inner: SBinaryEvent::new(name, condition_fn, EdgeType::RisingEdge),
}
}
pub fn from_coordinates(
vertices: &[(f64, f64)],
name: impl Into<String>,
angle_format: AngleFormat,
) -> Self {
let vertices_arc = prepare_aoi_vertices(vertices, angle_format);
let condition_fn =
move |t: Epoch, state: &SVector<f64, S>, _params: Option<&SVector<f64, P>>| {
let r_eci = Vector3::new(state[0], state[1], state[2]);
let r_ecef = position_eci_to_ecef(t, r_eci);
let geodetic = position_ecef_to_geodetic(r_ecef, AngleFormat::Radians);
let lon = geodetic[0];
let lat = geodetic[1];
point_in_polygon(lon, lat, &vertices_arc)
};
Self {
inner: SBinaryEvent::new(name, condition_fn, EdgeType::RisingEdge),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: SEventCallback<S, P>) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_sevent_detector_delegate!(SAOIEntryEvent<S, P>, inner, S, P);
pub struct DAOIEntryEvent {
inner: DBinaryEvent,
}
impl DAOIEntryEvent {
pub fn from_polygon(polygon: &PolygonLocation, name: impl Into<String>) -> Self {
let vertices = polygon_location_to_vertices(polygon);
let vertices_arc = Arc::new(vertices);
let condition_fn = move |t: Epoch, state: &DVector<f64>, _params: Option<&DVector<f64>>| {
let r_eci = Vector3::new(state[0], state[1], state[2]);
let r_ecef = position_eci_to_ecef(t, r_eci);
let geodetic = position_ecef_to_geodetic(r_ecef, AngleFormat::Radians);
let lon = geodetic[0];
let lat = geodetic[1];
point_in_polygon(lon, lat, &vertices_arc)
};
Self {
inner: DBinaryEvent::new(name, condition_fn, EdgeType::RisingEdge),
}
}
pub fn from_coordinates(
vertices: &[(f64, f64)],
name: impl Into<String>,
angle_format: AngleFormat,
) -> Self {
let vertices_arc = prepare_aoi_vertices(vertices, angle_format);
let condition_fn = move |t: Epoch, state: &DVector<f64>, _params: Option<&DVector<f64>>| {
let r_eci = Vector3::new(state[0], state[1], state[2]);
let r_ecef = position_eci_to_ecef(t, r_eci);
let geodetic = position_ecef_to_geodetic(r_ecef, AngleFormat::Radians);
let lon = geodetic[0];
let lat = geodetic[1];
point_in_polygon(lon, lat, &vertices_arc)
};
Self {
inner: DBinaryEvent::new(name, condition_fn, EdgeType::RisingEdge),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: DEventCallback) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_devent_detector_delegate!(DAOIEntryEvent, inner);
pub struct SAOIExitEvent<const S: usize, const P: usize> {
inner: SBinaryEvent<S, P>,
}
impl<const S: usize, const P: usize> SAOIExitEvent<S, P> {
pub fn from_polygon(polygon: &PolygonLocation, name: impl Into<String>) -> Self {
let vertices = polygon_location_to_vertices(polygon);
let vertices_arc = Arc::new(vertices);
let condition_fn =
move |t: Epoch, state: &SVector<f64, S>, _params: Option<&SVector<f64, P>>| {
let r_eci = Vector3::new(state[0], state[1], state[2]);
let r_ecef = position_eci_to_ecef(t, r_eci);
let geodetic = position_ecef_to_geodetic(r_ecef, AngleFormat::Radians);
let lon = geodetic[0];
let lat = geodetic[1];
point_in_polygon(lon, lat, &vertices_arc)
};
Self {
inner: SBinaryEvent::new(name, condition_fn, EdgeType::FallingEdge),
}
}
pub fn from_coordinates(
vertices: &[(f64, f64)],
name: impl Into<String>,
angle_format: AngleFormat,
) -> Self {
let vertices_arc = prepare_aoi_vertices(vertices, angle_format);
let condition_fn =
move |t: Epoch, state: &SVector<f64, S>, _params: Option<&SVector<f64, P>>| {
let r_eci = Vector3::new(state[0], state[1], state[2]);
let r_ecef = position_eci_to_ecef(t, r_eci);
let geodetic = position_ecef_to_geodetic(r_ecef, AngleFormat::Radians);
let lon = geodetic[0];
let lat = geodetic[1];
point_in_polygon(lon, lat, &vertices_arc)
};
Self {
inner: SBinaryEvent::new(name, condition_fn, EdgeType::FallingEdge),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: SEventCallback<S, P>) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_sevent_detector_delegate!(SAOIExitEvent<S, P>, inner, S, P);
pub struct DAOIExitEvent {
inner: DBinaryEvent,
}
impl DAOIExitEvent {
pub fn from_polygon(polygon: &PolygonLocation, name: impl Into<String>) -> Self {
let vertices = polygon_location_to_vertices(polygon);
let vertices_arc = Arc::new(vertices);
let condition_fn = move |t: Epoch, state: &DVector<f64>, _params: Option<&DVector<f64>>| {
let r_eci = Vector3::new(state[0], state[1], state[2]);
let r_ecef = position_eci_to_ecef(t, r_eci);
let geodetic = position_ecef_to_geodetic(r_ecef, AngleFormat::Radians);
let lon = geodetic[0];
let lat = geodetic[1];
point_in_polygon(lon, lat, &vertices_arc)
};
Self {
inner: DBinaryEvent::new(name, condition_fn, EdgeType::FallingEdge),
}
}
pub fn from_coordinates(
vertices: &[(f64, f64)],
name: impl Into<String>,
angle_format: AngleFormat,
) -> Self {
let vertices_arc = prepare_aoi_vertices(vertices, angle_format);
let condition_fn = move |t: Epoch, state: &DVector<f64>, _params: Option<&DVector<f64>>| {
let r_eci = Vector3::new(state[0], state[1], state[2]);
let r_ecef = position_eci_to_ecef(t, r_eci);
let geodetic = position_ecef_to_geodetic(r_ecef, AngleFormat::Radians);
let lon = geodetic[0];
let lat = geodetic[1];
point_in_polygon(lon, lat, &vertices_arc)
};
Self {
inner: DBinaryEvent::new(name, condition_fn, EdgeType::FallingEdge),
}
}
pub fn with_instance(mut self, instance: usize) -> Self {
self.inner = self.inner.with_instance(instance);
self
}
pub fn with_tolerances(mut self, time_tol: f64, value_tol: f64) -> Self {
self.inner = self.inner.with_tolerances(time_tol, value_tol);
self
}
pub fn with_step_reduction_factor(mut self, factor: f64) -> Self {
self.inner = self.inner.with_step_reduction_factor(factor);
self
}
pub fn with_callback(mut self, callback: DEventCallback) -> Self {
self.inner = self.inner.with_callback(callback);
self
}
pub fn set_terminal(mut self) -> Self {
self.inner = self.inner.set_terminal();
self
}
}
impl_devent_detector_delegate!(DAOIExitEvent, inner);
#[cfg(test)]
#[allow(non_snake_case)]
#[cfg_attr(coverage_nightly, coverage(off))]
mod tests {
use super::*;
use crate::constants::R_EARTH;
use crate::time::TimeSystem;
use crate::utils::testing::setup_global_test_eop;
use nalgebra::{DVector, Vector3, Vector6};
use serial_test::serial;
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};
#[test]
fn test_SAltitudeEvent_new() {
setup_global_test_eop();
let event = SAltitudeEvent::<6, 0>::new(500e3, "Low Altitude", EventDirection::Decreasing);
assert_eq!(event.name(), "Low Altitude");
assert_eq!(event.target_value(), 500e3);
assert_eq!(event.direction(), EventDirection::Decreasing);
assert_eq!(event.action(), EventAction::Continue);
}
#[test]
#[serial]
fn test_SAltitudeEvent_evaluate() {
setup_global_test_eop();
let value = 500e3;
let event = SAltitudeEvent::<6, 0>::new(value, "Altitude Test", EventDirection::Any);
let epoch = Epoch::from_jd(2451545.0, TimeSystem::UTC);
let state_low = Vector6::new(6000e3, 0.0, 0.0, 0.0, 7.5e3, 0.0);
let val_low = event.evaluate(epoch, &state_low, None);
assert!(val_low < 0.0);
let state_high = Vector6::new(R_EARTH + 1000e3, 0.0, 0.0, 0.0, 7.0e3, 0.0);
let val_high = event.evaluate(epoch, &state_high, None);
assert!(val_high > 0.0);
}
#[test]
fn test_SAltitudeEvent_target_value() {
setup_global_test_eop();
let event = SAltitudeEvent::<6, 0>::new(350e3, "Reentry", EventDirection::Decreasing);
assert_eq!(event.target_value(), 350e3);
}
#[test]
fn test_SAltitudeEvent_name() {
setup_global_test_eop();
let event = SAltitudeEvent::<6, 0>::new(500e3, "Test Name", EventDirection::Any);
assert_eq!(event.name(), "Test Name");
}
#[test]
fn test_SAltitudeEvent_with_instance() {
setup_global_test_eop();
let event = SAltitudeEvent::<6, 0>::new(500e3, "Altitude Check", EventDirection::Any)
.with_instance(3);
assert_eq!(event.name(), "Altitude Check 3");
}
#[test]
fn test_SAltitudeEvent_with_tolerances() {
setup_global_test_eop();
let event = SAltitudeEvent::<6, 0>::new(500e3, "Test", EventDirection::Any);
assert_eq!(event.time_tolerance(), 1e-6);
assert_eq!(event.value_tolerance(), 1e-9);
let event = SAltitudeEvent::<6, 0>::new(500e3, "Test", EventDirection::Any)
.with_tolerances(1e-4, 1e-6);
assert_eq!(event.time_tolerance(), 1e-4);
assert_eq!(event.value_tolerance(), 1e-6);
}
#[test]
fn test_SAltitudeEvent_time_tolerance() {
setup_global_test_eop();
let event = SAltitudeEvent::<6, 0>::new(500e3, "Test", EventDirection::Any)
.with_tolerances(5e-5, 1e-9);
assert_eq!(event.time_tolerance(), 5e-5);
}
#[test]
fn test_SAltitudeEvent_value_tolerance() {
setup_global_test_eop();
let event = SAltitudeEvent::<6, 0>::new(500e3, "Test", EventDirection::Any)
.with_tolerances(1e-6, 5e-8);
assert_eq!(event.value_tolerance(), 5e-8);
}
#[test]
fn test_SAltitudeEvent_with_step_reduction_factor() {
setup_global_test_eop();
let event = SAltitudeEvent::<6, 0>::new(500e3, "Test", EventDirection::Any);
assert_eq!(event.step_reduction_factor(), 0.2);
let event = SAltitudeEvent::<6, 0>::new(500e3, "Test", EventDirection::Any)
.with_step_reduction_factor(0.15);
assert_eq!(event.step_reduction_factor(), 0.15);
}
#[test]
fn test_SAltitudeEvent_step_reduction_factor() {
setup_global_test_eop();
let event = SAltitudeEvent::<6, 0>::new(500e3, "Test", EventDirection::Any)
.with_step_reduction_factor(0.1);
assert_eq!(event.step_reduction_factor(), 0.1);
}
#[test]
fn test_SAltitudeEvent_with_callback() {
setup_global_test_eop();
let called = Arc::new(AtomicBool::new(false));
let called_clone = called.clone();
let callback: SEventCallback<6, 0> = Box::new(move |_t, _state, _params| {
called_clone.store(true, Ordering::SeqCst);
(None, None, EventAction::Continue)
});
let event =
SAltitudeEvent::<6, 0>::new(500e3, "Test", EventDirection::Any).with_callback(callback);
assert!(event.callback().is_some());
let epoch = Epoch::from_jd(2451545.0, TimeSystem::UTC);
let state = Vector6::zeros();
if let Some(cb) = event.callback() {
cb(epoch, &state, None);
}
assert!(called.load(Ordering::SeqCst));
}
#[test]
fn test_SAltitudeEvent_callback_none() {
setup_global_test_eop();
let event = SAltitudeEvent::<6, 0>::new(500e3, "Test", EventDirection::Any);
assert!(event.callback().is_none());
}
#[test]
fn test_SAltitudeEvent_set_terminal() {
setup_global_test_eop();
let event = SAltitudeEvent::<6, 0>::new(500e3, "Test", EventDirection::Any);
assert_eq!(event.action(), EventAction::Continue);
let event = SAltitudeEvent::<6, 0>::new(500e3, "Test", EventDirection::Any).set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SAltitudeEvent_action_continue() {
setup_global_test_eop();
let event = SAltitudeEvent::<6, 0>::new(500e3, "Test", EventDirection::Any);
assert_eq!(event.action(), EventAction::Continue);
}
#[test]
fn test_SAltitudeEvent_action_stop() {
setup_global_test_eop();
let event = SAltitudeEvent::<6, 0>::new(500e3, "Test", EventDirection::Any).set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SAltitudeEvent_direction_increasing() {
setup_global_test_eop();
let event = SAltitudeEvent::<6, 0>::new(500e3, "Ascending", EventDirection::Increasing);
assert_eq!(event.direction(), EventDirection::Increasing);
}
#[test]
fn test_SAltitudeEvent_direction_decreasing() {
setup_global_test_eop();
let event = SAltitudeEvent::<6, 0>::new(500e3, "Descending", EventDirection::Decreasing);
assert_eq!(event.direction(), EventDirection::Decreasing);
}
#[test]
fn test_SAltitudeEvent_direction_any() {
setup_global_test_eop();
let event = SAltitudeEvent::<6, 0>::new(500e3, "Any", EventDirection::Any);
assert_eq!(event.direction(), EventDirection::Any);
}
#[test]
#[serial]
fn test_SAltitudeEvent_7d_state() {
setup_global_test_eop();
let event = SAltitudeEvent::<7, 4>::new(500e3, "7D State", EventDirection::Decreasing);
let epoch = Epoch::from_jd(2451545.0, TimeSystem::UTC);
let state: SVector<f64, 7> =
SVector::from([R_EARTH + 600e3, 0.0, 0.0, 0.0, 7.5e3, 0.0, 1000.0]);
let altitude = event.evaluate(epoch, &state, None);
assert!(altitude > 500e3);
}
#[test]
fn test_SAltitudeEvent_builder_chaining() {
setup_global_test_eop();
let callback: SEventCallback<6, 0> =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = SAltitudeEvent::<6, 0>::new(200e3, "Reentry", EventDirection::Decreasing)
.with_instance(1)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.1)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "Reentry 1");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.value_tolerance(), 1e-8);
assert_eq!(event.step_reduction_factor(), 0.1);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DAltitudeEvent_new() {
setup_global_test_eop();
let event = DAltitudeEvent::new(500e3, "Low Altitude", EventDirection::Decreasing);
assert_eq!(event.name(), "Low Altitude");
assert_eq!(event.target_value(), 500e3);
assert_eq!(event.direction(), EventDirection::Decreasing);
assert_eq!(event.action(), EventAction::Continue);
}
#[test]
#[serial]
fn test_DAltitudeEvent_evaluate() {
setup_global_test_eop();
let value = 500e3;
let event = DAltitudeEvent::new(value, "Altitude Test", EventDirection::Any);
let epoch = Epoch::from_jd(2451545.0, TimeSystem::UTC);
let state_low = DVector::from_vec(vec![6000e3, 0.0, 0.0, 0.0, 7.5e3, 0.0]);
let val_low = event.evaluate(epoch, &state_low, None);
assert!(val_low < 0.0);
let state_high = DVector::from_vec(vec![R_EARTH + 1000e3, 0.0, 0.0, 0.0, 7.0e3, 0.0]);
let val_high = event.evaluate(epoch, &state_high, None);
assert!(val_high > 0.0);
}
#[test]
fn test_DAltitudeEvent_target_value() {
setup_global_test_eop();
let event = DAltitudeEvent::new(350e3, "Reentry", EventDirection::Decreasing);
assert_eq!(event.target_value(), 350e3);
}
#[test]
fn test_DAltitudeEvent_name() {
setup_global_test_eop();
let event = DAltitudeEvent::new(500e3, "Test Name", EventDirection::Any);
assert_eq!(event.name(), "Test Name");
}
#[test]
fn test_DAltitudeEvent_with_instance() {
setup_global_test_eop();
let event =
DAltitudeEvent::new(500e3, "Altitude Check", EventDirection::Any).with_instance(2);
assert_eq!(event.name(), "Altitude Check 2");
}
#[test]
fn test_DAltitudeEvent_with_tolerances() {
setup_global_test_eop();
let event =
DAltitudeEvent::new(500e3, "Test", EventDirection::Any).with_tolerances(1e-4, 1e-7);
assert_eq!(event.time_tolerance(), 1e-4);
assert_eq!(event.value_tolerance(), 1e-7);
}
#[test]
fn test_DAltitudeEvent_time_tolerance() {
setup_global_test_eop();
let event =
DAltitudeEvent::new(500e3, "Test", EventDirection::Any).with_tolerances(2e-5, 1e-9);
assert_eq!(event.time_tolerance(), 2e-5);
}
#[test]
fn test_DAltitudeEvent_value_tolerance() {
setup_global_test_eop();
let event =
DAltitudeEvent::new(500e3, "Test", EventDirection::Any).with_tolerances(1e-6, 3e-8);
assert_eq!(event.value_tolerance(), 3e-8);
}
#[test]
fn test_DAltitudeEvent_with_step_reduction_factor() {
setup_global_test_eop();
let event = DAltitudeEvent::new(500e3, "Test", EventDirection::Any);
assert_eq!(event.step_reduction_factor(), 0.2);
let event = DAltitudeEvent::new(500e3, "Test", EventDirection::Any)
.with_step_reduction_factor(0.25);
assert_eq!(event.step_reduction_factor(), 0.25);
}
#[test]
fn test_DAltitudeEvent_step_reduction_factor() {
setup_global_test_eop();
let event = DAltitudeEvent::new(500e3, "Test", EventDirection::Any)
.with_step_reduction_factor(0.12);
assert_eq!(event.step_reduction_factor(), 0.12);
}
#[test]
fn test_DAltitudeEvent_with_callback() {
setup_global_test_eop();
let called = Arc::new(AtomicBool::new(false));
let called_clone = called.clone();
let callback: DEventCallback = Box::new(move |_t, _state, _params| {
called_clone.store(true, Ordering::SeqCst);
(None, None, EventAction::Continue)
});
let event = DAltitudeEvent::new(500e3, "Test", EventDirection::Any).with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_DAltitudeEvent_callback_none() {
setup_global_test_eop();
let event = DAltitudeEvent::new(500e3, "Test", EventDirection::Any);
assert!(event.callback().is_none());
}
#[test]
fn test_DAltitudeEvent_set_terminal() {
setup_global_test_eop();
let event = DAltitudeEvent::new(500e3, "Test", EventDirection::Any);
assert_eq!(event.action(), EventAction::Continue);
let event = DAltitudeEvent::new(500e3, "Test", EventDirection::Any).set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DAltitudeEvent_action_continue() {
setup_global_test_eop();
let event = DAltitudeEvent::new(500e3, "Test", EventDirection::Any);
assert_eq!(event.action(), EventAction::Continue);
}
#[test]
fn test_DAltitudeEvent_action_stop() {
setup_global_test_eop();
let event = DAltitudeEvent::new(500e3, "Test", EventDirection::Any).set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DAltitudeEvent_direction_increasing() {
setup_global_test_eop();
let event = DAltitudeEvent::new(500e3, "Ascending", EventDirection::Increasing);
assert_eq!(event.direction(), EventDirection::Increasing);
}
#[test]
fn test_DAltitudeEvent_direction_decreasing() {
setup_global_test_eop();
let event = DAltitudeEvent::new(500e3, "Descending", EventDirection::Decreasing);
assert_eq!(event.direction(), EventDirection::Decreasing);
}
#[test]
fn test_DAltitudeEvent_direction_any() {
setup_global_test_eop();
let event = DAltitudeEvent::new(500e3, "Any", EventDirection::Any);
assert_eq!(event.direction(), EventDirection::Any);
}
#[test]
fn test_DAltitudeEvent_builder_chaining() {
setup_global_test_eop();
let callback: DEventCallback =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = DAltitudeEvent::new(200e3, "Reentry", EventDirection::Decreasing)
.with_instance(1)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.1)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "Reentry 1");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.value_tolerance(), 1e-8);
assert_eq!(event.step_reduction_factor(), 0.1);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SSemiMajorAxisEvent_new() {
let event =
SSemiMajorAxisEvent::<6, 0>::new(7000e3, "SMA Check", EventDirection::Increasing);
assert_eq!(event.name(), "SMA Check");
assert_eq!(event.target_value(), 7000e3);
assert_eq!(event.direction(), EventDirection::Increasing);
}
#[test]
fn test_SSemiMajorAxisEvent_evaluate() {
let event = SSemiMajorAxisEvent::<6, 0>::new(7000e3, "SMA Check", EventDirection::Any);
let epoch = Epoch::from_jd(2451545.0, TimeSystem::UTC);
let state = Vector6::new(7000e3, 0.0, 0.0, 0.0, 7546.05, 0.0);
let val = event.evaluate(epoch, &state, None);
assert!((val - 7000e3).abs() < 1000.0); }
#[test]
fn test_DSemiMajorAxisEvent_new() {
let event = DSemiMajorAxisEvent::new(7000e3, "SMA Check", EventDirection::Decreasing);
assert_eq!(event.name(), "SMA Check");
assert_eq!(event.target_value(), 7000e3);
assert_eq!(event.direction(), EventDirection::Decreasing);
}
#[test]
fn test_SSemiMajorAxisEvent_target_value() {
let event = SSemiMajorAxisEvent::<6, 0>::new(8000e3, "SMA", EventDirection::Any);
assert_eq!(event.target_value(), 8000e3);
}
#[test]
fn test_SSemiMajorAxisEvent_name() {
let event = SSemiMajorAxisEvent::<6, 0>::new(7000e3, "Test SMA Name", EventDirection::Any);
assert_eq!(event.name(), "Test SMA Name");
}
#[test]
fn test_SSemiMajorAxisEvent_with_instance() {
let event = SSemiMajorAxisEvent::<6, 0>::new(7000e3, "SMA Check", EventDirection::Any)
.with_instance(3);
assert_eq!(event.name(), "SMA Check 3");
}
#[test]
fn test_SSemiMajorAxisEvent_with_tolerances() {
let event = SSemiMajorAxisEvent::<6, 0>::new(7000e3, "Test", EventDirection::Any);
assert_eq!(event.time_tolerance(), 1e-6);
assert_eq!(event.value_tolerance(), 1e-9);
let event = SSemiMajorAxisEvent::<6, 0>::new(7000e3, "Test", EventDirection::Any)
.with_tolerances(1e-4, 1e-6);
assert_eq!(event.time_tolerance(), 1e-4);
assert_eq!(event.value_tolerance(), 1e-6);
}
#[test]
fn test_SSemiMajorAxisEvent_time_tolerance() {
let event = SSemiMajorAxisEvent::<6, 0>::new(7000e3, "Test", EventDirection::Any)
.with_tolerances(5e-5, 1e-9);
assert_eq!(event.time_tolerance(), 5e-5);
}
#[test]
fn test_SSemiMajorAxisEvent_value_tolerance() {
let event = SSemiMajorAxisEvent::<6, 0>::new(7000e3, "Test", EventDirection::Any)
.with_tolerances(1e-6, 5e-8);
assert_eq!(event.value_tolerance(), 5e-8);
}
#[test]
fn test_SSemiMajorAxisEvent_with_step_reduction_factor() {
let event = SSemiMajorAxisEvent::<6, 0>::new(7000e3, "Test", EventDirection::Any);
assert_eq!(event.step_reduction_factor(), 0.2);
let event = SSemiMajorAxisEvent::<6, 0>::new(7000e3, "Test", EventDirection::Any)
.with_step_reduction_factor(0.15);
assert_eq!(event.step_reduction_factor(), 0.15);
}
#[test]
fn test_SSemiMajorAxisEvent_step_reduction_factor() {
let event = SSemiMajorAxisEvent::<6, 0>::new(7000e3, "Test", EventDirection::Any)
.with_step_reduction_factor(0.1);
assert_eq!(event.step_reduction_factor(), 0.1);
}
#[test]
fn test_SSemiMajorAxisEvent_with_callback() {
let called = Arc::new(AtomicBool::new(false));
let called_clone = called.clone();
let callback: SEventCallback<6, 0> = Box::new(move |_t, _state, _params| {
called_clone.store(true, Ordering::SeqCst);
(None, None, EventAction::Continue)
});
let event = SSemiMajorAxisEvent::<6, 0>::new(7000e3, "Test", EventDirection::Any)
.with_callback(callback);
assert!(event.callback().is_some());
let epoch = Epoch::from_jd(2451545.0, TimeSystem::UTC);
let state = Vector6::zeros();
if let Some(cb) = event.callback() {
cb(epoch, &state, None);
}
assert!(called.load(Ordering::SeqCst));
}
#[test]
fn test_SSemiMajorAxisEvent_callback_none() {
let event = SSemiMajorAxisEvent::<6, 0>::new(7000e3, "Test", EventDirection::Any);
assert!(event.callback().is_none());
}
#[test]
fn test_SSemiMajorAxisEvent_set_terminal() {
let event = SSemiMajorAxisEvent::<6, 0>::new(7000e3, "Test", EventDirection::Any);
assert_eq!(event.action(), EventAction::Continue);
let event =
SSemiMajorAxisEvent::<6, 0>::new(7000e3, "Test", EventDirection::Any).set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SSemiMajorAxisEvent_action_continue() {
let event = SSemiMajorAxisEvent::<6, 0>::new(7000e3, "Test", EventDirection::Any);
assert_eq!(event.action(), EventAction::Continue);
}
#[test]
fn test_SSemiMajorAxisEvent_action_stop() {
let event =
SSemiMajorAxisEvent::<6, 0>::new(7000e3, "Test", EventDirection::Any).set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SSemiMajorAxisEvent_direction_increasing() {
let event =
SSemiMajorAxisEvent::<6, 0>::new(7000e3, "Ascending", EventDirection::Increasing);
assert_eq!(event.direction(), EventDirection::Increasing);
}
#[test]
fn test_SSemiMajorAxisEvent_direction_decreasing() {
let event =
SSemiMajorAxisEvent::<6, 0>::new(7000e3, "Descending", EventDirection::Decreasing);
assert_eq!(event.direction(), EventDirection::Decreasing);
}
#[test]
fn test_SSemiMajorAxisEvent_direction_any() {
let event = SSemiMajorAxisEvent::<6, 0>::new(7000e3, "Any", EventDirection::Any);
assert_eq!(event.direction(), EventDirection::Any);
}
#[test]
fn test_SSemiMajorAxisEvent_builder_chaining() {
let callback: SEventCallback<6, 0> =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = SSemiMajorAxisEvent::<6, 0>::new(7000e3, "SMA", EventDirection::Increasing)
.with_instance(1)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.1)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "SMA 1");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.value_tolerance(), 1e-8);
assert_eq!(event.step_reduction_factor(), 0.1);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DSemiMajorAxisEvent_evaluate() {
let event = DSemiMajorAxisEvent::new(7000e3, "SMA Test", EventDirection::Any);
let epoch = Epoch::from_jd(2451545.0, TimeSystem::UTC);
let state = DVector::from_vec(vec![7000e3, 0.0, 0.0, 0.0, 7546.05, 0.0]);
let val = event.evaluate(epoch, &state, None);
assert!((val - 7000e3).abs() < 1000.0);
}
#[test]
fn test_DSemiMajorAxisEvent_target_value() {
let event = DSemiMajorAxisEvent::new(8000e3, "SMA", EventDirection::Any);
assert_eq!(event.target_value(), 8000e3);
}
#[test]
fn test_DSemiMajorAxisEvent_name() {
let event = DSemiMajorAxisEvent::new(7000e3, "Test SMA Name", EventDirection::Any);
assert_eq!(event.name(), "Test SMA Name");
}
#[test]
fn test_DSemiMajorAxisEvent_with_instance() {
let event =
DSemiMajorAxisEvent::new(7000e3, "SMA Check", EventDirection::Any).with_instance(2);
assert_eq!(event.name(), "SMA Check 2");
}
#[test]
fn test_DSemiMajorAxisEvent_with_tolerances() {
let event = DSemiMajorAxisEvent::new(7000e3, "Test", EventDirection::Any)
.with_tolerances(1e-4, 1e-7);
assert_eq!(event.time_tolerance(), 1e-4);
assert_eq!(event.value_tolerance(), 1e-7);
}
#[test]
fn test_DSemiMajorAxisEvent_time_tolerance() {
let event = DSemiMajorAxisEvent::new(7000e3, "Test", EventDirection::Any)
.with_tolerances(2e-5, 1e-9);
assert_eq!(event.time_tolerance(), 2e-5);
}
#[test]
fn test_DSemiMajorAxisEvent_value_tolerance() {
let event = DSemiMajorAxisEvent::new(7000e3, "Test", EventDirection::Any)
.with_tolerances(1e-6, 3e-8);
assert_eq!(event.value_tolerance(), 3e-8);
}
#[test]
fn test_DSemiMajorAxisEvent_with_step_reduction_factor() {
let event = DSemiMajorAxisEvent::new(7000e3, "Test", EventDirection::Any);
assert_eq!(event.step_reduction_factor(), 0.2);
let event = DSemiMajorAxisEvent::new(7000e3, "Test", EventDirection::Any)
.with_step_reduction_factor(0.25);
assert_eq!(event.step_reduction_factor(), 0.25);
}
#[test]
fn test_DSemiMajorAxisEvent_step_reduction_factor() {
let event = DSemiMajorAxisEvent::new(7000e3, "Test", EventDirection::Any)
.with_step_reduction_factor(0.12);
assert_eq!(event.step_reduction_factor(), 0.12);
}
#[test]
fn test_DSemiMajorAxisEvent_with_callback() {
let called = Arc::new(AtomicBool::new(false));
let called_clone = called.clone();
let callback: DEventCallback = Box::new(move |_t, _state, _params| {
called_clone.store(true, Ordering::SeqCst);
(None, None, EventAction::Continue)
});
let event =
DSemiMajorAxisEvent::new(7000e3, "Test", EventDirection::Any).with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_DSemiMajorAxisEvent_callback_none() {
let event = DSemiMajorAxisEvent::new(7000e3, "Test", EventDirection::Any);
assert!(event.callback().is_none());
}
#[test]
fn test_DSemiMajorAxisEvent_set_terminal() {
let event = DSemiMajorAxisEvent::new(7000e3, "Test", EventDirection::Any);
assert_eq!(event.action(), EventAction::Continue);
let event = DSemiMajorAxisEvent::new(7000e3, "Test", EventDirection::Any).set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DSemiMajorAxisEvent_action_continue() {
let event = DSemiMajorAxisEvent::new(7000e3, "Test", EventDirection::Any);
assert_eq!(event.action(), EventAction::Continue);
}
#[test]
fn test_DSemiMajorAxisEvent_action_stop() {
let event = DSemiMajorAxisEvent::new(7000e3, "Test", EventDirection::Any).set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DSemiMajorAxisEvent_direction_increasing() {
let event = DSemiMajorAxisEvent::new(7000e3, "Ascending", EventDirection::Increasing);
assert_eq!(event.direction(), EventDirection::Increasing);
}
#[test]
fn test_DSemiMajorAxisEvent_direction_decreasing() {
let event = DSemiMajorAxisEvent::new(7000e3, "Descending", EventDirection::Decreasing);
assert_eq!(event.direction(), EventDirection::Decreasing);
}
#[test]
fn test_DSemiMajorAxisEvent_direction_any() {
let event = DSemiMajorAxisEvent::new(7000e3, "Any", EventDirection::Any);
assert_eq!(event.direction(), EventDirection::Any);
}
#[test]
fn test_DSemiMajorAxisEvent_builder_chaining() {
let callback: DEventCallback =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = DSemiMajorAxisEvent::new(7000e3, "SMA", EventDirection::Decreasing)
.with_instance(1)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.1)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "SMA 1");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.value_tolerance(), 1e-8);
assert_eq!(event.step_reduction_factor(), 0.1);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SEccentricityEvent_new() {
let event = SEccentricityEvent::<6, 0>::new(0.1, "Ecc value", EventDirection::Increasing);
assert_eq!(event.name(), "Ecc value");
assert_eq!(event.target_value(), 0.1);
assert_eq!(event.direction(), EventDirection::Increasing);
}
#[test]
fn test_SEccentricityEvent_evaluate() {
let event = SEccentricityEvent::<6, 0>::new(0.1, "Ecc Test", EventDirection::Any);
let epoch = Epoch::from_jd(2451545.0, TimeSystem::UTC);
let state = Vector6::new(7000e3, 0.0, 0.0, 0.0, 7546.05, 0.0);
let val = event.evaluate(epoch, &state, None);
assert!(val >= 0.0); assert!(val < 0.01); }
#[test]
fn test_DEccentricityEvent_new() {
let event = DEccentricityEvent::new(0.5, "Ecc Check", EventDirection::Any);
assert_eq!(event.name(), "Ecc Check");
assert_eq!(event.target_value(), 0.5);
}
#[test]
fn test_SEccentricityEvent_target_value() {
let event = SEccentricityEvent::<6, 0>::new(0.25, "Ecc", EventDirection::Any);
assert_eq!(event.target_value(), 0.25);
}
#[test]
fn test_SEccentricityEvent_name() {
let event = SEccentricityEvent::<6, 0>::new(0.1, "Test Ecc Name", EventDirection::Any);
assert_eq!(event.name(), "Test Ecc Name");
}
#[test]
fn test_SEccentricityEvent_with_instance() {
let event =
SEccentricityEvent::<6, 0>::new(0.1, "Ecc Check", EventDirection::Any).with_instance(3);
assert_eq!(event.name(), "Ecc Check 3");
}
#[test]
fn test_SEccentricityEvent_with_tolerances() {
let event = SEccentricityEvent::<6, 0>::new(0.1, "Test", EventDirection::Any);
assert_eq!(event.time_tolerance(), 1e-6);
assert_eq!(event.value_tolerance(), 1e-9);
let event = SEccentricityEvent::<6, 0>::new(0.1, "Test", EventDirection::Any)
.with_tolerances(1e-4, 1e-6);
assert_eq!(event.time_tolerance(), 1e-4);
assert_eq!(event.value_tolerance(), 1e-6);
}
#[test]
fn test_SEccentricityEvent_time_tolerance() {
let event = SEccentricityEvent::<6, 0>::new(0.1, "Test", EventDirection::Any)
.with_tolerances(5e-5, 1e-9);
assert_eq!(event.time_tolerance(), 5e-5);
}
#[test]
fn test_SEccentricityEvent_value_tolerance() {
let event = SEccentricityEvent::<6, 0>::new(0.1, "Test", EventDirection::Any)
.with_tolerances(1e-6, 5e-8);
assert_eq!(event.value_tolerance(), 5e-8);
}
#[test]
fn test_SEccentricityEvent_with_step_reduction_factor() {
let event = SEccentricityEvent::<6, 0>::new(0.1, "Test", EventDirection::Any);
assert_eq!(event.step_reduction_factor(), 0.2);
let event = SEccentricityEvent::<6, 0>::new(0.1, "Test", EventDirection::Any)
.with_step_reduction_factor(0.15);
assert_eq!(event.step_reduction_factor(), 0.15);
}
#[test]
fn test_SEccentricityEvent_step_reduction_factor() {
let event = SEccentricityEvent::<6, 0>::new(0.1, "Test", EventDirection::Any)
.with_step_reduction_factor(0.1);
assert_eq!(event.step_reduction_factor(), 0.1);
}
#[test]
fn test_SEccentricityEvent_with_callback() {
let called = Arc::new(AtomicBool::new(false));
let called_clone = called.clone();
let callback: SEventCallback<6, 0> = Box::new(move |_t, _state, _params| {
called_clone.store(true, Ordering::SeqCst);
(None, None, EventAction::Continue)
});
let event = SEccentricityEvent::<6, 0>::new(0.1, "Test", EventDirection::Any)
.with_callback(callback);
assert!(event.callback().is_some());
let epoch = Epoch::from_jd(2451545.0, TimeSystem::UTC);
let state = Vector6::zeros();
if let Some(cb) = event.callback() {
cb(epoch, &state, None);
}
assert!(called.load(Ordering::SeqCst));
}
#[test]
fn test_SEccentricityEvent_callback_none() {
let event = SEccentricityEvent::<6, 0>::new(0.1, "Test", EventDirection::Any);
assert!(event.callback().is_none());
}
#[test]
fn test_SEccentricityEvent_set_terminal() {
let event = SEccentricityEvent::<6, 0>::new(0.1, "Test", EventDirection::Any);
assert_eq!(event.action(), EventAction::Continue);
let event =
SEccentricityEvent::<6, 0>::new(0.1, "Test", EventDirection::Any).set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SEccentricityEvent_action_continue() {
let event = SEccentricityEvent::<6, 0>::new(0.1, "Test", EventDirection::Any);
assert_eq!(event.action(), EventAction::Continue);
}
#[test]
fn test_SEccentricityEvent_action_stop() {
let event =
SEccentricityEvent::<6, 0>::new(0.1, "Test", EventDirection::Any).set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SEccentricityEvent_direction_increasing() {
let event = SEccentricityEvent::<6, 0>::new(0.1, "Ascending", EventDirection::Increasing);
assert_eq!(event.direction(), EventDirection::Increasing);
}
#[test]
fn test_SEccentricityEvent_direction_decreasing() {
let event = SEccentricityEvent::<6, 0>::new(0.1, "Descending", EventDirection::Decreasing);
assert_eq!(event.direction(), EventDirection::Decreasing);
}
#[test]
fn test_SEccentricityEvent_direction_any() {
let event = SEccentricityEvent::<6, 0>::new(0.1, "Any", EventDirection::Any);
assert_eq!(event.direction(), EventDirection::Any);
}
#[test]
fn test_SEccentricityEvent_builder_chaining() {
let callback: SEventCallback<6, 0> =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = SEccentricityEvent::<6, 0>::new(0.1, "Ecc", EventDirection::Increasing)
.with_instance(1)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.1)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "Ecc 1");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.value_tolerance(), 1e-8);
assert_eq!(event.step_reduction_factor(), 0.1);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DEccentricityEvent_evaluate() {
let event = DEccentricityEvent::new(0.1, "Ecc Test", EventDirection::Any);
let epoch = Epoch::from_jd(2451545.0, TimeSystem::UTC);
let state = DVector::from_vec(vec![7000e3, 0.0, 0.0, 0.0, 7546.05, 0.0]);
let val = event.evaluate(epoch, &state, None);
assert!(val >= 0.0);
assert!(val < 0.01);
}
#[test]
fn test_DEccentricityEvent_target_value() {
let event = DEccentricityEvent::new(0.25, "Ecc", EventDirection::Any);
assert_eq!(event.target_value(), 0.25);
}
#[test]
fn test_DEccentricityEvent_name() {
let event = DEccentricityEvent::new(0.1, "Test Ecc Name", EventDirection::Any);
assert_eq!(event.name(), "Test Ecc Name");
}
#[test]
fn test_DEccentricityEvent_with_instance() {
let event = DEccentricityEvent::new(0.1, "Ecc Check", EventDirection::Any).with_instance(2);
assert_eq!(event.name(), "Ecc Check 2");
}
#[test]
fn test_DEccentricityEvent_with_tolerances() {
let event =
DEccentricityEvent::new(0.1, "Test", EventDirection::Any).with_tolerances(1e-4, 1e-7);
assert_eq!(event.time_tolerance(), 1e-4);
assert_eq!(event.value_tolerance(), 1e-7);
}
#[test]
fn test_DEccentricityEvent_time_tolerance() {
let event =
DEccentricityEvent::new(0.1, "Test", EventDirection::Any).with_tolerances(2e-5, 1e-9);
assert_eq!(event.time_tolerance(), 2e-5);
}
#[test]
fn test_DEccentricityEvent_value_tolerance() {
let event =
DEccentricityEvent::new(0.1, "Test", EventDirection::Any).with_tolerances(1e-6, 3e-8);
assert_eq!(event.value_tolerance(), 3e-8);
}
#[test]
fn test_DEccentricityEvent_with_step_reduction_factor() {
let event = DEccentricityEvent::new(0.1, "Test", EventDirection::Any);
assert_eq!(event.step_reduction_factor(), 0.2);
let event = DEccentricityEvent::new(0.1, "Test", EventDirection::Any)
.with_step_reduction_factor(0.25);
assert_eq!(event.step_reduction_factor(), 0.25);
}
#[test]
fn test_DEccentricityEvent_step_reduction_factor() {
let event = DEccentricityEvent::new(0.1, "Test", EventDirection::Any)
.with_step_reduction_factor(0.12);
assert_eq!(event.step_reduction_factor(), 0.12);
}
#[test]
fn test_DEccentricityEvent_with_callback() {
let called = Arc::new(AtomicBool::new(false));
let called_clone = called.clone();
let callback: DEventCallback = Box::new(move |_t, _state, _params| {
called_clone.store(true, Ordering::SeqCst);
(None, None, EventAction::Continue)
});
let event =
DEccentricityEvent::new(0.1, "Test", EventDirection::Any).with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_DEccentricityEvent_callback_none() {
let event = DEccentricityEvent::new(0.1, "Test", EventDirection::Any);
assert!(event.callback().is_none());
}
#[test]
fn test_DEccentricityEvent_set_terminal() {
let event = DEccentricityEvent::new(0.1, "Test", EventDirection::Any);
assert_eq!(event.action(), EventAction::Continue);
let event = DEccentricityEvent::new(0.1, "Test", EventDirection::Any).set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DEccentricityEvent_action_continue() {
let event = DEccentricityEvent::new(0.1, "Test", EventDirection::Any);
assert_eq!(event.action(), EventAction::Continue);
}
#[test]
fn test_DEccentricityEvent_action_stop() {
let event = DEccentricityEvent::new(0.1, "Test", EventDirection::Any).set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DEccentricityEvent_direction_increasing() {
let event = DEccentricityEvent::new(0.1, "Ascending", EventDirection::Increasing);
assert_eq!(event.direction(), EventDirection::Increasing);
}
#[test]
fn test_DEccentricityEvent_direction_decreasing() {
let event = DEccentricityEvent::new(0.1, "Descending", EventDirection::Decreasing);
assert_eq!(event.direction(), EventDirection::Decreasing);
}
#[test]
fn test_DEccentricityEvent_direction_any() {
let event = DEccentricityEvent::new(0.1, "Any", EventDirection::Any);
assert_eq!(event.direction(), EventDirection::Any);
}
#[test]
fn test_DEccentricityEvent_builder_chaining() {
let callback: DEventCallback =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = DEccentricityEvent::new(0.1, "Ecc", EventDirection::Decreasing)
.with_instance(1)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.1)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "Ecc 1");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.value_tolerance(), 1e-8);
assert_eq!(event.step_reduction_factor(), 0.1);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SInclinationEvent_new() {
let inc_rad = std::f64::consts::PI / 4.0; let event = SInclinationEvent::<6, 0>::new(
inc_rad,
"Inc value",
EventDirection::Increasing,
AngleFormat::Radians,
);
assert_eq!(event.name(), "Inc value");
assert_eq!(event.target_value(), inc_rad);
}
#[test]
fn test_DInclinationEvent_new() {
let event =
DInclinationEvent::new(45.0, "Inc Check", EventDirection::Any, AngleFormat::Degrees);
assert_eq!(event.name(), "Inc Check");
}
#[test]
fn test_SInclinationEvent_new_degrees() {
let event = SInclinationEvent::<6, 0>::new(
45.0,
"Inc Deg",
EventDirection::Increasing,
AngleFormat::Degrees,
);
assert_eq!(event.name(), "Inc Deg");
assert!((event.target_value() - std::f64::consts::PI / 4.0).abs() < 1e-10);
}
#[test]
fn test_SInclinationEvent_target_value() {
let event =
SInclinationEvent::<6, 0>::new(0.5, "Inc", EventDirection::Any, AngleFormat::Radians);
assert_eq!(event.target_value(), 0.5);
}
#[test]
fn test_SInclinationEvent_name() {
let event = SInclinationEvent::<6, 0>::new(
45.0,
"Test Inc Name",
EventDirection::Any,
AngleFormat::Degrees,
);
assert_eq!(event.name(), "Test Inc Name");
}
#[test]
fn test_SInclinationEvent_with_instance() {
let event = SInclinationEvent::<6, 0>::new(
45.0,
"Inc Check",
EventDirection::Any,
AngleFormat::Degrees,
)
.with_instance(3);
assert_eq!(event.name(), "Inc Check 3");
}
#[test]
fn test_SInclinationEvent_with_tolerances() {
let event =
SInclinationEvent::<6, 0>::new(45.0, "Test", EventDirection::Any, AngleFormat::Degrees);
assert_eq!(event.time_tolerance(), 1e-6);
assert_eq!(event.value_tolerance(), 1e-9);
let event =
SInclinationEvent::<6, 0>::new(45.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.with_tolerances(1e-4, 1e-6);
assert_eq!(event.time_tolerance(), 1e-4);
assert_eq!(event.value_tolerance(), 1e-6);
}
#[test]
fn test_SInclinationEvent_time_tolerance() {
let event =
SInclinationEvent::<6, 0>::new(45.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.with_tolerances(5e-5, 1e-9);
assert_eq!(event.time_tolerance(), 5e-5);
}
#[test]
fn test_SInclinationEvent_value_tolerance() {
let event =
SInclinationEvent::<6, 0>::new(45.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.with_tolerances(1e-6, 5e-8);
assert_eq!(event.value_tolerance(), 5e-8);
}
#[test]
fn test_SInclinationEvent_with_step_reduction_factor() {
let event =
SInclinationEvent::<6, 0>::new(45.0, "Test", EventDirection::Any, AngleFormat::Degrees);
assert_eq!(event.step_reduction_factor(), 0.2);
let event =
SInclinationEvent::<6, 0>::new(45.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.with_step_reduction_factor(0.15);
assert_eq!(event.step_reduction_factor(), 0.15);
}
#[test]
fn test_SInclinationEvent_step_reduction_factor() {
let event =
SInclinationEvent::<6, 0>::new(45.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.with_step_reduction_factor(0.1);
assert_eq!(event.step_reduction_factor(), 0.1);
}
#[test]
fn test_SInclinationEvent_with_callback() {
let called = Arc::new(AtomicBool::new(false));
let called_clone = called.clone();
let callback: SEventCallback<6, 0> = Box::new(move |_t, _state, _params| {
called_clone.store(true, Ordering::SeqCst);
(None, None, EventAction::Continue)
});
let event =
SInclinationEvent::<6, 0>::new(45.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.with_callback(callback);
assert!(event.callback().is_some());
let epoch = Epoch::from_jd(2451545.0, TimeSystem::UTC);
let state = Vector6::zeros();
if let Some(cb) = event.callback() {
cb(epoch, &state, None);
}
assert!(called.load(Ordering::SeqCst));
}
#[test]
fn test_SInclinationEvent_callback_none() {
let event =
SInclinationEvent::<6, 0>::new(45.0, "Test", EventDirection::Any, AngleFormat::Degrees);
assert!(event.callback().is_none());
}
#[test]
fn test_SInclinationEvent_set_terminal() {
let event =
SInclinationEvent::<6, 0>::new(45.0, "Test", EventDirection::Any, AngleFormat::Degrees);
assert_eq!(event.action(), EventAction::Continue);
let event =
SInclinationEvent::<6, 0>::new(45.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SInclinationEvent_action_continue() {
let event =
SInclinationEvent::<6, 0>::new(45.0, "Test", EventDirection::Any, AngleFormat::Degrees);
assert_eq!(event.action(), EventAction::Continue);
}
#[test]
fn test_SInclinationEvent_action_stop() {
let event =
SInclinationEvent::<6, 0>::new(45.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SInclinationEvent_direction_increasing() {
let event = SInclinationEvent::<6, 0>::new(
45.0,
"Ascending",
EventDirection::Increasing,
AngleFormat::Degrees,
);
assert_eq!(event.direction(), EventDirection::Increasing);
}
#[test]
fn test_SInclinationEvent_direction_decreasing() {
let event = SInclinationEvent::<6, 0>::new(
45.0,
"Descending",
EventDirection::Decreasing,
AngleFormat::Degrees,
);
assert_eq!(event.direction(), EventDirection::Decreasing);
}
#[test]
fn test_SInclinationEvent_direction_any() {
let event =
SInclinationEvent::<6, 0>::new(45.0, "Any", EventDirection::Any, AngleFormat::Degrees);
assert_eq!(event.direction(), EventDirection::Any);
}
#[test]
fn test_SInclinationEvent_builder_chaining() {
let callback: SEventCallback<6, 0> =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = SInclinationEvent::<6, 0>::new(
45.0,
"Inc",
EventDirection::Increasing,
AngleFormat::Degrees,
)
.with_instance(1)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.1)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "Inc 1");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.value_tolerance(), 1e-8);
assert_eq!(event.step_reduction_factor(), 0.1);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DInclinationEvent_new_radians() {
let event = DInclinationEvent::new(
std::f64::consts::PI / 4.0,
"Inc Rad",
EventDirection::Any,
AngleFormat::Radians,
);
assert_eq!(event.name(), "Inc Rad");
}
#[test]
fn test_DInclinationEvent_target_value() {
let event = DInclinationEvent::new(0.5, "Inc", EventDirection::Any, AngleFormat::Radians);
assert_eq!(event.target_value(), 0.5);
}
#[test]
fn test_DInclinationEvent_name() {
let event = DInclinationEvent::new(
45.0,
"Test Inc Name",
EventDirection::Any,
AngleFormat::Degrees,
);
assert_eq!(event.name(), "Test Inc Name");
}
#[test]
fn test_DInclinationEvent_with_instance() {
let event =
DInclinationEvent::new(45.0, "Inc Check", EventDirection::Any, AngleFormat::Degrees)
.with_instance(2);
assert_eq!(event.name(), "Inc Check 2");
}
#[test]
fn test_DInclinationEvent_with_tolerances() {
let event = DInclinationEvent::new(45.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.with_tolerances(1e-4, 1e-7);
assert_eq!(event.time_tolerance(), 1e-4);
assert_eq!(event.value_tolerance(), 1e-7);
}
#[test]
fn test_DInclinationEvent_time_tolerance() {
let event = DInclinationEvent::new(45.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.with_tolerances(2e-5, 1e-9);
assert_eq!(event.time_tolerance(), 2e-5);
}
#[test]
fn test_DInclinationEvent_value_tolerance() {
let event = DInclinationEvent::new(45.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.with_tolerances(1e-6, 3e-8);
assert_eq!(event.value_tolerance(), 3e-8);
}
#[test]
fn test_DInclinationEvent_with_step_reduction_factor() {
let event = DInclinationEvent::new(45.0, "Test", EventDirection::Any, AngleFormat::Degrees);
assert_eq!(event.step_reduction_factor(), 0.2);
let event = DInclinationEvent::new(45.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.with_step_reduction_factor(0.25);
assert_eq!(event.step_reduction_factor(), 0.25);
}
#[test]
fn test_DInclinationEvent_step_reduction_factor() {
let event = DInclinationEvent::new(45.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.with_step_reduction_factor(0.12);
assert_eq!(event.step_reduction_factor(), 0.12);
}
#[test]
fn test_DInclinationEvent_with_callback() {
let called = Arc::new(AtomicBool::new(false));
let called_clone = called.clone();
let callback: DEventCallback = Box::new(move |_t, _state, _params| {
called_clone.store(true, Ordering::SeqCst);
(None, None, EventAction::Continue)
});
let event = DInclinationEvent::new(45.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_DInclinationEvent_callback_none() {
let event = DInclinationEvent::new(45.0, "Test", EventDirection::Any, AngleFormat::Degrees);
assert!(event.callback().is_none());
}
#[test]
fn test_DInclinationEvent_set_terminal() {
let event = DInclinationEvent::new(45.0, "Test", EventDirection::Any, AngleFormat::Degrees);
assert_eq!(event.action(), EventAction::Continue);
let event = DInclinationEvent::new(45.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DInclinationEvent_action_continue() {
let event = DInclinationEvent::new(45.0, "Test", EventDirection::Any, AngleFormat::Degrees);
assert_eq!(event.action(), EventAction::Continue);
}
#[test]
fn test_DInclinationEvent_action_stop() {
let event = DInclinationEvent::new(45.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DInclinationEvent_direction_increasing() {
let event = DInclinationEvent::new(
45.0,
"Ascending",
EventDirection::Increasing,
AngleFormat::Degrees,
);
assert_eq!(event.direction(), EventDirection::Increasing);
}
#[test]
fn test_DInclinationEvent_direction_decreasing() {
let event = DInclinationEvent::new(
45.0,
"Descending",
EventDirection::Decreasing,
AngleFormat::Degrees,
);
assert_eq!(event.direction(), EventDirection::Decreasing);
}
#[test]
fn test_DInclinationEvent_direction_any() {
let event = DInclinationEvent::new(45.0, "Any", EventDirection::Any, AngleFormat::Degrees);
assert_eq!(event.direction(), EventDirection::Any);
}
#[test]
fn test_DInclinationEvent_builder_chaining() {
let callback: DEventCallback =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = DInclinationEvent::new(
45.0,
"Inc",
EventDirection::Decreasing,
AngleFormat::Degrees,
)
.with_instance(1)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.1)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "Inc 1");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.value_tolerance(), 1e-8);
assert_eq!(event.step_reduction_factor(), 0.1);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SArgumentOfPerigeeEvent_new() {
let event = SArgumentOfPerigeeEvent::<6, 0>::new(
std::f64::consts::PI / 2.0,
"AoP",
EventDirection::Increasing,
AngleFormat::Radians,
);
assert_eq!(event.name(), "AoP");
}
#[test]
fn test_DArgumentOfPerigeeEvent_new() {
let event =
DArgumentOfPerigeeEvent::new(90.0, "AoP", EventDirection::Any, AngleFormat::Degrees);
assert_eq!(event.name(), "AoP");
}
#[test]
fn test_SArgumentOfPerigeeEvent_target_value() {
let event = SArgumentOfPerigeeEvent::<6, 0>::new(
0.5,
"AoP",
EventDirection::Any,
AngleFormat::Radians,
);
assert_eq!(event.target_value(), 0.5);
}
#[test]
fn test_SArgumentOfPerigeeEvent_with_instance() {
let event = SArgumentOfPerigeeEvent::<6, 0>::new(
90.0,
"AoP Check",
EventDirection::Any,
AngleFormat::Degrees,
)
.with_instance(3);
assert_eq!(event.name(), "AoP Check 3");
}
#[test]
fn test_SArgumentOfPerigeeEvent_with_tolerances() {
let event = SArgumentOfPerigeeEvent::<6, 0>::new(
90.0,
"Test",
EventDirection::Any,
AngleFormat::Degrees,
)
.with_tolerances(1e-4, 1e-6);
assert_eq!(event.time_tolerance(), 1e-4);
assert_eq!(event.value_tolerance(), 1e-6);
}
#[test]
fn test_SArgumentOfPerigeeEvent_with_step_reduction_factor() {
let event = SArgumentOfPerigeeEvent::<6, 0>::new(
90.0,
"Test",
EventDirection::Any,
AngleFormat::Degrees,
)
.with_step_reduction_factor(0.15);
assert_eq!(event.step_reduction_factor(), 0.15);
}
#[test]
fn test_SArgumentOfPerigeeEvent_with_callback() {
let callback: SEventCallback<6, 0> =
Box::new(move |_t, _state, _params| (None, None, EventAction::Continue));
let event = SArgumentOfPerigeeEvent::<6, 0>::new(
90.0,
"Test",
EventDirection::Any,
AngleFormat::Degrees,
)
.with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_SArgumentOfPerigeeEvent_callback_none() {
let event = SArgumentOfPerigeeEvent::<6, 0>::new(
90.0,
"Test",
EventDirection::Any,
AngleFormat::Degrees,
);
assert!(event.callback().is_none());
}
#[test]
fn test_SArgumentOfPerigeeEvent_set_terminal() {
let event = SArgumentOfPerigeeEvent::<6, 0>::new(
90.0,
"Test",
EventDirection::Any,
AngleFormat::Degrees,
)
.set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SArgumentOfPerigeeEvent_direction_increasing() {
let event = SArgumentOfPerigeeEvent::<6, 0>::new(
90.0,
"AoP",
EventDirection::Increasing,
AngleFormat::Degrees,
);
assert_eq!(event.direction(), EventDirection::Increasing);
}
#[test]
fn test_SArgumentOfPerigeeEvent_direction_decreasing() {
let event = SArgumentOfPerigeeEvent::<6, 0>::new(
90.0,
"AoP",
EventDirection::Decreasing,
AngleFormat::Degrees,
);
assert_eq!(event.direction(), EventDirection::Decreasing);
}
#[test]
fn test_SArgumentOfPerigeeEvent_direction_any() {
let event = SArgumentOfPerigeeEvent::<6, 0>::new(
90.0,
"AoP",
EventDirection::Any,
AngleFormat::Degrees,
);
assert_eq!(event.direction(), EventDirection::Any);
}
#[test]
fn test_SArgumentOfPerigeeEvent_builder_chaining() {
let callback: SEventCallback<6, 0> =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = SArgumentOfPerigeeEvent::<6, 0>::new(
90.0,
"AoP",
EventDirection::Increasing,
AngleFormat::Degrees,
)
.with_instance(1)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.1)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "AoP 1");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.step_reduction_factor(), 0.1);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DArgumentOfPerigeeEvent_target_value() {
let event =
DArgumentOfPerigeeEvent::new(0.5, "AoP", EventDirection::Any, AngleFormat::Radians);
assert_eq!(event.target_value(), 0.5);
}
#[test]
fn test_DArgumentOfPerigeeEvent_with_instance() {
let event = DArgumentOfPerigeeEvent::new(
90.0,
"AoP Check",
EventDirection::Any,
AngleFormat::Degrees,
)
.with_instance(2);
assert_eq!(event.name(), "AoP Check 2");
}
#[test]
fn test_DArgumentOfPerigeeEvent_with_tolerances() {
let event =
DArgumentOfPerigeeEvent::new(90.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.with_tolerances(1e-4, 1e-7);
assert_eq!(event.time_tolerance(), 1e-4);
assert_eq!(event.value_tolerance(), 1e-7);
}
#[test]
fn test_DArgumentOfPerigeeEvent_with_step_reduction_factor() {
let event =
DArgumentOfPerigeeEvent::new(90.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.with_step_reduction_factor(0.25);
assert_eq!(event.step_reduction_factor(), 0.25);
}
#[test]
fn test_DArgumentOfPerigeeEvent_with_callback() {
let callback: DEventCallback =
Box::new(move |_t, _state, _params| (None, None, EventAction::Continue));
let event =
DArgumentOfPerigeeEvent::new(90.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_DArgumentOfPerigeeEvent_callback_none() {
let event =
DArgumentOfPerigeeEvent::new(90.0, "Test", EventDirection::Any, AngleFormat::Degrees);
assert!(event.callback().is_none());
}
#[test]
fn test_DArgumentOfPerigeeEvent_set_terminal() {
let event =
DArgumentOfPerigeeEvent::new(90.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DArgumentOfPerigeeEvent_direction_increasing() {
let event = DArgumentOfPerigeeEvent::new(
90.0,
"AoP",
EventDirection::Increasing,
AngleFormat::Degrees,
);
assert_eq!(event.direction(), EventDirection::Increasing);
}
#[test]
fn test_DArgumentOfPerigeeEvent_direction_decreasing() {
let event = DArgumentOfPerigeeEvent::new(
90.0,
"AoP",
EventDirection::Decreasing,
AngleFormat::Degrees,
);
assert_eq!(event.direction(), EventDirection::Decreasing);
}
#[test]
fn test_DArgumentOfPerigeeEvent_direction_any() {
let event =
DArgumentOfPerigeeEvent::new(90.0, "AoP", EventDirection::Any, AngleFormat::Degrees);
assert_eq!(event.direction(), EventDirection::Any);
}
#[test]
fn test_DArgumentOfPerigeeEvent_builder_chaining() {
let callback: DEventCallback =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = DArgumentOfPerigeeEvent::new(
90.0,
"AoP",
EventDirection::Decreasing,
AngleFormat::Degrees,
)
.with_instance(1)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.1)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "AoP 1");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.step_reduction_factor(), 0.1);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SMeanAnomalyEvent_new() {
let event = SMeanAnomalyEvent::<6, 0>::new(
0.0,
"Periapsis",
EventDirection::Increasing,
AngleFormat::Radians,
);
assert_eq!(event.name(), "Periapsis");
assert_eq!(event.target_value(), 0.0);
}
#[test]
fn test_DMeanAnomalyEvent_new() {
let event =
DMeanAnomalyEvent::new(180.0, "Apoapsis", EventDirection::Any, AngleFormat::Degrees);
assert_eq!(event.name(), "Apoapsis");
}
#[test]
fn test_SMeanAnomalyEvent_with_instance() {
let event =
SMeanAnomalyEvent::<6, 0>::new(0.0, "MA", EventDirection::Any, AngleFormat::Radians)
.with_instance(3);
assert_eq!(event.name(), "MA 3");
}
#[test]
fn test_SMeanAnomalyEvent_with_tolerances() {
let event =
SMeanAnomalyEvent::<6, 0>::new(0.0, "Test", EventDirection::Any, AngleFormat::Radians)
.with_tolerances(1e-4, 1e-6);
assert_eq!(event.time_tolerance(), 1e-4);
assert_eq!(event.value_tolerance(), 1e-6);
}
#[test]
fn test_SMeanAnomalyEvent_with_step_reduction_factor() {
let event =
SMeanAnomalyEvent::<6, 0>::new(0.0, "Test", EventDirection::Any, AngleFormat::Radians)
.with_step_reduction_factor(0.15);
assert_eq!(event.step_reduction_factor(), 0.15);
}
#[test]
fn test_SMeanAnomalyEvent_with_callback() {
let callback: SEventCallback<6, 0> =
Box::new(move |_t, _state, _params| (None, None, EventAction::Continue));
let event =
SMeanAnomalyEvent::<6, 0>::new(0.0, "Test", EventDirection::Any, AngleFormat::Radians)
.with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_SMeanAnomalyEvent_callback_none() {
let event =
SMeanAnomalyEvent::<6, 0>::new(0.0, "Test", EventDirection::Any, AngleFormat::Radians);
assert!(event.callback().is_none());
}
#[test]
fn test_SMeanAnomalyEvent_set_terminal() {
let event =
SMeanAnomalyEvent::<6, 0>::new(0.0, "Test", EventDirection::Any, AngleFormat::Radians)
.set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SMeanAnomalyEvent_direction_increasing() {
let event = SMeanAnomalyEvent::<6, 0>::new(
0.0,
"MA",
EventDirection::Increasing,
AngleFormat::Radians,
);
assert_eq!(event.direction(), EventDirection::Increasing);
}
#[test]
fn test_SMeanAnomalyEvent_direction_decreasing() {
let event = SMeanAnomalyEvent::<6, 0>::new(
0.0,
"MA",
EventDirection::Decreasing,
AngleFormat::Radians,
);
assert_eq!(event.direction(), EventDirection::Decreasing);
}
#[test]
fn test_SMeanAnomalyEvent_direction_any() {
let event =
SMeanAnomalyEvent::<6, 0>::new(0.0, "MA", EventDirection::Any, AngleFormat::Radians);
assert_eq!(event.direction(), EventDirection::Any);
}
#[test]
fn test_SMeanAnomalyEvent_builder_chaining() {
let callback: SEventCallback<6, 0> =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = SMeanAnomalyEvent::<6, 0>::new(
0.0,
"MA",
EventDirection::Increasing,
AngleFormat::Radians,
)
.with_instance(1)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.1)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "MA 1");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.step_reduction_factor(), 0.1);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DMeanAnomalyEvent_with_instance() {
let event = DMeanAnomalyEvent::new(180.0, "MA", EventDirection::Any, AngleFormat::Degrees)
.with_instance(2);
assert_eq!(event.name(), "MA 2");
}
#[test]
fn test_DMeanAnomalyEvent_with_tolerances() {
let event =
DMeanAnomalyEvent::new(180.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.with_tolerances(1e-4, 1e-7);
assert_eq!(event.time_tolerance(), 1e-4);
assert_eq!(event.value_tolerance(), 1e-7);
}
#[test]
fn test_DMeanAnomalyEvent_with_step_reduction_factor() {
let event =
DMeanAnomalyEvent::new(180.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.with_step_reduction_factor(0.25);
assert_eq!(event.step_reduction_factor(), 0.25);
}
#[test]
fn test_DMeanAnomalyEvent_with_callback() {
let callback: DEventCallback =
Box::new(move |_t, _state, _params| (None, None, EventAction::Continue));
let event =
DMeanAnomalyEvent::new(180.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_DMeanAnomalyEvent_callback_none() {
let event =
DMeanAnomalyEvent::new(180.0, "Test", EventDirection::Any, AngleFormat::Degrees);
assert!(event.callback().is_none());
}
#[test]
fn test_DMeanAnomalyEvent_set_terminal() {
let event =
DMeanAnomalyEvent::new(180.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DMeanAnomalyEvent_direction_increasing() {
let event = DMeanAnomalyEvent::new(
180.0,
"MA",
EventDirection::Increasing,
AngleFormat::Degrees,
);
assert_eq!(event.direction(), EventDirection::Increasing);
}
#[test]
fn test_DMeanAnomalyEvent_direction_decreasing() {
let event = DMeanAnomalyEvent::new(
180.0,
"MA",
EventDirection::Decreasing,
AngleFormat::Degrees,
);
assert_eq!(event.direction(), EventDirection::Decreasing);
}
#[test]
fn test_DMeanAnomalyEvent_direction_any() {
let event = DMeanAnomalyEvent::new(180.0, "MA", EventDirection::Any, AngleFormat::Degrees);
assert_eq!(event.direction(), EventDirection::Any);
}
#[test]
fn test_DMeanAnomalyEvent_builder_chaining() {
let callback: DEventCallback =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = DMeanAnomalyEvent::new(
180.0,
"MA",
EventDirection::Decreasing,
AngleFormat::Degrees,
)
.with_instance(1)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.1)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "MA 1");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.step_reduction_factor(), 0.1);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SEccentricAnomalyEvent_new() {
let event = SEccentricAnomalyEvent::<6, 0>::new(
0.0,
"Periapsis EA",
EventDirection::Increasing,
AngleFormat::Radians,
);
assert_eq!(event.name(), "Periapsis EA");
}
#[test]
fn test_DEccentricAnomalyEvent_new() {
let event =
DEccentricAnomalyEvent::new(0.0, "EA Check", EventDirection::Any, AngleFormat::Degrees);
assert_eq!(event.name(), "EA Check");
}
#[test]
fn test_SEccentricAnomalyEvent_with_instance() {
let event = SEccentricAnomalyEvent::<6, 0>::new(
0.0,
"EA",
EventDirection::Any,
AngleFormat::Radians,
)
.with_instance(3);
assert_eq!(event.name(), "EA 3");
}
#[test]
fn test_SEccentricAnomalyEvent_with_tolerances() {
let event = SEccentricAnomalyEvent::<6, 0>::new(
0.0,
"Test",
EventDirection::Any,
AngleFormat::Radians,
)
.with_tolerances(1e-4, 1e-6);
assert_eq!(event.time_tolerance(), 1e-4);
assert_eq!(event.value_tolerance(), 1e-6);
}
#[test]
fn test_SEccentricAnomalyEvent_with_step_reduction_factor() {
let event = SEccentricAnomalyEvent::<6, 0>::new(
0.0,
"Test",
EventDirection::Any,
AngleFormat::Radians,
)
.with_step_reduction_factor(0.15);
assert_eq!(event.step_reduction_factor(), 0.15);
}
#[test]
fn test_SEccentricAnomalyEvent_with_callback() {
let callback: SEventCallback<6, 0> =
Box::new(move |_t, _state, _params| (None, None, EventAction::Continue));
let event = SEccentricAnomalyEvent::<6, 0>::new(
0.0,
"Test",
EventDirection::Any,
AngleFormat::Radians,
)
.with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_SEccentricAnomalyEvent_callback_none() {
let event = SEccentricAnomalyEvent::<6, 0>::new(
0.0,
"Test",
EventDirection::Any,
AngleFormat::Radians,
);
assert!(event.callback().is_none());
}
#[test]
fn test_SEccentricAnomalyEvent_set_terminal() {
let event = SEccentricAnomalyEvent::<6, 0>::new(
0.0,
"Test",
EventDirection::Any,
AngleFormat::Radians,
)
.set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SEccentricAnomalyEvent_direction_increasing() {
let event = SEccentricAnomalyEvent::<6, 0>::new(
0.0,
"EA",
EventDirection::Increasing,
AngleFormat::Radians,
);
assert_eq!(event.direction(), EventDirection::Increasing);
}
#[test]
fn test_SEccentricAnomalyEvent_direction_decreasing() {
let event = SEccentricAnomalyEvent::<6, 0>::new(
0.0,
"EA",
EventDirection::Decreasing,
AngleFormat::Radians,
);
assert_eq!(event.direction(), EventDirection::Decreasing);
}
#[test]
fn test_SEccentricAnomalyEvent_direction_any() {
let event = SEccentricAnomalyEvent::<6, 0>::new(
0.0,
"EA",
EventDirection::Any,
AngleFormat::Radians,
);
assert_eq!(event.direction(), EventDirection::Any);
}
#[test]
fn test_SEccentricAnomalyEvent_builder_chaining() {
let callback: SEventCallback<6, 0> =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = SEccentricAnomalyEvent::<6, 0>::new(
0.0,
"EA",
EventDirection::Increasing,
AngleFormat::Radians,
)
.with_instance(1)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.1)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "EA 1");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.step_reduction_factor(), 0.1);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DEccentricAnomalyEvent_with_instance() {
let event =
DEccentricAnomalyEvent::new(0.0, "EA", EventDirection::Any, AngleFormat::Degrees)
.with_instance(2);
assert_eq!(event.name(), "EA 2");
}
#[test]
fn test_DEccentricAnomalyEvent_with_tolerances() {
let event =
DEccentricAnomalyEvent::new(0.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.with_tolerances(1e-4, 1e-7);
assert_eq!(event.time_tolerance(), 1e-4);
assert_eq!(event.value_tolerance(), 1e-7);
}
#[test]
fn test_DEccentricAnomalyEvent_with_step_reduction_factor() {
let event =
DEccentricAnomalyEvent::new(0.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.with_step_reduction_factor(0.25);
assert_eq!(event.step_reduction_factor(), 0.25);
}
#[test]
fn test_DEccentricAnomalyEvent_with_callback() {
let callback: DEventCallback =
Box::new(move |_t, _state, _params| (None, None, EventAction::Continue));
let event =
DEccentricAnomalyEvent::new(0.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_DEccentricAnomalyEvent_callback_none() {
let event =
DEccentricAnomalyEvent::new(0.0, "Test", EventDirection::Any, AngleFormat::Degrees);
assert!(event.callback().is_none());
}
#[test]
fn test_DEccentricAnomalyEvent_set_terminal() {
let event =
DEccentricAnomalyEvent::new(0.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DEccentricAnomalyEvent_direction_increasing() {
let event = DEccentricAnomalyEvent::new(
0.0,
"EA",
EventDirection::Increasing,
AngleFormat::Degrees,
);
assert_eq!(event.direction(), EventDirection::Increasing);
}
#[test]
fn test_DEccentricAnomalyEvent_direction_decreasing() {
let event = DEccentricAnomalyEvent::new(
0.0,
"EA",
EventDirection::Decreasing,
AngleFormat::Degrees,
);
assert_eq!(event.direction(), EventDirection::Decreasing);
}
#[test]
fn test_DEccentricAnomalyEvent_direction_any() {
let event =
DEccentricAnomalyEvent::new(0.0, "EA", EventDirection::Any, AngleFormat::Degrees);
assert_eq!(event.direction(), EventDirection::Any);
}
#[test]
fn test_DEccentricAnomalyEvent_builder_chaining() {
let callback: DEventCallback =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = DEccentricAnomalyEvent::new(
0.0,
"EA",
EventDirection::Decreasing,
AngleFormat::Degrees,
)
.with_instance(1)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.1)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "EA 1");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.step_reduction_factor(), 0.1);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_STrueAnomalyEvent_new() {
let event = STrueAnomalyEvent::<6, 0>::new(
0.0,
"Periapsis TA",
EventDirection::Increasing,
AngleFormat::Radians,
);
assert_eq!(event.name(), "Periapsis TA");
}
#[test]
fn test_DTrueAnomalyEvent_new() {
let event = DTrueAnomalyEvent::new(
180.0,
"Apoapsis TA",
EventDirection::Any,
AngleFormat::Degrees,
);
assert_eq!(event.name(), "Apoapsis TA");
}
#[test]
fn test_STrueAnomalyEvent_with_instance() {
let event =
STrueAnomalyEvent::<6, 0>::new(0.0, "TA", EventDirection::Any, AngleFormat::Radians)
.with_instance(3);
assert_eq!(event.name(), "TA 3");
}
#[test]
fn test_STrueAnomalyEvent_with_tolerances() {
let event =
STrueAnomalyEvent::<6, 0>::new(0.0, "Test", EventDirection::Any, AngleFormat::Radians)
.with_tolerances(1e-4, 1e-6);
assert_eq!(event.time_tolerance(), 1e-4);
assert_eq!(event.value_tolerance(), 1e-6);
}
#[test]
fn test_STrueAnomalyEvent_with_step_reduction_factor() {
let event =
STrueAnomalyEvent::<6, 0>::new(0.0, "Test", EventDirection::Any, AngleFormat::Radians)
.with_step_reduction_factor(0.15);
assert_eq!(event.step_reduction_factor(), 0.15);
}
#[test]
fn test_STrueAnomalyEvent_with_callback() {
let callback: SEventCallback<6, 0> =
Box::new(move |_t, _state, _params| (None, None, EventAction::Continue));
let event =
STrueAnomalyEvent::<6, 0>::new(0.0, "Test", EventDirection::Any, AngleFormat::Radians)
.with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_STrueAnomalyEvent_callback_none() {
let event =
STrueAnomalyEvent::<6, 0>::new(0.0, "Test", EventDirection::Any, AngleFormat::Radians);
assert!(event.callback().is_none());
}
#[test]
fn test_STrueAnomalyEvent_set_terminal() {
let event =
STrueAnomalyEvent::<6, 0>::new(0.0, "Test", EventDirection::Any, AngleFormat::Radians)
.set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_STrueAnomalyEvent_direction_increasing() {
let event = STrueAnomalyEvent::<6, 0>::new(
0.0,
"TA",
EventDirection::Increasing,
AngleFormat::Radians,
);
assert_eq!(event.direction(), EventDirection::Increasing);
}
#[test]
fn test_STrueAnomalyEvent_direction_decreasing() {
let event = STrueAnomalyEvent::<6, 0>::new(
0.0,
"TA",
EventDirection::Decreasing,
AngleFormat::Radians,
);
assert_eq!(event.direction(), EventDirection::Decreasing);
}
#[test]
fn test_STrueAnomalyEvent_direction_any() {
let event =
STrueAnomalyEvent::<6, 0>::new(0.0, "TA", EventDirection::Any, AngleFormat::Radians);
assert_eq!(event.direction(), EventDirection::Any);
}
#[test]
fn test_STrueAnomalyEvent_builder_chaining() {
let callback: SEventCallback<6, 0> =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = STrueAnomalyEvent::<6, 0>::new(
0.0,
"TA",
EventDirection::Increasing,
AngleFormat::Radians,
)
.with_instance(1)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.1)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "TA 1");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.step_reduction_factor(), 0.1);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DTrueAnomalyEvent_with_instance() {
let event = DTrueAnomalyEvent::new(180.0, "TA", EventDirection::Any, AngleFormat::Degrees)
.with_instance(2);
assert_eq!(event.name(), "TA 2");
}
#[test]
fn test_DTrueAnomalyEvent_with_tolerances() {
let event =
DTrueAnomalyEvent::new(180.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.with_tolerances(1e-4, 1e-7);
assert_eq!(event.time_tolerance(), 1e-4);
assert_eq!(event.value_tolerance(), 1e-7);
}
#[test]
fn test_DTrueAnomalyEvent_with_step_reduction_factor() {
let event =
DTrueAnomalyEvent::new(180.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.with_step_reduction_factor(0.25);
assert_eq!(event.step_reduction_factor(), 0.25);
}
#[test]
fn test_DTrueAnomalyEvent_with_callback() {
let callback: DEventCallback =
Box::new(move |_t, _state, _params| (None, None, EventAction::Continue));
let event =
DTrueAnomalyEvent::new(180.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_DTrueAnomalyEvent_callback_none() {
let event =
DTrueAnomalyEvent::new(180.0, "Test", EventDirection::Any, AngleFormat::Degrees);
assert!(event.callback().is_none());
}
#[test]
fn test_DTrueAnomalyEvent_set_terminal() {
let event =
DTrueAnomalyEvent::new(180.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DTrueAnomalyEvent_direction_increasing() {
let event = DTrueAnomalyEvent::new(
180.0,
"TA",
EventDirection::Increasing,
AngleFormat::Degrees,
);
assert_eq!(event.direction(), EventDirection::Increasing);
}
#[test]
fn test_DTrueAnomalyEvent_direction_decreasing() {
let event = DTrueAnomalyEvent::new(
180.0,
"TA",
EventDirection::Decreasing,
AngleFormat::Degrees,
);
assert_eq!(event.direction(), EventDirection::Decreasing);
}
#[test]
fn test_DTrueAnomalyEvent_direction_any() {
let event = DTrueAnomalyEvent::new(180.0, "TA", EventDirection::Any, AngleFormat::Degrees);
assert_eq!(event.direction(), EventDirection::Any);
}
#[test]
fn test_DTrueAnomalyEvent_builder_chaining() {
let callback: DEventCallback =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = DTrueAnomalyEvent::new(
180.0,
"TA",
EventDirection::Decreasing,
AngleFormat::Degrees,
)
.with_instance(1)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.1)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "TA 1");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.step_reduction_factor(), 0.1);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SArgumentOfLatitudeEvent_new() {
let event = SArgumentOfLatitudeEvent::<6, 0>::new(
0.5,
"AoL Check",
EventDirection::Increasing,
AngleFormat::Radians,
);
assert_eq!(event.name(), "AoL Check");
assert_eq!(event.target_value(), 0.5);
}
#[test]
fn test_DArgumentOfLatitudeEvent_new() {
let event =
DArgumentOfLatitudeEvent::new(30.0, "AoL", EventDirection::Any, AngleFormat::Degrees);
assert_eq!(event.name(), "AoL");
}
#[test]
fn test_SArgumentOfLatitudeEvent_with_instance() {
let event = SArgumentOfLatitudeEvent::<6, 0>::new(
0.5,
"AoL",
EventDirection::Any,
AngleFormat::Radians,
)
.with_instance(3);
assert_eq!(event.name(), "AoL 3");
}
#[test]
fn test_SArgumentOfLatitudeEvent_with_tolerances() {
let event = SArgumentOfLatitudeEvent::<6, 0>::new(
0.5,
"Test",
EventDirection::Any,
AngleFormat::Radians,
)
.with_tolerances(1e-4, 1e-6);
assert_eq!(event.time_tolerance(), 1e-4);
assert_eq!(event.value_tolerance(), 1e-6);
}
#[test]
fn test_SArgumentOfLatitudeEvent_with_step_reduction_factor() {
let event = SArgumentOfLatitudeEvent::<6, 0>::new(
0.5,
"Test",
EventDirection::Any,
AngleFormat::Radians,
)
.with_step_reduction_factor(0.15);
assert_eq!(event.step_reduction_factor(), 0.15);
}
#[test]
fn test_SArgumentOfLatitudeEvent_with_callback() {
let callback: SEventCallback<6, 0> =
Box::new(move |_t, _state, _params| (None, None, EventAction::Continue));
let event = SArgumentOfLatitudeEvent::<6, 0>::new(
0.5,
"Test",
EventDirection::Any,
AngleFormat::Radians,
)
.with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_SArgumentOfLatitudeEvent_callback_none() {
let event = SArgumentOfLatitudeEvent::<6, 0>::new(
0.5,
"Test",
EventDirection::Any,
AngleFormat::Radians,
);
assert!(event.callback().is_none());
}
#[test]
fn test_SArgumentOfLatitudeEvent_set_terminal() {
let event = SArgumentOfLatitudeEvent::<6, 0>::new(
0.5,
"Test",
EventDirection::Any,
AngleFormat::Radians,
)
.set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SArgumentOfLatitudeEvent_direction_increasing() {
let event = SArgumentOfLatitudeEvent::<6, 0>::new(
0.5,
"AoL",
EventDirection::Increasing,
AngleFormat::Radians,
);
assert_eq!(event.direction(), EventDirection::Increasing);
}
#[test]
fn test_SArgumentOfLatitudeEvent_direction_decreasing() {
let event = SArgumentOfLatitudeEvent::<6, 0>::new(
0.5,
"AoL",
EventDirection::Decreasing,
AngleFormat::Radians,
);
assert_eq!(event.direction(), EventDirection::Decreasing);
}
#[test]
fn test_SArgumentOfLatitudeEvent_direction_any() {
let event = SArgumentOfLatitudeEvent::<6, 0>::new(
0.5,
"AoL",
EventDirection::Any,
AngleFormat::Radians,
);
assert_eq!(event.direction(), EventDirection::Any);
}
#[test]
fn test_SArgumentOfLatitudeEvent_builder_chaining() {
let callback: SEventCallback<6, 0> =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = SArgumentOfLatitudeEvent::<6, 0>::new(
0.5,
"AoL",
EventDirection::Increasing,
AngleFormat::Radians,
)
.with_instance(1)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.1)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "AoL 1");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.step_reduction_factor(), 0.1);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DArgumentOfLatitudeEvent_with_instance() {
let event =
DArgumentOfLatitudeEvent::new(30.0, "AoL", EventDirection::Any, AngleFormat::Degrees)
.with_instance(2);
assert_eq!(event.name(), "AoL 2");
}
#[test]
fn test_DArgumentOfLatitudeEvent_with_tolerances() {
let event =
DArgumentOfLatitudeEvent::new(30.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.with_tolerances(1e-4, 1e-7);
assert_eq!(event.time_tolerance(), 1e-4);
assert_eq!(event.value_tolerance(), 1e-7);
}
#[test]
fn test_DArgumentOfLatitudeEvent_with_step_reduction_factor() {
let event =
DArgumentOfLatitudeEvent::new(30.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.with_step_reduction_factor(0.25);
assert_eq!(event.step_reduction_factor(), 0.25);
}
#[test]
fn test_DArgumentOfLatitudeEvent_with_callback() {
let callback: DEventCallback =
Box::new(move |_t, _state, _params| (None, None, EventAction::Continue));
let event =
DArgumentOfLatitudeEvent::new(30.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_DArgumentOfLatitudeEvent_callback_none() {
let event =
DArgumentOfLatitudeEvent::new(30.0, "Test", EventDirection::Any, AngleFormat::Degrees);
assert!(event.callback().is_none());
}
#[test]
fn test_DArgumentOfLatitudeEvent_set_terminal() {
let event =
DArgumentOfLatitudeEvent::new(30.0, "Test", EventDirection::Any, AngleFormat::Degrees)
.set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DArgumentOfLatitudeEvent_direction_increasing() {
let event = DArgumentOfLatitudeEvent::new(
30.0,
"AoL",
EventDirection::Increasing,
AngleFormat::Degrees,
);
assert_eq!(event.direction(), EventDirection::Increasing);
}
#[test]
fn test_DArgumentOfLatitudeEvent_direction_decreasing() {
let event = DArgumentOfLatitudeEvent::new(
30.0,
"AoL",
EventDirection::Decreasing,
AngleFormat::Degrees,
);
assert_eq!(event.direction(), EventDirection::Decreasing);
}
#[test]
fn test_DArgumentOfLatitudeEvent_direction_any() {
let event =
DArgumentOfLatitudeEvent::new(30.0, "AoL", EventDirection::Any, AngleFormat::Degrees);
assert_eq!(event.direction(), EventDirection::Any);
}
#[test]
fn test_DArgumentOfLatitudeEvent_builder_chaining() {
let callback: DEventCallback =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = DArgumentOfLatitudeEvent::new(
30.0,
"AoL",
EventDirection::Decreasing,
AngleFormat::Degrees,
)
.with_instance(1)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.1)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "AoL 1");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.step_reduction_factor(), 0.1);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SAscendingNodeEvent_new() {
let event = SAscendingNodeEvent::<6, 0>::new("Ascending Node");
assert_eq!(event.name(), "Ascending Node");
assert_eq!(event.target_value(), 0.0); assert_eq!(event.direction(), EventDirection::Increasing);
}
#[test]
fn test_SAscendingNodeEvent_builder_chaining() {
let event = SAscendingNodeEvent::<6, 0>::new("Asc Node")
.with_instance(2)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.15);
assert_eq!(event.name(), "Asc Node 2");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.step_reduction_factor(), 0.15);
}
#[test]
fn test_DAscendingNodeEvent_new() {
let event = DAscendingNodeEvent::new("Ascending");
assert_eq!(event.name(), "Ascending");
assert_eq!(event.target_value(), 0.0);
}
#[test]
fn test_SDescendingNodeEvent_new() {
let event = SDescendingNodeEvent::<6, 0>::new("Descending Node");
assert_eq!(event.name(), "Descending Node");
assert_eq!(event.target_value(), 0.0); assert_eq!(event.direction(), EventDirection::Increasing);
}
#[test]
fn test_DDescendingNodeEvent_new() {
let event = DDescendingNodeEvent::new("Descending");
assert_eq!(event.name(), "Descending");
}
#[test]
fn test_SAscendingNodeEvent_with_instance() {
let event = SAscendingNodeEvent::<6, 0>::new("Asc Node").with_instance(3);
assert_eq!(event.name(), "Asc Node 3");
}
#[test]
fn test_SAscendingNodeEvent_with_tolerances() {
let event = SAscendingNodeEvent::<6, 0>::new("Test").with_tolerances(1e-4, 1e-6);
assert_eq!(event.time_tolerance(), 1e-4);
assert_eq!(event.value_tolerance(), 1e-6);
}
#[test]
fn test_SAscendingNodeEvent_with_step_reduction_factor() {
let event = SAscendingNodeEvent::<6, 0>::new("Test").with_step_reduction_factor(0.15);
assert_eq!(event.step_reduction_factor(), 0.15);
}
#[test]
fn test_SAscendingNodeEvent_with_callback() {
let callback: SEventCallback<6, 0> =
Box::new(move |_t, _state, _params| (None, None, EventAction::Continue));
let event = SAscendingNodeEvent::<6, 0>::new("Test").with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_SAscendingNodeEvent_callback_none() {
let event = SAscendingNodeEvent::<6, 0>::new("Test");
assert!(event.callback().is_none());
}
#[test]
fn test_SAscendingNodeEvent_set_terminal() {
let event = SAscendingNodeEvent::<6, 0>::new("Test").set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DAscendingNodeEvent_with_instance() {
let event = DAscendingNodeEvent::new("Asc Node").with_instance(2);
assert_eq!(event.name(), "Asc Node 2");
}
#[test]
fn test_DAscendingNodeEvent_with_tolerances() {
let event = DAscendingNodeEvent::new("Test").with_tolerances(1e-4, 1e-7);
assert_eq!(event.time_tolerance(), 1e-4);
assert_eq!(event.value_tolerance(), 1e-7);
}
#[test]
fn test_DAscendingNodeEvent_with_step_reduction_factor() {
let event = DAscendingNodeEvent::new("Test").with_step_reduction_factor(0.25);
assert_eq!(event.step_reduction_factor(), 0.25);
}
#[test]
fn test_DAscendingNodeEvent_with_callback() {
let callback: DEventCallback =
Box::new(move |_t, _state, _params| (None, None, EventAction::Continue));
let event = DAscendingNodeEvent::new("Test").with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_DAscendingNodeEvent_callback_none() {
let event = DAscendingNodeEvent::new("Test");
assert!(event.callback().is_none());
}
#[test]
fn test_DAscendingNodeEvent_set_terminal() {
let event = DAscendingNodeEvent::new("Test").set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DAscendingNodeEvent_builder_chaining() {
let callback: DEventCallback =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = DAscendingNodeEvent::new("Asc Node")
.with_instance(1)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.1)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "Asc Node 1");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.step_reduction_factor(), 0.1);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SDescendingNodeEvent_with_instance() {
let event = SDescendingNodeEvent::<6, 0>::new("Desc Node").with_instance(3);
assert_eq!(event.name(), "Desc Node 3");
}
#[test]
fn test_SDescendingNodeEvent_with_tolerances() {
let event = SDescendingNodeEvent::<6, 0>::new("Test").with_tolerances(1e-4, 1e-6);
assert_eq!(event.time_tolerance(), 1e-4);
assert_eq!(event.value_tolerance(), 1e-6);
}
#[test]
fn test_SDescendingNodeEvent_with_step_reduction_factor() {
let event = SDescendingNodeEvent::<6, 0>::new("Test").with_step_reduction_factor(0.15);
assert_eq!(event.step_reduction_factor(), 0.15);
}
#[test]
fn test_SDescendingNodeEvent_with_callback() {
let callback: SEventCallback<6, 0> =
Box::new(move |_t, _state, _params| (None, None, EventAction::Continue));
let event = SDescendingNodeEvent::<6, 0>::new("Test").with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_SDescendingNodeEvent_callback_none() {
let event = SDescendingNodeEvent::<6, 0>::new("Test");
assert!(event.callback().is_none());
}
#[test]
fn test_SDescendingNodeEvent_set_terminal() {
let event = SDescendingNodeEvent::<6, 0>::new("Test").set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SDescendingNodeEvent_builder_chaining() {
let callback: SEventCallback<6, 0> =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = SDescendingNodeEvent::<6, 0>::new("Desc Node")
.with_instance(1)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.1)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "Desc Node 1");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.step_reduction_factor(), 0.1);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DDescendingNodeEvent_with_instance() {
let event = DDescendingNodeEvent::new("Desc Node").with_instance(2);
assert_eq!(event.name(), "Desc Node 2");
}
#[test]
fn test_DDescendingNodeEvent_with_tolerances() {
let event = DDescendingNodeEvent::new("Test").with_tolerances(1e-4, 1e-7);
assert_eq!(event.time_tolerance(), 1e-4);
assert_eq!(event.value_tolerance(), 1e-7);
}
#[test]
fn test_DDescendingNodeEvent_with_step_reduction_factor() {
let event = DDescendingNodeEvent::new("Test").with_step_reduction_factor(0.25);
assert_eq!(event.step_reduction_factor(), 0.25);
}
#[test]
fn test_DDescendingNodeEvent_with_callback() {
let callback: DEventCallback =
Box::new(move |_t, _state, _params| (None, None, EventAction::Continue));
let event = DDescendingNodeEvent::new("Test").with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_DDescendingNodeEvent_callback_none() {
let event = DDescendingNodeEvent::new("Test");
assert!(event.callback().is_none());
}
#[test]
fn test_DDescendingNodeEvent_set_terminal() {
let event = DDescendingNodeEvent::new("Test").set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DDescendingNodeEvent_builder_chaining() {
let callback: DEventCallback =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = DDescendingNodeEvent::new("Desc Node")
.with_instance(1)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.1)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "Desc Node 1");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.step_reduction_factor(), 0.1);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SSpeedEvent_new() {
let event = SSpeedEvent::<6, 0>::new(7500.0, "Speed value", EventDirection::Increasing);
assert_eq!(event.name(), "Speed value");
assert_eq!(event.target_value(), 7500.0);
}
#[test]
fn test_SSpeedEvent_evaluate() {
let event = SSpeedEvent::<6, 0>::new(7000.0, "Speed", EventDirection::Any);
let epoch = Epoch::from_jd(2451545.0, TimeSystem::UTC);
let state = Vector6::new(7000e3, 0.0, 0.0, 3000.0, 4000.0, 0.0);
let val = event.evaluate(epoch, &state, None);
assert!((val - 5000.0).abs() < 1e-6);
}
#[test]
fn test_DSpeedEvent_new() {
let event = DSpeedEvent::new(8000.0, "Speed", EventDirection::Decreasing);
assert_eq!(event.name(), "Speed");
assert_eq!(event.target_value(), 8000.0);
}
#[test]
fn test_SSpeedEvent_with_instance() {
let event = SSpeedEvent::<6, 0>::new(7500.0, "Speed", EventDirection::Any).with_instance(3);
assert_eq!(event.name(), "Speed 3");
}
#[test]
fn test_SSpeedEvent_with_tolerances() {
let event = SSpeedEvent::<6, 0>::new(7500.0, "Test", EventDirection::Any)
.with_tolerances(1e-4, 1e-6);
assert_eq!(event.time_tolerance(), 1e-4);
assert_eq!(event.value_tolerance(), 1e-6);
}
#[test]
fn test_SSpeedEvent_with_step_reduction_factor() {
let event = SSpeedEvent::<6, 0>::new(7500.0, "Test", EventDirection::Any)
.with_step_reduction_factor(0.15);
assert_eq!(event.step_reduction_factor(), 0.15);
}
#[test]
fn test_SSpeedEvent_with_callback() {
let callback: SEventCallback<6, 0> =
Box::new(move |_t, _state, _params| (None, None, EventAction::Continue));
let event =
SSpeedEvent::<6, 0>::new(7500.0, "Test", EventDirection::Any).with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_SSpeedEvent_callback_none() {
let event = SSpeedEvent::<6, 0>::new(7500.0, "Test", EventDirection::Any);
assert!(event.callback().is_none());
}
#[test]
fn test_SSpeedEvent_set_terminal() {
let event = SSpeedEvent::<6, 0>::new(7500.0, "Test", EventDirection::Any).set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SSpeedEvent_direction_increasing() {
let event = SSpeedEvent::<6, 0>::new(7500.0, "Speed", EventDirection::Increasing);
assert_eq!(event.direction(), EventDirection::Increasing);
}
#[test]
fn test_SSpeedEvent_direction_decreasing() {
let event = SSpeedEvent::<6, 0>::new(7500.0, "Speed", EventDirection::Decreasing);
assert_eq!(event.direction(), EventDirection::Decreasing);
}
#[test]
fn test_SSpeedEvent_direction_any() {
let event = SSpeedEvent::<6, 0>::new(7500.0, "Speed", EventDirection::Any);
assert_eq!(event.direction(), EventDirection::Any);
}
#[test]
fn test_SSpeedEvent_builder_chaining() {
let callback: SEventCallback<6, 0> =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = SSpeedEvent::<6, 0>::new(7500.0, "Speed", EventDirection::Increasing)
.with_instance(1)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.1)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "Speed 1");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.step_reduction_factor(), 0.1);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DSpeedEvent_evaluate() {
let event = DSpeedEvent::new(7000.0, "Speed", EventDirection::Any);
let epoch = Epoch::from_jd(2451545.0, TimeSystem::UTC);
let state = DVector::from_vec(vec![7000e3, 0.0, 0.0, 3000.0, 4000.0, 0.0]);
let val = event.evaluate(epoch, &state, None);
assert!((val - 5000.0).abs() < 1e-6);
}
#[test]
fn test_DSpeedEvent_with_instance() {
let event = DSpeedEvent::new(7500.0, "Speed", EventDirection::Any).with_instance(2);
assert_eq!(event.name(), "Speed 2");
}
#[test]
fn test_DSpeedEvent_with_tolerances() {
let event =
DSpeedEvent::new(7500.0, "Test", EventDirection::Any).with_tolerances(1e-4, 1e-7);
assert_eq!(event.time_tolerance(), 1e-4);
assert_eq!(event.value_tolerance(), 1e-7);
}
#[test]
fn test_DSpeedEvent_with_step_reduction_factor() {
let event =
DSpeedEvent::new(7500.0, "Test", EventDirection::Any).with_step_reduction_factor(0.25);
assert_eq!(event.step_reduction_factor(), 0.25);
}
#[test]
fn test_DSpeedEvent_with_callback() {
let callback: DEventCallback =
Box::new(move |_t, _state, _params| (None, None, EventAction::Continue));
let event = DSpeedEvent::new(7500.0, "Test", EventDirection::Any).with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_DSpeedEvent_callback_none() {
let event = DSpeedEvent::new(7500.0, "Test", EventDirection::Any);
assert!(event.callback().is_none());
}
#[test]
fn test_DSpeedEvent_set_terminal() {
let event = DSpeedEvent::new(7500.0, "Test", EventDirection::Any).set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DSpeedEvent_direction_increasing() {
let event = DSpeedEvent::new(7500.0, "Speed", EventDirection::Increasing);
assert_eq!(event.direction(), EventDirection::Increasing);
}
#[test]
fn test_DSpeedEvent_direction_decreasing() {
let event = DSpeedEvent::new(7500.0, "Speed", EventDirection::Decreasing);
assert_eq!(event.direction(), EventDirection::Decreasing);
}
#[test]
fn test_DSpeedEvent_direction_any() {
let event = DSpeedEvent::new(7500.0, "Speed", EventDirection::Any);
assert_eq!(event.direction(), EventDirection::Any);
}
#[test]
fn test_DSpeedEvent_builder_chaining() {
let callback: DEventCallback =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = DSpeedEvent::new(7500.0, "Speed", EventDirection::Decreasing)
.with_instance(1)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.1)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "Speed 1");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.step_reduction_factor(), 0.1);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SLongitudeEvent_new() {
setup_global_test_eop();
let event = SLongitudeEvent::<6, 0>::new(
0.0,
"Prime Meridian",
EventDirection::Any,
AngleFormat::Degrees,
);
assert_eq!(event.name(), "Prime Meridian");
assert_eq!(event.target_value(), 0.0);
}
#[test]
fn test_DLongitudeEvent_new() {
setup_global_test_eop();
let event = DLongitudeEvent::new(
45.0,
"Lon Check",
EventDirection::Increasing,
AngleFormat::Degrees,
);
assert_eq!(event.name(), "Lon Check");
}
#[test]
#[serial]
fn test_SLongitudeEvent_evaluate() {
setup_global_test_eop();
let state = Vector6::new(R_EARTH + 500e3, 0.0, 0.0, 0.0, 7612.0, 0.0);
let event = SLongitudeEvent::<6, 0>::new(
0.0,
"Prime Meridian",
EventDirection::Any,
AngleFormat::Degrees,
);
let epoch = Epoch::from_datetime(2024, 1, 1, 0, 0, 0.0, 0.0, TimeSystem::UTC);
let result = event.evaluate(epoch, &state, None);
assert!(result.is_finite());
}
#[test]
fn test_SLongitudeEvent_target_value() {
setup_global_test_eop();
let event = SLongitudeEvent::<6, 0>::new(
45.0,
"Longitude",
EventDirection::Any,
AngleFormat::Degrees,
);
assert_eq!(event.target_value(), 45.0_f64.to_radians());
}
#[test]
fn test_SLongitudeEvent_with_instance() {
setup_global_test_eop();
let event = SLongitudeEvent::<6, 0>::new(
0.0,
"Longitude",
EventDirection::Any,
AngleFormat::Degrees,
)
.with_instance(3);
assert_eq!(event.name(), "Longitude 3");
}
#[test]
fn test_SLongitudeEvent_with_tolerances() {
setup_global_test_eop();
let event = SLongitudeEvent::<6, 0>::new(
0.0,
"Longitude",
EventDirection::Any,
AngleFormat::Degrees,
)
.with_tolerances(1e-6, 1e-9);
assert_eq!(event.time_tolerance(), 1e-6);
assert_eq!(event.value_tolerance(), 1e-9);
}
#[test]
fn test_SLongitudeEvent_time_tolerance() {
setup_global_test_eop();
let event = SLongitudeEvent::<6, 0>::new(
0.0,
"Longitude",
EventDirection::Any,
AngleFormat::Degrees,
);
assert!(event.time_tolerance() > 0.0);
}
#[test]
fn test_SLongitudeEvent_value_tolerance() {
setup_global_test_eop();
let event = SLongitudeEvent::<6, 0>::new(
0.0,
"Longitude",
EventDirection::Any,
AngleFormat::Degrees,
);
assert!(event.value_tolerance() > 0.0);
}
#[test]
fn test_SLongitudeEvent_with_step_reduction_factor() {
setup_global_test_eop();
let event = SLongitudeEvent::<6, 0>::new(
0.0,
"Longitude",
EventDirection::Any,
AngleFormat::Degrees,
)
.with_step_reduction_factor(0.25);
assert_eq!(event.step_reduction_factor(), 0.25);
}
#[test]
fn test_SLongitudeEvent_step_reduction_factor() {
setup_global_test_eop();
let event = SLongitudeEvent::<6, 0>::new(
0.0,
"Longitude",
EventDirection::Any,
AngleFormat::Degrees,
);
assert!(event.step_reduction_factor() > 0.0);
assert!(event.step_reduction_factor() < 1.0);
}
#[test]
fn test_SLongitudeEvent_with_callback() {
setup_global_test_eop();
let callback: SEventCallback<6, 0> =
Box::new(move |_t, _state, _params| (None, None, EventAction::Continue));
let event = SLongitudeEvent::<6, 0>::new(
0.0,
"Longitude",
EventDirection::Any,
AngleFormat::Degrees,
)
.with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_SLongitudeEvent_callback_none() {
setup_global_test_eop();
let event = SLongitudeEvent::<6, 0>::new(
0.0,
"Longitude",
EventDirection::Any,
AngleFormat::Degrees,
);
assert!(event.callback().is_none());
}
#[test]
fn test_SLongitudeEvent_set_terminal() {
setup_global_test_eop();
let event = SLongitudeEvent::<6, 0>::new(
0.0,
"Longitude",
EventDirection::Any,
AngleFormat::Degrees,
)
.set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SLongitudeEvent_action_continue() {
setup_global_test_eop();
let event = SLongitudeEvent::<6, 0>::new(
0.0,
"Longitude",
EventDirection::Any,
AngleFormat::Degrees,
);
assert_eq!(event.action(), EventAction::Continue);
}
#[test]
fn test_SLongitudeEvent_action_stop() {
setup_global_test_eop();
let event = SLongitudeEvent::<6, 0>::new(
0.0,
"Longitude",
EventDirection::Any,
AngleFormat::Degrees,
)
.set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SLongitudeEvent_direction_increasing() {
setup_global_test_eop();
let event = SLongitudeEvent::<6, 0>::new(
0.0,
"Longitude",
EventDirection::Increasing,
AngleFormat::Degrees,
);
assert_eq!(event.direction(), EventDirection::Increasing);
}
#[test]
fn test_SLongitudeEvent_direction_decreasing() {
setup_global_test_eop();
let event = SLongitudeEvent::<6, 0>::new(
0.0,
"Longitude",
EventDirection::Decreasing,
AngleFormat::Degrees,
);
assert_eq!(event.direction(), EventDirection::Decreasing);
}
#[test]
fn test_SLongitudeEvent_direction_any() {
setup_global_test_eop();
let event = SLongitudeEvent::<6, 0>::new(
0.0,
"Longitude",
EventDirection::Any,
AngleFormat::Degrees,
);
assert_eq!(event.direction(), EventDirection::Any);
}
#[test]
fn test_SLongitudeEvent_angle_format_radians() {
setup_global_test_eop();
let event = SLongitudeEvent::<6, 0>::new(
std::f64::consts::FRAC_PI_4,
"Longitude",
EventDirection::Any,
AngleFormat::Radians,
);
assert_eq!(event.target_value(), std::f64::consts::FRAC_PI_4);
}
#[test]
fn test_SLongitudeEvent_builder_chaining() {
setup_global_test_eop();
let callback: SEventCallback<6, 0> =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = SLongitudeEvent::<6, 0>::new(
-74.0,
"NYC Longitude",
EventDirection::Increasing,
AngleFormat::Degrees,
)
.with_instance(1)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.1)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "NYC Longitude 1");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.step_reduction_factor(), 0.1);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
#[serial]
fn test_DLongitudeEvent_evaluate() {
setup_global_test_eop();
let state = DVector::from_vec(vec![R_EARTH + 500e3, 0.0, 0.0, 0.0, 7612.0, 0.0]);
let event =
DLongitudeEvent::new(0.0, "Longitude", EventDirection::Any, AngleFormat::Degrees);
let epoch = Epoch::from_datetime(2024, 1, 1, 0, 0, 0.0, 0.0, TimeSystem::UTC);
let result = event.evaluate(epoch, &state, None);
assert!(result.is_finite());
}
#[test]
fn test_DLongitudeEvent_target_value() {
setup_global_test_eop();
let event =
DLongitudeEvent::new(90.0, "Longitude", EventDirection::Any, AngleFormat::Degrees);
assert_eq!(event.target_value(), 90.0_f64.to_radians());
}
#[test]
fn test_DLongitudeEvent_with_instance() {
setup_global_test_eop();
let event =
DLongitudeEvent::new(0.0, "Longitude", EventDirection::Any, AngleFormat::Degrees)
.with_instance(2);
assert_eq!(event.name(), "Longitude 2");
}
#[test]
fn test_DLongitudeEvent_with_tolerances() {
setup_global_test_eop();
let event =
DLongitudeEvent::new(0.0, "Longitude", EventDirection::Any, AngleFormat::Degrees)
.with_tolerances(1e-6, 1e-9);
assert_eq!(event.time_tolerance(), 1e-6);
assert_eq!(event.value_tolerance(), 1e-9);
}
#[test]
fn test_DLongitudeEvent_time_tolerance() {
setup_global_test_eop();
let event =
DLongitudeEvent::new(0.0, "Longitude", EventDirection::Any, AngleFormat::Degrees);
assert!(event.time_tolerance() > 0.0);
}
#[test]
fn test_DLongitudeEvent_value_tolerance() {
setup_global_test_eop();
let event =
DLongitudeEvent::new(0.0, "Longitude", EventDirection::Any, AngleFormat::Degrees);
assert!(event.value_tolerance() > 0.0);
}
#[test]
fn test_DLongitudeEvent_with_step_reduction_factor() {
setup_global_test_eop();
let event =
DLongitudeEvent::new(0.0, "Longitude", EventDirection::Any, AngleFormat::Degrees)
.with_step_reduction_factor(0.15);
assert_eq!(event.step_reduction_factor(), 0.15);
}
#[test]
fn test_DLongitudeEvent_step_reduction_factor() {
setup_global_test_eop();
let event =
DLongitudeEvent::new(0.0, "Longitude", EventDirection::Any, AngleFormat::Degrees);
assert!(event.step_reduction_factor() > 0.0);
assert!(event.step_reduction_factor() < 1.0);
}
#[test]
fn test_DLongitudeEvent_with_callback() {
setup_global_test_eop();
let callback: DEventCallback =
Box::new(move |_t, _state, _params| (None, None, EventAction::Continue));
let event =
DLongitudeEvent::new(0.0, "Longitude", EventDirection::Any, AngleFormat::Degrees)
.with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_DLongitudeEvent_callback_none() {
setup_global_test_eop();
let event =
DLongitudeEvent::new(0.0, "Longitude", EventDirection::Any, AngleFormat::Degrees);
assert!(event.callback().is_none());
}
#[test]
fn test_DLongitudeEvent_set_terminal() {
setup_global_test_eop();
let event =
DLongitudeEvent::new(0.0, "Longitude", EventDirection::Any, AngleFormat::Degrees)
.set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DLongitudeEvent_action_continue() {
setup_global_test_eop();
let event =
DLongitudeEvent::new(0.0, "Longitude", EventDirection::Any, AngleFormat::Degrees);
assert_eq!(event.action(), EventAction::Continue);
}
#[test]
fn test_DLongitudeEvent_action_stop() {
setup_global_test_eop();
let event =
DLongitudeEvent::new(0.0, "Longitude", EventDirection::Any, AngleFormat::Degrees)
.set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DLongitudeEvent_direction_increasing() {
setup_global_test_eop();
let event = DLongitudeEvent::new(
0.0,
"Longitude",
EventDirection::Increasing,
AngleFormat::Degrees,
);
assert_eq!(event.direction(), EventDirection::Increasing);
}
#[test]
fn test_DLongitudeEvent_direction_decreasing() {
setup_global_test_eop();
let event = DLongitudeEvent::new(
0.0,
"Longitude",
EventDirection::Decreasing,
AngleFormat::Degrees,
);
assert_eq!(event.direction(), EventDirection::Decreasing);
}
#[test]
fn test_DLongitudeEvent_direction_any() {
setup_global_test_eop();
let event =
DLongitudeEvent::new(0.0, "Longitude", EventDirection::Any, AngleFormat::Degrees);
assert_eq!(event.direction(), EventDirection::Any);
}
#[test]
fn test_DLongitudeEvent_angle_format_radians() {
setup_global_test_eop();
let event = DLongitudeEvent::new(
std::f64::consts::PI,
"Longitude",
EventDirection::Any,
AngleFormat::Radians,
);
assert_eq!(event.target_value(), std::f64::consts::PI);
}
#[test]
fn test_DLongitudeEvent_builder_chaining() {
setup_global_test_eop();
let callback: DEventCallback =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = DLongitudeEvent::new(
139.0,
"Tokyo Longitude",
EventDirection::Decreasing,
AngleFormat::Degrees,
)
.with_instance(5)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.2)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "Tokyo Longitude 5");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.step_reduction_factor(), 0.2);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SLatitudeEvent_new() {
setup_global_test_eop();
let event = SLatitudeEvent::<6, 0>::new(
30.0,
"Latitude Check",
EventDirection::Any,
AngleFormat::Degrees,
);
assert_eq!(event.name(), "Latitude Check");
assert_eq!(event.target_value(), 30.0_f64.to_radians());
}
#[test]
fn test_DLatitudeEvent_new() {
setup_global_test_eop();
let event = DLatitudeEvent::new(
0.0,
"Equator",
EventDirection::Increasing,
AngleFormat::Degrees,
);
assert_eq!(event.name(), "Equator");
}
#[test]
#[serial]
fn test_SLatitudeEvent_evaluate() {
setup_global_test_eop();
let state = Vector6::new(6800e3, 0.0, 500e3, 0.0, 7000.0, 1000.0);
let event = SLatitudeEvent::<6, 0>::new(
0.0,
"Equator Crossing",
EventDirection::Any,
AngleFormat::Degrees,
);
let epoch = Epoch::from_datetime(2024, 1, 1, 0, 0, 0.0, 0.0, TimeSystem::UTC);
let result = event.evaluate(epoch, &state, None);
assert!(result.is_finite());
}
#[test]
fn test_SLatitudeEvent_target_value() {
setup_global_test_eop();
let event = SLatitudeEvent::<6, 0>::new(
45.0,
"Latitude",
EventDirection::Any,
AngleFormat::Degrees,
);
assert_eq!(event.target_value(), 45.0_f64.to_radians());
}
#[test]
fn test_SLatitudeEvent_with_instance() {
setup_global_test_eop();
let event =
SLatitudeEvent::<6, 0>::new(0.0, "Latitude", EventDirection::Any, AngleFormat::Degrees)
.with_instance(4);
assert_eq!(event.name(), "Latitude 4");
}
#[test]
fn test_SLatitudeEvent_with_tolerances() {
setup_global_test_eop();
let event =
SLatitudeEvent::<6, 0>::new(0.0, "Latitude", EventDirection::Any, AngleFormat::Degrees)
.with_tolerances(1e-6, 1e-9);
assert_eq!(event.time_tolerance(), 1e-6);
assert_eq!(event.value_tolerance(), 1e-9);
}
#[test]
fn test_SLatitudeEvent_time_tolerance() {
setup_global_test_eop();
let event =
SLatitudeEvent::<6, 0>::new(0.0, "Latitude", EventDirection::Any, AngleFormat::Degrees);
assert!(event.time_tolerance() > 0.0);
}
#[test]
fn test_SLatitudeEvent_value_tolerance() {
setup_global_test_eop();
let event =
SLatitudeEvent::<6, 0>::new(0.0, "Latitude", EventDirection::Any, AngleFormat::Degrees);
assert!(event.value_tolerance() > 0.0);
}
#[test]
fn test_SLatitudeEvent_with_step_reduction_factor() {
setup_global_test_eop();
let event =
SLatitudeEvent::<6, 0>::new(0.0, "Latitude", EventDirection::Any, AngleFormat::Degrees)
.with_step_reduction_factor(0.3);
assert_eq!(event.step_reduction_factor(), 0.3);
}
#[test]
fn test_SLatitudeEvent_step_reduction_factor() {
setup_global_test_eop();
let event =
SLatitudeEvent::<6, 0>::new(0.0, "Latitude", EventDirection::Any, AngleFormat::Degrees);
assert!(event.step_reduction_factor() > 0.0);
assert!(event.step_reduction_factor() < 1.0);
}
#[test]
fn test_SLatitudeEvent_with_callback() {
setup_global_test_eop();
let callback: SEventCallback<6, 0> =
Box::new(move |_t, _state, _params| (None, None, EventAction::Continue));
let event =
SLatitudeEvent::<6, 0>::new(0.0, "Latitude", EventDirection::Any, AngleFormat::Degrees)
.with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_SLatitudeEvent_callback_none() {
setup_global_test_eop();
let event =
SLatitudeEvent::<6, 0>::new(0.0, "Latitude", EventDirection::Any, AngleFormat::Degrees);
assert!(event.callback().is_none());
}
#[test]
fn test_SLatitudeEvent_set_terminal() {
setup_global_test_eop();
let event =
SLatitudeEvent::<6, 0>::new(0.0, "Latitude", EventDirection::Any, AngleFormat::Degrees)
.set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SLatitudeEvent_action_continue() {
setup_global_test_eop();
let event =
SLatitudeEvent::<6, 0>::new(0.0, "Latitude", EventDirection::Any, AngleFormat::Degrees);
assert_eq!(event.action(), EventAction::Continue);
}
#[test]
fn test_SLatitudeEvent_action_stop() {
setup_global_test_eop();
let event =
SLatitudeEvent::<6, 0>::new(0.0, "Latitude", EventDirection::Any, AngleFormat::Degrees)
.set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SLatitudeEvent_direction_increasing() {
setup_global_test_eop();
let event = SLatitudeEvent::<6, 0>::new(
0.0,
"Latitude",
EventDirection::Increasing,
AngleFormat::Degrees,
);
assert_eq!(event.direction(), EventDirection::Increasing);
}
#[test]
fn test_SLatitudeEvent_direction_decreasing() {
setup_global_test_eop();
let event = SLatitudeEvent::<6, 0>::new(
0.0,
"Latitude",
EventDirection::Decreasing,
AngleFormat::Degrees,
);
assert_eq!(event.direction(), EventDirection::Decreasing);
}
#[test]
fn test_SLatitudeEvent_direction_any() {
setup_global_test_eop();
let event =
SLatitudeEvent::<6, 0>::new(0.0, "Latitude", EventDirection::Any, AngleFormat::Degrees);
assert_eq!(event.direction(), EventDirection::Any);
}
#[test]
fn test_SLatitudeEvent_angle_format_radians() {
setup_global_test_eop();
let event = SLatitudeEvent::<6, 0>::new(
std::f64::consts::FRAC_PI_6,
"Latitude",
EventDirection::Any,
AngleFormat::Radians,
);
assert_eq!(event.target_value(), std::f64::consts::FRAC_PI_6);
}
#[test]
fn test_SLatitudeEvent_builder_chaining() {
setup_global_test_eop();
let callback: SEventCallback<6, 0> =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = SLatitudeEvent::<6, 0>::new(
40.7,
"NYC Latitude",
EventDirection::Increasing,
AngleFormat::Degrees,
)
.with_instance(1)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.1)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "NYC Latitude 1");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.step_reduction_factor(), 0.1);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
#[serial]
fn test_DLatitudeEvent_evaluate() {
setup_global_test_eop();
let state = DVector::from_vec(vec![6800e3, 0.0, 500e3, 0.0, 7000.0, 1000.0]);
let event = DLatitudeEvent::new(0.0, "Latitude", EventDirection::Any, AngleFormat::Degrees);
let epoch = Epoch::from_datetime(2024, 1, 1, 0, 0, 0.0, 0.0, TimeSystem::UTC);
let result = event.evaluate(epoch, &state, None);
assert!(result.is_finite());
}
#[test]
fn test_DLatitudeEvent_target_value() {
setup_global_test_eop();
let event =
DLatitudeEvent::new(-30.0, "Latitude", EventDirection::Any, AngleFormat::Degrees);
assert_eq!(event.target_value(), (-30.0_f64).to_radians());
}
#[test]
fn test_DLatitudeEvent_with_instance() {
setup_global_test_eop();
let event = DLatitudeEvent::new(0.0, "Latitude", EventDirection::Any, AngleFormat::Degrees)
.with_instance(7);
assert_eq!(event.name(), "Latitude 7");
}
#[test]
fn test_DLatitudeEvent_with_tolerances() {
setup_global_test_eop();
let event = DLatitudeEvent::new(0.0, "Latitude", EventDirection::Any, AngleFormat::Degrees)
.with_tolerances(1e-6, 1e-9);
assert_eq!(event.time_tolerance(), 1e-6);
assert_eq!(event.value_tolerance(), 1e-9);
}
#[test]
fn test_DLatitudeEvent_time_tolerance() {
setup_global_test_eop();
let event = DLatitudeEvent::new(0.0, "Latitude", EventDirection::Any, AngleFormat::Degrees);
assert!(event.time_tolerance() > 0.0);
}
#[test]
fn test_DLatitudeEvent_value_tolerance() {
setup_global_test_eop();
let event = DLatitudeEvent::new(0.0, "Latitude", EventDirection::Any, AngleFormat::Degrees);
assert!(event.value_tolerance() > 0.0);
}
#[test]
fn test_DLatitudeEvent_with_step_reduction_factor() {
setup_global_test_eop();
let event = DLatitudeEvent::new(0.0, "Latitude", EventDirection::Any, AngleFormat::Degrees)
.with_step_reduction_factor(0.35);
assert_eq!(event.step_reduction_factor(), 0.35);
}
#[test]
fn test_DLatitudeEvent_step_reduction_factor() {
setup_global_test_eop();
let event = DLatitudeEvent::new(0.0, "Latitude", EventDirection::Any, AngleFormat::Degrees);
assert!(event.step_reduction_factor() > 0.0);
assert!(event.step_reduction_factor() < 1.0);
}
#[test]
fn test_DLatitudeEvent_with_callback() {
setup_global_test_eop();
let callback: DEventCallback =
Box::new(move |_t, _state, _params| (None, None, EventAction::Continue));
let event = DLatitudeEvent::new(0.0, "Latitude", EventDirection::Any, AngleFormat::Degrees)
.with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_DLatitudeEvent_callback_none() {
setup_global_test_eop();
let event = DLatitudeEvent::new(0.0, "Latitude", EventDirection::Any, AngleFormat::Degrees);
assert!(event.callback().is_none());
}
#[test]
fn test_DLatitudeEvent_set_terminal() {
setup_global_test_eop();
let event = DLatitudeEvent::new(0.0, "Latitude", EventDirection::Any, AngleFormat::Degrees)
.set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DLatitudeEvent_action_continue() {
setup_global_test_eop();
let event = DLatitudeEvent::new(0.0, "Latitude", EventDirection::Any, AngleFormat::Degrees);
assert_eq!(event.action(), EventAction::Continue);
}
#[test]
fn test_DLatitudeEvent_action_stop() {
setup_global_test_eop();
let event = DLatitudeEvent::new(0.0, "Latitude", EventDirection::Any, AngleFormat::Degrees)
.set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DLatitudeEvent_direction_increasing() {
setup_global_test_eop();
let event = DLatitudeEvent::new(
0.0,
"Latitude",
EventDirection::Increasing,
AngleFormat::Degrees,
);
assert_eq!(event.direction(), EventDirection::Increasing);
}
#[test]
fn test_DLatitudeEvent_direction_decreasing() {
setup_global_test_eop();
let event = DLatitudeEvent::new(
0.0,
"Latitude",
EventDirection::Decreasing,
AngleFormat::Degrees,
);
assert_eq!(event.direction(), EventDirection::Decreasing);
}
#[test]
fn test_DLatitudeEvent_direction_any() {
setup_global_test_eop();
let event = DLatitudeEvent::new(0.0, "Latitude", EventDirection::Any, AngleFormat::Degrees);
assert_eq!(event.direction(), EventDirection::Any);
}
#[test]
fn test_DLatitudeEvent_angle_format_radians() {
setup_global_test_eop();
let event = DLatitudeEvent::new(
std::f64::consts::FRAC_PI_4,
"Latitude",
EventDirection::Any,
AngleFormat::Radians,
);
assert_eq!(event.target_value(), std::f64::consts::FRAC_PI_4);
}
#[test]
fn test_DLatitudeEvent_builder_chaining() {
setup_global_test_eop();
let callback: DEventCallback =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = DLatitudeEvent::new(
35.6,
"Tokyo Latitude",
EventDirection::Decreasing,
AngleFormat::Degrees,
)
.with_instance(3)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.2)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "Tokyo Latitude 3");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.step_reduction_factor(), 0.2);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SUmbraEvent_new_without_source() {
let event = SUmbraEvent::<6, 0>::new("Enter Umbra", EdgeType::RisingEdge, None);
assert_eq!(event.name(), "Enter Umbra");
}
#[test]
fn test_SUmbraEvent_new_with_source() {
let event = SUmbraEvent::<6, 0>::new(
"Umbra DE440s",
EdgeType::FallingEdge,
Some(crate::propagators::EphemerisSource::DE440s),
);
assert_eq!(event.name(), "Umbra DE440s");
}
#[test]
fn test_SUmbraEvent_with_ephemeris_sources() {
use crate::propagators::EphemerisSource;
let event1 = SUmbraEvent::<6, 0>::new(
"Umbra LP",
EdgeType::RisingEdge,
Some(EphemerisSource::LowPrecision),
);
assert_eq!(event1.name(), "Umbra LP");
let event2 = SUmbraEvent::<6, 0>::new(
"Umbra DE440s",
EdgeType::RisingEdge,
Some(EphemerisSource::DE440s),
);
assert_eq!(event2.name(), "Umbra DE440s");
let event3 = SUmbraEvent::<6, 0>::new(
"Umbra DE440",
EdgeType::RisingEdge,
Some(EphemerisSource::DE440),
);
assert_eq!(event3.name(), "Umbra DE440");
}
#[test]
fn test_SUmbraEvent_with_instance() {
let event = SUmbraEvent::<6, 0>::new("Umbra", EdgeType::RisingEdge, None).with_instance(2);
assert_eq!(event.name(), "Umbra 2");
}
#[test]
fn test_SUmbraEvent_with_tolerances() {
let event = SUmbraEvent::<6, 0>::new("Umbra", EdgeType::RisingEdge, None)
.with_tolerances(1e-6, 1e-9);
assert_eq!(event.time_tolerance(), 1e-6);
assert_eq!(event.value_tolerance(), 1e-9);
}
#[test]
fn test_SUmbraEvent_time_tolerance() {
let event = SUmbraEvent::<6, 0>::new("Umbra", EdgeType::RisingEdge, None);
assert!(event.time_tolerance() > 0.0);
}
#[test]
fn test_SUmbraEvent_value_tolerance() {
let event = SUmbraEvent::<6, 0>::new("Umbra", EdgeType::RisingEdge, None);
assert!(event.value_tolerance() > 0.0);
}
#[test]
fn test_SUmbraEvent_with_step_reduction_factor() {
let event = SUmbraEvent::<6, 0>::new("Umbra", EdgeType::RisingEdge, None)
.with_step_reduction_factor(0.2);
assert_eq!(event.step_reduction_factor(), 0.2);
}
#[test]
fn test_SUmbraEvent_step_reduction_factor() {
let event = SUmbraEvent::<6, 0>::new("Umbra", EdgeType::RisingEdge, None);
assert!(event.step_reduction_factor() > 0.0);
assert!(event.step_reduction_factor() < 1.0);
}
#[test]
fn test_SUmbraEvent_with_callback() {
let callback: SEventCallback<6, 0> =
Box::new(move |_t, _state, _params| (None, None, EventAction::Continue));
let event =
SUmbraEvent::<6, 0>::new("Umbra", EdgeType::RisingEdge, None).with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_SUmbraEvent_callback_none() {
let event = SUmbraEvent::<6, 0>::new("Umbra", EdgeType::RisingEdge, None);
assert!(event.callback().is_none());
}
#[test]
fn test_SUmbraEvent_set_terminal() {
let event = SUmbraEvent::<6, 0>::new("Umbra", EdgeType::RisingEdge, None).set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SUmbraEvent_action_continue() {
let event = SUmbraEvent::<6, 0>::new("Umbra", EdgeType::RisingEdge, None);
assert_eq!(event.action(), EventAction::Continue);
}
#[test]
fn test_SUmbraEvent_action_stop() {
let event = SUmbraEvent::<6, 0>::new("Umbra", EdgeType::RisingEdge, None).set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SUmbraEvent_builder_chaining() {
let callback: SEventCallback<6, 0> =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = SUmbraEvent::<6, 0>::new("Umbra", EdgeType::RisingEdge, None)
.with_instance(1)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.1)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "Umbra 1");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.step_reduction_factor(), 0.1);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DUmbraEvent_new() {
let event = DUmbraEvent::new("Umbra", EdgeType::AnyEdge, None);
assert_eq!(event.name(), "Umbra");
}
#[test]
fn test_DUmbraEvent_with_ephemeris_sources() {
use crate::propagators::EphemerisSource;
let event1 = DUmbraEvent::new(
"Umbra LP",
EdgeType::RisingEdge,
Some(EphemerisSource::LowPrecision),
);
assert_eq!(event1.name(), "Umbra LP");
let event2 = DUmbraEvent::new(
"Umbra DE440s",
EdgeType::RisingEdge,
Some(EphemerisSource::DE440s),
);
assert_eq!(event2.name(), "Umbra DE440s");
let event3 = DUmbraEvent::new(
"Umbra DE440",
EdgeType::RisingEdge,
Some(EphemerisSource::DE440),
);
assert_eq!(event3.name(), "Umbra DE440");
}
#[test]
fn test_DUmbraEvent_with_instance() {
let event = DUmbraEvent::new("Umbra", EdgeType::RisingEdge, None).with_instance(3);
assert_eq!(event.name(), "Umbra 3");
}
#[test]
fn test_DUmbraEvent_with_tolerances() {
let event =
DUmbraEvent::new("Umbra", EdgeType::RisingEdge, None).with_tolerances(1e-6, 1e-9);
assert_eq!(event.time_tolerance(), 1e-6);
assert_eq!(event.value_tolerance(), 1e-9);
}
#[test]
fn test_DUmbraEvent_time_tolerance() {
let event = DUmbraEvent::new("Umbra", EdgeType::RisingEdge, None);
assert!(event.time_tolerance() > 0.0);
}
#[test]
fn test_DUmbraEvent_value_tolerance() {
let event = DUmbraEvent::new("Umbra", EdgeType::RisingEdge, None);
assert!(event.value_tolerance() > 0.0);
}
#[test]
fn test_DUmbraEvent_with_step_reduction_factor() {
let event =
DUmbraEvent::new("Umbra", EdgeType::RisingEdge, None).with_step_reduction_factor(0.25);
assert_eq!(event.step_reduction_factor(), 0.25);
}
#[test]
fn test_DUmbraEvent_step_reduction_factor() {
let event = DUmbraEvent::new("Umbra", EdgeType::RisingEdge, None);
assert!(event.step_reduction_factor() > 0.0);
assert!(event.step_reduction_factor() < 1.0);
}
#[test]
fn test_DUmbraEvent_with_callback() {
let callback: DEventCallback =
Box::new(move |_t, _state, _params| (None, None, EventAction::Continue));
let event = DUmbraEvent::new("Umbra", EdgeType::RisingEdge, None).with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_DUmbraEvent_callback_none() {
let event = DUmbraEvent::new("Umbra", EdgeType::RisingEdge, None);
assert!(event.callback().is_none());
}
#[test]
fn test_DUmbraEvent_set_terminal() {
let event = DUmbraEvent::new("Umbra", EdgeType::RisingEdge, None).set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DUmbraEvent_action_continue() {
let event = DUmbraEvent::new("Umbra", EdgeType::RisingEdge, None);
assert_eq!(event.action(), EventAction::Continue);
}
#[test]
fn test_DUmbraEvent_action_stop() {
let event = DUmbraEvent::new("Umbra", EdgeType::RisingEdge, None).set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DUmbraEvent_builder_chaining() {
let callback: DEventCallback =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = DUmbraEvent::new("Umbra", EdgeType::FallingEdge, None)
.with_instance(2)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.15)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "Umbra 2");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.step_reduction_factor(), 0.15);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SPenumbraEvent_new() {
let event = SPenumbraEvent::<6, 0>::new("Penumbra", EdgeType::RisingEdge, None);
assert_eq!(event.name(), "Penumbra");
}
#[test]
fn test_SPenumbraEvent_with_ephemeris_sources() {
use crate::propagators::EphemerisSource;
let event1 = SPenumbraEvent::<6, 0>::new(
"Penumbra LP",
EdgeType::RisingEdge,
Some(EphemerisSource::LowPrecision),
);
assert_eq!(event1.name(), "Penumbra LP");
let event2 = SPenumbraEvent::<6, 0>::new(
"Penumbra DE440s",
EdgeType::RisingEdge,
Some(EphemerisSource::DE440s),
);
assert_eq!(event2.name(), "Penumbra DE440s");
let event3 = SPenumbraEvent::<6, 0>::new(
"Penumbra DE440",
EdgeType::RisingEdge,
Some(EphemerisSource::DE440),
);
assert_eq!(event3.name(), "Penumbra DE440");
}
#[test]
fn test_SPenumbraEvent_with_instance() {
let event =
SPenumbraEvent::<6, 0>::new("Penumbra", EdgeType::RisingEdge, None).with_instance(1);
assert_eq!(event.name(), "Penumbra 1");
}
#[test]
fn test_SPenumbraEvent_with_tolerances() {
let event = SPenumbraEvent::<6, 0>::new("Penumbra", EdgeType::RisingEdge, None)
.with_tolerances(1e-6, 1e-9);
assert_eq!(event.time_tolerance(), 1e-6);
assert_eq!(event.value_tolerance(), 1e-9);
}
#[test]
fn test_SPenumbraEvent_time_tolerance() {
let event = SPenumbraEvent::<6, 0>::new("Penumbra", EdgeType::RisingEdge, None);
assert!(event.time_tolerance() > 0.0);
}
#[test]
fn test_SPenumbraEvent_value_tolerance() {
let event = SPenumbraEvent::<6, 0>::new("Penumbra", EdgeType::RisingEdge, None);
assert!(event.value_tolerance() > 0.0);
}
#[test]
fn test_SPenumbraEvent_with_step_reduction_factor() {
let event = SPenumbraEvent::<6, 0>::new("Penumbra", EdgeType::RisingEdge, None)
.with_step_reduction_factor(0.3);
assert_eq!(event.step_reduction_factor(), 0.3);
}
#[test]
fn test_SPenumbraEvent_step_reduction_factor() {
let event = SPenumbraEvent::<6, 0>::new("Penumbra", EdgeType::RisingEdge, None);
assert!(event.step_reduction_factor() > 0.0);
assert!(event.step_reduction_factor() < 1.0);
}
#[test]
fn test_SPenumbraEvent_with_callback() {
let callback: SEventCallback<6, 0> =
Box::new(move |_t, _state, _params| (None, None, EventAction::Continue));
let event = SPenumbraEvent::<6, 0>::new("Penumbra", EdgeType::RisingEdge, None)
.with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_SPenumbraEvent_callback_none() {
let event = SPenumbraEvent::<6, 0>::new("Penumbra", EdgeType::RisingEdge, None);
assert!(event.callback().is_none());
}
#[test]
fn test_SPenumbraEvent_set_terminal() {
let event =
SPenumbraEvent::<6, 0>::new("Penumbra", EdgeType::RisingEdge, None).set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SPenumbraEvent_action_continue() {
let event = SPenumbraEvent::<6, 0>::new("Penumbra", EdgeType::RisingEdge, None);
assert_eq!(event.action(), EventAction::Continue);
}
#[test]
fn test_SPenumbraEvent_action_stop() {
let event =
SPenumbraEvent::<6, 0>::new("Penumbra", EdgeType::RisingEdge, None).set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SPenumbraEvent_builder_chaining() {
let callback: SEventCallback<6, 0> =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = SPenumbraEvent::<6, 0>::new("Penumbra", EdgeType::AnyEdge, None)
.with_instance(3)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.1)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "Penumbra 3");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.step_reduction_factor(), 0.1);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DPenumbraEvent_new() {
let event = DPenumbraEvent::new("Penumbra", EdgeType::FallingEdge, None);
assert_eq!(event.name(), "Penumbra");
}
#[test]
fn test_DPenumbraEvent_with_ephemeris_sources() {
use crate::propagators::EphemerisSource;
let event1 = DPenumbraEvent::new(
"Penumbra LP",
EdgeType::RisingEdge,
Some(EphemerisSource::LowPrecision),
);
assert_eq!(event1.name(), "Penumbra LP");
let event2 = DPenumbraEvent::new(
"Penumbra DE440s",
EdgeType::RisingEdge,
Some(EphemerisSource::DE440s),
);
assert_eq!(event2.name(), "Penumbra DE440s");
let event3 = DPenumbraEvent::new(
"Penumbra DE440",
EdgeType::RisingEdge,
Some(EphemerisSource::DE440),
);
assert_eq!(event3.name(), "Penumbra DE440");
}
#[test]
fn test_DPenumbraEvent_with_instance() {
let event = DPenumbraEvent::new("Penumbra", EdgeType::RisingEdge, None).with_instance(4);
assert_eq!(event.name(), "Penumbra 4");
}
#[test]
fn test_DPenumbraEvent_with_tolerances() {
let event =
DPenumbraEvent::new("Penumbra", EdgeType::RisingEdge, None).with_tolerances(1e-6, 1e-9);
assert_eq!(event.time_tolerance(), 1e-6);
assert_eq!(event.value_tolerance(), 1e-9);
}
#[test]
fn test_DPenumbraEvent_time_tolerance() {
let event = DPenumbraEvent::new("Penumbra", EdgeType::RisingEdge, None);
assert!(event.time_tolerance() > 0.0);
}
#[test]
fn test_DPenumbraEvent_value_tolerance() {
let event = DPenumbraEvent::new("Penumbra", EdgeType::RisingEdge, None);
assert!(event.value_tolerance() > 0.0);
}
#[test]
fn test_DPenumbraEvent_with_step_reduction_factor() {
let event = DPenumbraEvent::new("Penumbra", EdgeType::RisingEdge, None)
.with_step_reduction_factor(0.35);
assert_eq!(event.step_reduction_factor(), 0.35);
}
#[test]
fn test_DPenumbraEvent_step_reduction_factor() {
let event = DPenumbraEvent::new("Penumbra", EdgeType::RisingEdge, None);
assert!(event.step_reduction_factor() > 0.0);
assert!(event.step_reduction_factor() < 1.0);
}
#[test]
fn test_DPenumbraEvent_with_callback() {
let callback: DEventCallback =
Box::new(move |_t, _state, _params| (None, None, EventAction::Continue));
let event =
DPenumbraEvent::new("Penumbra", EdgeType::RisingEdge, None).with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_DPenumbraEvent_callback_none() {
let event = DPenumbraEvent::new("Penumbra", EdgeType::RisingEdge, None);
assert!(event.callback().is_none());
}
#[test]
fn test_DPenumbraEvent_set_terminal() {
let event = DPenumbraEvent::new("Penumbra", EdgeType::RisingEdge, None).set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DPenumbraEvent_action_continue() {
let event = DPenumbraEvent::new("Penumbra", EdgeType::RisingEdge, None);
assert_eq!(event.action(), EventAction::Continue);
}
#[test]
fn test_DPenumbraEvent_action_stop() {
let event = DPenumbraEvent::new("Penumbra", EdgeType::RisingEdge, None).set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DPenumbraEvent_builder_chaining() {
let callback: DEventCallback =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = DPenumbraEvent::new("Penumbra", EdgeType::FallingEdge, None)
.with_instance(5)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.2)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "Penumbra 5");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.step_reduction_factor(), 0.2);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SEclipseEvent_new() {
let event = SEclipseEvent::<6, 0>::new("Eclipse", EdgeType::AnyEdge, None);
assert_eq!(event.name(), "Eclipse");
}
#[test]
fn test_SEclipseEvent_with_ephemeris_sources() {
use crate::propagators::EphemerisSource;
let event1 = SEclipseEvent::<6, 0>::new(
"Eclipse LP",
EdgeType::RisingEdge,
Some(EphemerisSource::LowPrecision),
);
assert_eq!(event1.name(), "Eclipse LP");
let event2 = SEclipseEvent::<6, 0>::new(
"Eclipse DE440s",
EdgeType::RisingEdge,
Some(EphemerisSource::DE440s),
);
assert_eq!(event2.name(), "Eclipse DE440s");
let event3 = SEclipseEvent::<6, 0>::new(
"Eclipse DE440",
EdgeType::RisingEdge,
Some(EphemerisSource::DE440),
);
assert_eq!(event3.name(), "Eclipse DE440");
}
#[test]
fn test_SEclipseEvent_with_instance() {
let event =
SEclipseEvent::<6, 0>::new("Eclipse", EdgeType::RisingEdge, None).with_instance(1);
assert_eq!(event.name(), "Eclipse 1");
}
#[test]
fn test_SEclipseEvent_with_tolerances() {
let event = SEclipseEvent::<6, 0>::new("Eclipse", EdgeType::RisingEdge, None)
.with_tolerances(1e-6, 1e-9);
assert_eq!(event.time_tolerance(), 1e-6);
assert_eq!(event.value_tolerance(), 1e-9);
}
#[test]
fn test_SEclipseEvent_time_tolerance() {
let event = SEclipseEvent::<6, 0>::new("Eclipse", EdgeType::RisingEdge, None);
assert!(event.time_tolerance() > 0.0);
}
#[test]
fn test_SEclipseEvent_value_tolerance() {
let event = SEclipseEvent::<6, 0>::new("Eclipse", EdgeType::RisingEdge, None);
assert!(event.value_tolerance() > 0.0);
}
#[test]
fn test_SEclipseEvent_with_step_reduction_factor() {
let event = SEclipseEvent::<6, 0>::new("Eclipse", EdgeType::RisingEdge, None)
.with_step_reduction_factor(0.4);
assert_eq!(event.step_reduction_factor(), 0.4);
}
#[test]
fn test_SEclipseEvent_step_reduction_factor() {
let event = SEclipseEvent::<6, 0>::new("Eclipse", EdgeType::RisingEdge, None);
assert!(event.step_reduction_factor() > 0.0);
assert!(event.step_reduction_factor() < 1.0);
}
#[test]
fn test_SEclipseEvent_with_callback() {
let callback: SEventCallback<6, 0> =
Box::new(move |_t, _state, _params| (None, None, EventAction::Continue));
let event = SEclipseEvent::<6, 0>::new("Eclipse", EdgeType::RisingEdge, None)
.with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_SEclipseEvent_callback_none() {
let event = SEclipseEvent::<6, 0>::new("Eclipse", EdgeType::RisingEdge, None);
assert!(event.callback().is_none());
}
#[test]
fn test_SEclipseEvent_set_terminal() {
let event =
SEclipseEvent::<6, 0>::new("Eclipse", EdgeType::RisingEdge, None).set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SEclipseEvent_action_continue() {
let event = SEclipseEvent::<6, 0>::new("Eclipse", EdgeType::RisingEdge, None);
assert_eq!(event.action(), EventAction::Continue);
}
#[test]
fn test_SEclipseEvent_action_stop() {
let event =
SEclipseEvent::<6, 0>::new("Eclipse", EdgeType::RisingEdge, None).set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SEclipseEvent_builder_chaining() {
let callback: SEventCallback<6, 0> =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = SEclipseEvent::<6, 0>::new("Eclipse", EdgeType::AnyEdge, None)
.with_instance(2)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.1)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "Eclipse 2");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.step_reduction_factor(), 0.1);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DEclipseEvent_new() {
let event = DEclipseEvent::new("Eclipse", EdgeType::FallingEdge, None);
assert_eq!(event.name(), "Eclipse");
}
#[test]
fn test_DEclipseEvent_with_ephemeris_sources() {
use crate::propagators::EphemerisSource;
let event1 = DEclipseEvent::new(
"Eclipse LP",
EdgeType::RisingEdge,
Some(EphemerisSource::LowPrecision),
);
assert_eq!(event1.name(), "Eclipse LP");
let event2 = DEclipseEvent::new(
"Eclipse DE440s",
EdgeType::RisingEdge,
Some(EphemerisSource::DE440s),
);
assert_eq!(event2.name(), "Eclipse DE440s");
let event3 = DEclipseEvent::new(
"Eclipse DE440",
EdgeType::RisingEdge,
Some(EphemerisSource::DE440),
);
assert_eq!(event3.name(), "Eclipse DE440");
}
#[test]
fn test_DEclipseEvent_with_instance() {
let event = DEclipseEvent::new("Eclipse", EdgeType::RisingEdge, None).with_instance(6);
assert_eq!(event.name(), "Eclipse 6");
}
#[test]
fn test_DEclipseEvent_with_tolerances() {
let event =
DEclipseEvent::new("Eclipse", EdgeType::RisingEdge, None).with_tolerances(1e-6, 1e-9);
assert_eq!(event.time_tolerance(), 1e-6);
assert_eq!(event.value_tolerance(), 1e-9);
}
#[test]
fn test_DEclipseEvent_time_tolerance() {
let event = DEclipseEvent::new("Eclipse", EdgeType::RisingEdge, None);
assert!(event.time_tolerance() > 0.0);
}
#[test]
fn test_DEclipseEvent_value_tolerance() {
let event = DEclipseEvent::new("Eclipse", EdgeType::RisingEdge, None);
assert!(event.value_tolerance() > 0.0);
}
#[test]
fn test_DEclipseEvent_with_step_reduction_factor() {
let event = DEclipseEvent::new("Eclipse", EdgeType::RisingEdge, None)
.with_step_reduction_factor(0.45);
assert_eq!(event.step_reduction_factor(), 0.45);
}
#[test]
fn test_DEclipseEvent_step_reduction_factor() {
let event = DEclipseEvent::new("Eclipse", EdgeType::RisingEdge, None);
assert!(event.step_reduction_factor() > 0.0);
assert!(event.step_reduction_factor() < 1.0);
}
#[test]
fn test_DEclipseEvent_with_callback() {
let callback: DEventCallback =
Box::new(move |_t, _state, _params| (None, None, EventAction::Continue));
let event =
DEclipseEvent::new("Eclipse", EdgeType::RisingEdge, None).with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_DEclipseEvent_callback_none() {
let event = DEclipseEvent::new("Eclipse", EdgeType::RisingEdge, None);
assert!(event.callback().is_none());
}
#[test]
fn test_DEclipseEvent_set_terminal() {
let event = DEclipseEvent::new("Eclipse", EdgeType::RisingEdge, None).set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DEclipseEvent_action_continue() {
let event = DEclipseEvent::new("Eclipse", EdgeType::RisingEdge, None);
assert_eq!(event.action(), EventAction::Continue);
}
#[test]
fn test_DEclipseEvent_action_stop() {
let event = DEclipseEvent::new("Eclipse", EdgeType::RisingEdge, None).set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DEclipseEvent_builder_chaining() {
let callback: DEventCallback =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = DEclipseEvent::new("Eclipse", EdgeType::FallingEdge, None)
.with_instance(7)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.25)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "Eclipse 7");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.step_reduction_factor(), 0.25);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SSunlitEvent_new() {
let event = SSunlitEvent::<6, 0>::new("Sunlit", EdgeType::RisingEdge, None);
assert_eq!(event.name(), "Sunlit");
}
#[test]
fn test_SSunlitEvent_with_ephemeris_sources() {
use crate::propagators::EphemerisSource;
let event1 = SSunlitEvent::<6, 0>::new(
"Sunlit LP",
EdgeType::RisingEdge,
Some(EphemerisSource::LowPrecision),
);
assert_eq!(event1.name(), "Sunlit LP");
let event2 = SSunlitEvent::<6, 0>::new(
"Sunlit DE440s",
EdgeType::RisingEdge,
Some(EphemerisSource::DE440s),
);
assert_eq!(event2.name(), "Sunlit DE440s");
let event3 = SSunlitEvent::<6, 0>::new(
"Sunlit DE440",
EdgeType::RisingEdge,
Some(EphemerisSource::DE440),
);
assert_eq!(event3.name(), "Sunlit DE440");
}
#[test]
fn test_SSunlitEvent_with_instance() {
let event =
SSunlitEvent::<6, 0>::new("Sunlit", EdgeType::RisingEdge, None).with_instance(1);
assert_eq!(event.name(), "Sunlit 1");
}
#[test]
fn test_SSunlitEvent_with_tolerances() {
let event = SSunlitEvent::<6, 0>::new("Sunlit", EdgeType::RisingEdge, None)
.with_tolerances(1e-6, 1e-9);
assert_eq!(event.time_tolerance(), 1e-6);
assert_eq!(event.value_tolerance(), 1e-9);
}
#[test]
fn test_SSunlitEvent_time_tolerance() {
let event = SSunlitEvent::<6, 0>::new("Sunlit", EdgeType::RisingEdge, None);
assert!(event.time_tolerance() > 0.0);
}
#[test]
fn test_SSunlitEvent_value_tolerance() {
let event = SSunlitEvent::<6, 0>::new("Sunlit", EdgeType::RisingEdge, None);
assert!(event.value_tolerance() > 0.0);
}
#[test]
fn test_SSunlitEvent_with_step_reduction_factor() {
let event = SSunlitEvent::<6, 0>::new("Sunlit", EdgeType::RisingEdge, None)
.with_step_reduction_factor(0.5);
assert_eq!(event.step_reduction_factor(), 0.5);
}
#[test]
fn test_SSunlitEvent_step_reduction_factor() {
let event = SSunlitEvent::<6, 0>::new("Sunlit", EdgeType::RisingEdge, None);
assert!(event.step_reduction_factor() > 0.0);
assert!(event.step_reduction_factor() < 1.0);
}
#[test]
fn test_SSunlitEvent_with_callback() {
let callback: SEventCallback<6, 0> =
Box::new(move |_t, _state, _params| (None, None, EventAction::Continue));
let event =
SSunlitEvent::<6, 0>::new("Sunlit", EdgeType::RisingEdge, None).with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_SSunlitEvent_callback_none() {
let event = SSunlitEvent::<6, 0>::new("Sunlit", EdgeType::RisingEdge, None);
assert!(event.callback().is_none());
}
#[test]
fn test_SSunlitEvent_set_terminal() {
let event = SSunlitEvent::<6, 0>::new("Sunlit", EdgeType::RisingEdge, None).set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SSunlitEvent_action_continue() {
let event = SSunlitEvent::<6, 0>::new("Sunlit", EdgeType::RisingEdge, None);
assert_eq!(event.action(), EventAction::Continue);
}
#[test]
fn test_SSunlitEvent_action_stop() {
let event = SSunlitEvent::<6, 0>::new("Sunlit", EdgeType::RisingEdge, None).set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SSunlitEvent_builder_chaining() {
let callback: SEventCallback<6, 0> =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = SSunlitEvent::<6, 0>::new("Sunlit", EdgeType::AnyEdge, None)
.with_instance(2)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.1)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "Sunlit 2");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.step_reduction_factor(), 0.1);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DSunlitEvent_new() {
let event = DSunlitEvent::new("Sunlit", EdgeType::AnyEdge, None);
assert_eq!(event.name(), "Sunlit");
}
#[test]
fn test_DSunlitEvent_with_ephemeris_sources() {
use crate::propagators::EphemerisSource;
let event1 = DSunlitEvent::new(
"Sunlit LP",
EdgeType::RisingEdge,
Some(EphemerisSource::LowPrecision),
);
assert_eq!(event1.name(), "Sunlit LP");
let event2 = DSunlitEvent::new(
"Sunlit DE440s",
EdgeType::RisingEdge,
Some(EphemerisSource::DE440s),
);
assert_eq!(event2.name(), "Sunlit DE440s");
let event3 = DSunlitEvent::new(
"Sunlit DE440",
EdgeType::RisingEdge,
Some(EphemerisSource::DE440),
);
assert_eq!(event3.name(), "Sunlit DE440");
}
#[test]
fn test_DSunlitEvent_with_instance() {
let event = DSunlitEvent::new("Sunlit", EdgeType::RisingEdge, None).with_instance(8);
assert_eq!(event.name(), "Sunlit 8");
}
#[test]
fn test_DSunlitEvent_with_tolerances() {
let event =
DSunlitEvent::new("Sunlit", EdgeType::RisingEdge, None).with_tolerances(1e-6, 1e-9);
assert_eq!(event.time_tolerance(), 1e-6);
assert_eq!(event.value_tolerance(), 1e-9);
}
#[test]
fn test_DSunlitEvent_time_tolerance() {
let event = DSunlitEvent::new("Sunlit", EdgeType::RisingEdge, None);
assert!(event.time_tolerance() > 0.0);
}
#[test]
fn test_DSunlitEvent_value_tolerance() {
let event = DSunlitEvent::new("Sunlit", EdgeType::RisingEdge, None);
assert!(event.value_tolerance() > 0.0);
}
#[test]
fn test_DSunlitEvent_with_step_reduction_factor() {
let event = DSunlitEvent::new("Sunlit", EdgeType::RisingEdge, None)
.with_step_reduction_factor(0.55);
assert_eq!(event.step_reduction_factor(), 0.55);
}
#[test]
fn test_DSunlitEvent_step_reduction_factor() {
let event = DSunlitEvent::new("Sunlit", EdgeType::RisingEdge, None);
assert!(event.step_reduction_factor() > 0.0);
assert!(event.step_reduction_factor() < 1.0);
}
#[test]
fn test_DSunlitEvent_with_callback() {
let callback: DEventCallback =
Box::new(move |_t, _state, _params| (None, None, EventAction::Continue));
let event = DSunlitEvent::new("Sunlit", EdgeType::RisingEdge, None).with_callback(callback);
assert!(event.callback().is_some());
}
#[test]
fn test_DSunlitEvent_callback_none() {
let event = DSunlitEvent::new("Sunlit", EdgeType::RisingEdge, None);
assert!(event.callback().is_none());
}
#[test]
fn test_DSunlitEvent_set_terminal() {
let event = DSunlitEvent::new("Sunlit", EdgeType::RisingEdge, None).set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DSunlitEvent_action_continue() {
let event = DSunlitEvent::new("Sunlit", EdgeType::RisingEdge, None);
assert_eq!(event.action(), EventAction::Continue);
}
#[test]
fn test_DSunlitEvent_action_stop() {
let event = DSunlitEvent::new("Sunlit", EdgeType::RisingEdge, None).set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DSunlitEvent_builder_chaining() {
let callback: DEventCallback =
Box::new(|_t, _state, _params| (None, None, EventAction::Stop));
let event = DSunlitEvent::new("Sunlit", EdgeType::FallingEdge, None)
.with_instance(9)
.with_tolerances(1e-5, 1e-8)
.with_step_reduction_factor(0.3)
.with_callback(callback)
.set_terminal();
assert_eq!(event.name(), "Sunlit 9");
assert_eq!(event.time_tolerance(), 1e-5);
assert_eq!(event.step_reduction_factor(), 0.3);
assert!(event.callback().is_some());
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SAOIEntryEvent_from_coordinates() {
setup_global_test_eop();
let vertices = vec![
(-10.0, -10.0),
(10.0, -10.0),
(10.0, 10.0),
(-10.0, 10.0),
(-10.0, -10.0), ];
let event =
SAOIEntryEvent::<6, 0>::from_coordinates(&vertices, "AOI Entry", AngleFormat::Degrees);
assert_eq!(event.name(), "AOI Entry");
assert_eq!(event.action(), EventAction::Continue);
}
#[test]
fn test_SAOIEntryEvent_from_polygon() {
setup_global_test_eop();
let polygon = PolygonLocation::new(vec![
Vector3::new(-10.0, -10.0, 0.0),
Vector3::new(10.0, -10.0, 0.0),
Vector3::new(10.0, 10.0, 0.0),
Vector3::new(-10.0, 10.0, 0.0),
Vector3::new(-10.0, -10.0, 0.0),
])
.unwrap();
let event = SAOIEntryEvent::<6, 0>::from_polygon(&polygon, "AOI Entry");
assert_eq!(event.name(), "AOI Entry");
}
#[test]
#[serial]
fn test_SAOIEntryEvent_evaluate_inside() {
setup_global_test_eop();
let vertices = vec![
(60.0, -30.0),
(100.0, -30.0),
(100.0, 30.0),
(60.0, 30.0),
(60.0, -30.0),
];
let event =
SAOIEntryEvent::<6, 0>::from_coordinates(&vertices, "AOI Entry", AngleFormat::Degrees);
let epoch = Epoch::from_jd(2451545.0, TimeSystem::UTC);
let r = R_EARTH + 500e3;
let state_inside = Vector6::new(r, 0.0, 0.0, 0.0, 7.5e3, 0.0);
let val = event.evaluate(epoch, &state_inside, None);
assert!(
val > 0.0,
"Expected positive value for inside AOI, got {}",
val
);
}
#[test]
#[serial]
fn test_SAOIEntryEvent_evaluate_outside() {
setup_global_test_eop();
let vertices = vec![
(-5.0, -5.0),
(5.0, -5.0),
(5.0, 5.0),
(-5.0, 5.0),
(-5.0, -5.0),
];
let event =
SAOIEntryEvent::<6, 0>::from_coordinates(&vertices, "AOI Entry", AngleFormat::Degrees);
let epoch = Epoch::from_jd(2451545.0, TimeSystem::UTC);
let r = R_EARTH + 500e3;
let state_outside = Vector6::new(0.0, r, 0.0, 0.0, -7.5e3, 0.0);
let val = event.evaluate(epoch, &state_outside, None);
assert!(
val < 0.0,
"Expected negative value for outside AOI, got {}",
val
);
}
#[test]
fn test_SAOIEntryEvent_with_instance() {
setup_global_test_eop();
let vertices = vec![
(-10.0, -10.0),
(10.0, -10.0),
(10.0, 10.0),
(-10.0, 10.0),
(-10.0, -10.0),
];
let event =
SAOIEntryEvent::<6, 0>::from_coordinates(&vertices, "AOI Entry", AngleFormat::Degrees)
.with_instance(3);
assert_eq!(event.name(), "AOI Entry 3");
}
#[test]
fn test_SAOIEntryEvent_set_terminal() {
setup_global_test_eop();
let vertices = vec![
(-10.0, -10.0),
(10.0, -10.0),
(10.0, 10.0),
(-10.0, 10.0),
(-10.0, -10.0),
];
let event =
SAOIEntryEvent::<6, 0>::from_coordinates(&vertices, "AOI Entry", AngleFormat::Degrees)
.set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_SAOIEntryEvent_with_tolerances() {
setup_global_test_eop();
let vertices = vec![
(-10.0, -10.0),
(10.0, -10.0),
(10.0, 10.0),
(-10.0, 10.0),
(-10.0, -10.0),
];
let event =
SAOIEntryEvent::<6, 0>::from_coordinates(&vertices, "AOI Entry", AngleFormat::Degrees)
.with_tolerances(1e-4, 1e-6);
assert_eq!(event.time_tolerance(), 1e-4);
}
#[test]
fn test_SAOIEntryEvent_radians_input() {
setup_global_test_eop();
use std::f64::consts::PI;
let vertices = vec![
(-10.0 * PI / 180.0, -10.0 * PI / 180.0),
(10.0 * PI / 180.0, -10.0 * PI / 180.0),
(10.0 * PI / 180.0, 10.0 * PI / 180.0),
(-10.0 * PI / 180.0, 10.0 * PI / 180.0),
(-10.0 * PI / 180.0, -10.0 * PI / 180.0),
];
let event = SAOIEntryEvent::<6, 0>::from_coordinates(
&vertices,
"AOI Entry Radians",
AngleFormat::Radians,
);
assert_eq!(event.name(), "AOI Entry Radians");
}
#[test]
fn test_SAOIExitEvent_from_coordinates() {
setup_global_test_eop();
let vertices = vec![
(-10.0, -10.0),
(10.0, -10.0),
(10.0, 10.0),
(-10.0, 10.0),
(-10.0, -10.0),
];
let event =
SAOIExitEvent::<6, 0>::from_coordinates(&vertices, "AOI Exit", AngleFormat::Degrees);
assert_eq!(event.name(), "AOI Exit");
assert_eq!(event.action(), EventAction::Continue);
}
#[test]
fn test_SAOIExitEvent_from_polygon() {
setup_global_test_eop();
let polygon = PolygonLocation::new(vec![
Vector3::new(-10.0, -10.0, 0.0),
Vector3::new(10.0, -10.0, 0.0),
Vector3::new(10.0, 10.0, 0.0),
Vector3::new(-10.0, 10.0, 0.0),
Vector3::new(-10.0, -10.0, 0.0),
])
.unwrap();
let event = SAOIExitEvent::<6, 0>::from_polygon(&polygon, "AOI Exit");
assert_eq!(event.name(), "AOI Exit");
}
#[test]
#[serial]
fn test_SAOIExitEvent_evaluate_inside() {
setup_global_test_eop();
let vertices = vec![
(60.0, -30.0),
(100.0, -30.0),
(100.0, 30.0),
(60.0, 30.0),
(60.0, -30.0),
];
let event =
SAOIExitEvent::<6, 0>::from_coordinates(&vertices, "AOI Exit", AngleFormat::Degrees);
let epoch = Epoch::from_jd(2451545.0, TimeSystem::UTC);
let r = R_EARTH + 500e3;
let state_inside = Vector6::new(r, 0.0, 0.0, 0.0, 7.5e3, 0.0);
let val = event.evaluate(epoch, &state_inside, None);
assert!(
val > 0.0,
"Expected positive value for inside AOI, got {}",
val
);
}
#[test]
#[serial]
fn test_SAOIExitEvent_evaluate_outside() {
setup_global_test_eop();
let vertices = vec![
(-5.0, -5.0),
(5.0, -5.0),
(5.0, 5.0),
(-5.0, 5.0),
(-5.0, -5.0),
];
let event =
SAOIExitEvent::<6, 0>::from_coordinates(&vertices, "AOI Exit", AngleFormat::Degrees);
let epoch = Epoch::from_jd(2451545.0, TimeSystem::UTC);
let r = R_EARTH + 500e3;
let state_outside = Vector6::new(0.0, r, 0.0, 0.0, -7.5e3, 0.0);
let val = event.evaluate(epoch, &state_outside, None);
assert!(
val < 0.0,
"Expected negative value for outside AOI, got {}",
val
);
}
#[test]
fn test_SAOIExitEvent_with_instance() {
setup_global_test_eop();
let vertices = vec![
(-10.0, -10.0),
(10.0, -10.0),
(10.0, 10.0),
(-10.0, 10.0),
(-10.0, -10.0),
];
let event =
SAOIExitEvent::<6, 0>::from_coordinates(&vertices, "AOI Exit", AngleFormat::Degrees)
.with_instance(5);
assert_eq!(event.name(), "AOI Exit 5");
}
#[test]
fn test_SAOIExitEvent_set_terminal() {
setup_global_test_eop();
let vertices = vec![
(-10.0, -10.0),
(10.0, -10.0),
(10.0, 10.0),
(-10.0, 10.0),
(-10.0, -10.0),
];
let event =
SAOIExitEvent::<6, 0>::from_coordinates(&vertices, "AOI Exit", AngleFormat::Degrees)
.set_terminal();
assert_eq!(event.action(), EventAction::Stop);
}
#[test]
fn test_DAOIEntryEvent_from_coordinates() {
setup_global_test_eop();
let vertices = vec![
(-10.0, -10.0),
(10.0, -10.0),
(10.0, 10.0),
(-10.0, 10.0),
(-10.0, -10.0),
];
let event =
DAOIEntryEvent::from_coordinates(&vertices, "Dynamic AOI Entry", AngleFormat::Degrees);
assert_eq!(event.name(), "Dynamic AOI Entry");
assert_eq!(event.action(), EventAction::Continue);
}
#[test]
fn test_DAOIEntryEvent_from_polygon() {
setup_global_test_eop();
let polygon = PolygonLocation::new(vec![
Vector3::new(-10.0, -10.0, 0.0),
Vector3::new(10.0, -10.0, 0.0),
Vector3::new(10.0, 10.0, 0.0),
Vector3::new(-10.0, 10.0, 0.0),
Vector3::new(-10.0, -10.0, 0.0),
])
.unwrap();
let event = DAOIEntryEvent::from_polygon(&polygon, "Dynamic AOI Entry");
assert_eq!(event.name(), "Dynamic AOI Entry");
}
#[test]
#[serial]
fn test_DAOIEntryEvent_evaluate() {
setup_global_test_eop();
let vertices = vec![
(60.0, -30.0),
(100.0, -30.0),
(100.0, 30.0),
(60.0, 30.0),
(60.0, -30.0),
];
let event =
DAOIEntryEvent::from_coordinates(&vertices, "Dynamic AOI Entry", AngleFormat::Degrees);
let epoch = Epoch::from_jd(2451545.0, TimeSystem::UTC);
let r = R_EARTH + 500e3;
let state_inside = DVector::from_vec(vec![r, 0.0, 0.0, 0.0, 7.5e3, 0.0]);
let val = event.evaluate(epoch, &state_inside, None);
assert!(
val > 0.0,
"Expected positive value for inside AOI, got {}",
val
);
let state_outside = DVector::from_vec(vec![0.0, 0.0, r, 0.0, 7.5e3, 0.0]);
let val = event.evaluate(epoch, &state_outside, None);
assert!(
val < 0.0,
"Expected negative value for outside AOI, got {}",
val
);
}
#[test]
fn test_DAOIEntryEvent_with_instance() {
setup_global_test_eop();
let vertices = vec![
(-10.0, -10.0),
(10.0, -10.0),
(10.0, 10.0),
(-10.0, 10.0),
(-10.0, -10.0),
];
let event =
DAOIEntryEvent::from_coordinates(&vertices, "Dynamic AOI Entry", AngleFormat::Degrees)
.with_instance(2);
assert_eq!(event.name(), "Dynamic AOI Entry 2");
}
#[test]
fn test_DAOIExitEvent_from_coordinates() {
setup_global_test_eop();
let vertices = vec![
(-10.0, -10.0),
(10.0, -10.0),
(10.0, 10.0),
(-10.0, 10.0),
(-10.0, -10.0),
];
let event =
DAOIExitEvent::from_coordinates(&vertices, "Dynamic AOI Exit", AngleFormat::Degrees);
assert_eq!(event.name(), "Dynamic AOI Exit");
assert_eq!(event.action(), EventAction::Continue);
}
#[test]
fn test_DAOIExitEvent_from_polygon() {
setup_global_test_eop();
let polygon = PolygonLocation::new(vec![
Vector3::new(-10.0, -10.0, 0.0),
Vector3::new(10.0, -10.0, 0.0),
Vector3::new(10.0, 10.0, 0.0),
Vector3::new(-10.0, 10.0, 0.0),
Vector3::new(-10.0, -10.0, 0.0),
])
.unwrap();
let event = DAOIExitEvent::from_polygon(&polygon, "Dynamic AOI Exit");
assert_eq!(event.name(), "Dynamic AOI Exit");
}
#[test]
#[serial]
fn test_DAOIExitEvent_evaluate() {
setup_global_test_eop();
let vertices = vec![
(60.0, -30.0),
(100.0, -30.0),
(100.0, 30.0),
(60.0, 30.0),
(60.0, -30.0),
];
let event =
DAOIExitEvent::from_coordinates(&vertices, "Dynamic AOI Exit", AngleFormat::Degrees);
let epoch = Epoch::from_jd(2451545.0, TimeSystem::UTC);
let r = R_EARTH + 500e3;
let state_inside = DVector::from_vec(vec![r, 0.0, 0.0, 0.0, 7.5e3, 0.0]);
let val = event.evaluate(epoch, &state_inside, None);
assert!(
val > 0.0,
"Expected positive value for inside AOI, got {}",
val
);
let state_outside = DVector::from_vec(vec![0.0, 0.0, r, 0.0, 7.5e3, 0.0]);
let val = event.evaluate(epoch, &state_outside, None);
assert!(
val < 0.0,
"Expected negative value for outside AOI, got {}",
val
);
}
#[test]
fn test_DAOIExitEvent_with_instance() {
setup_global_test_eop();
let vertices = vec![
(-10.0, -10.0),
(10.0, -10.0),
(10.0, 10.0),
(-10.0, 10.0),
(-10.0, -10.0),
];
let event =
DAOIExitEvent::from_coordinates(&vertices, "Dynamic AOI Exit", AngleFormat::Degrees)
.with_instance(4);
assert_eq!(event.name(), "Dynamic AOI Exit 4");
}
#[test]
fn test_SAOIEntryEvent_antimeridian() {
setup_global_test_eop();
let vertices = vec![
(170.0, -10.0),
(-170.0, -10.0), (-170.0, 10.0),
(170.0, 10.0),
(170.0, -10.0),
];
let event = SAOIEntryEvent::<6, 0>::from_coordinates(
&vertices,
"Pacific AOI",
AngleFormat::Degrees,
);
assert_eq!(event.name(), "Pacific AOI");
}
#[test]
fn test_SAOIExitEvent_antimeridian() {
setup_global_test_eop();
let vertices = vec![
(170.0, -10.0),
(-170.0, -10.0),
(-170.0, 10.0),
(170.0, 10.0),
(170.0, -10.0),
];
let event = SAOIExitEvent::<6, 0>::from_coordinates(
&vertices,
"Pacific AOI Exit",
AngleFormat::Degrees,
);
assert_eq!(event.name(), "Pacific AOI Exit");
}
}