From be100861ceba850ca77f35cddaafbdc9941026ef Mon Sep 17 00:00:00 2001 From: Helge Eichhorn Date: Tue, 17 Dec 2024 22:42:39 +0100 Subject: [PATCH] WIP --- crates/lox-bodies/src/lib.rs | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/crates/lox-bodies/src/lib.rs b/crates/lox-bodies/src/lib.rs index 3bf1a868..e305c7ab 100644 --- a/crates/lox-bodies/src/lib.rs +++ b/crates/lox-bodies/src/lib.rs @@ -167,17 +167,6 @@ struct NutationPrecessionCoefficients { theta1: [f64; N], } -impl NutationPrecessionCoefficients { - fn theta(&self, t: f64) -> Vec { - let t = t / SECONDS_PER_JULIAN_CENTURY; - self.theta0 - .iter() - .enumerate() - .map(|(i, &theta0)| theta0 + self.theta1[i] * t) - .collect() - } -} - pub(crate) struct RotationalElement { typ: RotationalElementType, c0: f64, @@ -193,12 +182,16 @@ impl RotationalElement { t: f64, ) -> f64 { let Some(nut_prec) = nut_prec else { return 0.0 }; - let theta = nut_prec.theta(t); self.c .map(|c| { c.iter() - .zip(theta.iter()) - .map(|(&c, &theta)| c * self.typ.sincos(theta)) + .zip(nut_prec.theta0.iter()) + .zip(nut_prec.theta1.iter()) + .map(|((&c, &theta0), &theta1)| { + c * self + .typ + .sincos(theta0 + theta1 * t / SECONDS_PER_JULIAN_CENTURY) + }) .sum() }) .unwrap_or_default() @@ -210,14 +203,16 @@ impl RotationalElement { t: f64, ) -> f64 { let Some(nut_prec) = nut_prec else { return 0.0 }; - let theta = nut_prec.theta(t); self.c .map(|c| { c.iter() + .zip(nut_prec.theta0.iter()) .zip(nut_prec.theta1.iter()) - .zip(theta.iter()) - .map(|((&c, &theta1), &theta)| { - c * theta1 / SECONDS_PER_JULIAN_CENTURY * self.typ.sincos_dot(theta) + .map(|((&c, &theta0), &theta1)| { + c * theta1 / SECONDS_PER_JULIAN_CENTURY + * self + .typ + .sincos_dot(theta0 + theta1 * t / SECONDS_PER_JULIAN_CENTURY) }) .sum() })