use super::propagator::SimpleState;
use super::thrust::ThrustProfile;
use crate::mathtypes::*;
use crate::Instant;
pub trait SatProperties {
fn cd_a_over_m(&self, tm: &Instant, state: &SimpleState) -> f64;
fn cr_a_over_m(&self, tm: &Instant, state: &SimpleState) -> f64;
fn thrust_accel(&self, _tm: &Instant, _pos_gcrf: &Vector3, _vel_gcrf: &Vector3) -> Option<Vector3> {
None
}
}
#[derive(Debug, Clone)]
pub struct SatPropertiesSimple {
pub cdaoverm: f64,
pub craoverm: f64,
pub thrust: ThrustProfile,
}
impl SatPropertiesSimple {
pub fn new(cdaoverm: f64, craoverm: f64) -> Self {
Self {
cdaoverm,
craoverm,
thrust: ThrustProfile {
thrusts: Vec::new(),
},
}
}
pub fn with_thrust(mut self, thrust: ThrustProfile) -> Self {
self.thrust = thrust;
self
}
}
impl Default for SatPropertiesSimple {
fn default() -> Self {
Self {
cdaoverm: 0.0,
craoverm: 0.0,
thrust: ThrustProfile::default(),
}
}
}
impl std::fmt::Display for SatPropertiesSimple {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(
f,
r#"Static Sat Properties:
Cd A / M : {} m^2/kg
Cr A / M : {} m^2/kg
Thrust arcs : {}"#,
self.cdaoverm,
self.craoverm,
self.thrust.thrusts.len(),
)
}
}
impl SatProperties for SatPropertiesSimple {
fn cd_a_over_m(&self, _tm: &Instant, _state: &SimpleState) -> f64 {
self.cdaoverm
}
fn cr_a_over_m(&self, _tm: &Instant, _state: &SimpleState) -> f64 {
self.craoverm
}
fn thrust_accel(&self, tm: &Instant, pos_gcrf: &Vector3, vel_gcrf: &Vector3) -> Option<Vector3> {
if self.thrust.is_empty() {
None
} else {
self.thrust.accel_gcrf(tm, pos_gcrf, vel_gcrf)
}
}
}