-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
421 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (c) 2024. Helge Eichhorn and the LOX contributors | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, you can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
use crate::frames::{BodyFixed, FrameTransformationProvider, Icrf, TryRotateTo}; | ||
use crate::rotations::Rotation; | ||
use glam::{DMat3, DVec3}; | ||
use lox_bodies::{MaybeRotationalElements, RotationalElements}; | ||
use lox_math::types::units::Seconds; | ||
use lox_time::prelude::Tdb; | ||
use lox_time::TimeLike; | ||
|
||
pub(crate) fn icrf_to_bodyfixed<T: MaybeRotationalElements>( | ||
body: &T, | ||
seconds: Seconds, | ||
) -> Option<Rotation> { | ||
let (Some((right_ascension, declination, prime_meridian)), Some(rates)) = ( | ||
body.maybe_rotational_elements(seconds), | ||
body.maybe_rotational_element_rates(seconds), | ||
) else { | ||
return None; | ||
}; | ||
let m1 = DMat3::from_rotation_z(-right_ascension); | ||
let m2 = DMat3::from_rotation_x(-declination); | ||
let m3 = DMat3::from_rotation_z(-prime_meridian); | ||
let m = m3 * m2 * m1; | ||
let v = DVec3::from(rates); | ||
Some(Rotation::new(m).with_angular_velocity(v)) | ||
} | ||
|
||
impl<O: RotationalElements, P: FrameTransformationProvider> TryRotateTo<BodyFixed<O>, P> for Icrf { | ||
type Error = (); | ||
|
||
fn try_rotation<T: TimeLike>( | ||
&self, | ||
frame: &BodyFixed<O>, | ||
time: T, | ||
provider: &P, | ||
) -> Result<Rotation, Self::Error> { | ||
// FIXME | ||
let seconds = time.seconds_since_j2000(); | ||
Ok(icrf_to_bodyfixed(&frame.0, seconds).unwrap()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.