#[cfg(not(feature = "std"))]
use num_traits::Float;
#[cfg(not(feature = "std"))]
use num_traits::Euclid;
#[derive(Clone, Copy)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Geopotential {
pub ae: f64,
pub ke: f64,
pub j2: f64,
pub j3: f64,
pub j4: f64,
}
pub const WGS84: Geopotential = Geopotential {
ae: 6378.137,
ke: 0.07436685316871385,
j2: 0.00108262998905,
j3: -0.00000253215306,
j4: -0.00000161098761,
};
pub const WGS72: Geopotential = Geopotential {
ae: 6378.135,
ke: 0.07436691613317342,
j2: 0.001082616,
j3: -0.00000253881,
j4: -0.00000165597,
};
pub fn iau_epoch_to_sidereal_time(epoch: f64) -> f64 {
let c2000 = epoch / 100.0;
((-6.2e-6 * c2000.powi(3)
+ 0.093104 * c2000.powi(2)
+ (876600.0 * 3600.0 + 8640184.812866) * c2000
+ 67310.54841)
* (core::f64::consts::PI / 180.0)
/ 240.0)
.rem_euclid({
#[cfg(feature = "std")]
{
2.0 * core::f64::consts::PI
}
#[cfg(not(feature = "std"))]
{
&(2.0 * core::f64::consts::PI)
}
})
}
pub fn afspc_epoch_to_sidereal_time(epoch: f64) -> f64 {
let d1970 = (epoch + 30.0) * 365.25 + 1.0;
#[allow(clippy::excessive_precision)]
(1.7321343856509374
+ 1.72027916940703639e-2 * (d1970 + 1.0e-8).floor()
+ (1.72027916940703639e-2 + 2.0 * core::f64::consts::PI)
* (d1970 - (d1970 + 1.0e-8).floor())
+ d1970.powi(2) * 5.07551419432269442e-15)
.rem_euclid({
#[cfg(feature = "std")]
{
2.0 * core::f64::consts::PI
}
#[cfg(not(feature = "std"))]
{
&(2.0 * core::f64::consts::PI)
}
})
}