Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
helgee committed Dec 17, 2024
1 parent 6d151d4 commit be10086
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions crates/lox-bodies/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,6 @@ struct NutationPrecessionCoefficients<const N: usize> {
theta1: [f64; N],
}

impl<const N: usize> NutationPrecessionCoefficients<N> {
fn theta(&self, t: f64) -> Vec<f64> {
let t = t / SECONDS_PER_JULIAN_CENTURY;
self.theta0
.iter()
.enumerate()
.map(|(i, &theta0)| theta0 + self.theta1[i] * t)
.collect()
}
}

pub(crate) struct RotationalElement<const N: usize> {
typ: RotationalElementType,
c0: f64,
Expand All @@ -193,12 +182,16 @@ impl<const N: usize> RotationalElement<N> {
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()
Expand All @@ -210,14 +203,16 @@ impl<const N: usize> RotationalElement<N> {
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()
})
Expand Down

0 comments on commit be10086

Please sign in to comment.