pub const RHO_EARTH: f64 = 5517.0;
pub const RHO_WATER: f64 = 1000.0;
#[derive(Clone, Copy, Debug)]
pub enum Functional<'a> {
Potential,
GeoidHeight,
GravityDisturbance,
GravityAnomaly,
RadialGradient,
WaterHeight {
love: &'a [f64],
},
}
impl Functional<'_> {
pub fn factor(&self, n: usize, gm: f64, radius: f64, r: f64) -> f64 {
let q = (radius / r).powi(n as i32);
let nf = n as f64;
match self {
Functional::Potential => gm / r * q,
Functional::GeoidHeight => r * q,
Functional::GravityDisturbance => gm / (r * r) * (nf + 1.0) * q,
Functional::GravityAnomaly => gm / (r * r) * (nf - 1.0) * q,
Functional::RadialGradient => gm / (r * r * r) * (nf + 1.0) * (nf + 2.0) * q,
Functional::WaterHeight { love } => {
radius * RHO_EARTH / (3.0 * RHO_WATER) * (2.0 * nf + 1.0) / (1.0 + love[n])
}
}
}
}