Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added additional test for roundtrip from state vector to string tle #24

Merged
merged 2 commits into from
Mar 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,4 +545,34 @@ mod tests {
);
Ok(())
}

#[test]
#[cfg(feature = "tlegen")]
fn test_can_roundtrip_state_vector_plus_epoch_to_tle() -> Result<()> {
use float_cmp::assert_approx_eq;

let epoch = Utc.with_ymd_and_hms(2021, 5, 25, 0, 0, 0).unwrap();
let r_1 = [
-3767.0783048821595,
-5832.3746513067335,
0.013350841794354097,
];
let v_1 = [5.087843659697572, -3.2858873951805836, 4.561428718239809];
let svector = StateVector::new(epoch, r_1, v_1);
let tle_string = svector.coe.as_tle_at(0, epoch);
let svector_2 = TwoLineElement::from_lines(&tle_string)?.propagate_to(epoch)?;
let r_2 = svector_2.position;
let v_2 = svector_2.velocity;
println!("r_1:{:?}", r_1);
println!("r_2:{:?}", r_2);
println!("v_1:{:?}", v_1);
println!("v_2:{:?}", v_2);
assert_approx_eq!(f64, r_1[0], r_2[0], epsilon = 10.);
assert_approx_eq!(f64, r_1[1], r_2[1], epsilon = 10.);
assert_approx_eq!(f64, r_1[2], r_2[2], epsilon = 10.);
assert_approx_eq!(f64, v_1[0], v_2[0], epsilon = 0.01);
assert_approx_eq!(f64, v_1[1], v_2[1], epsilon = 0.01);
assert_approx_eq!(f64, v_1[2], v_2[2], epsilon = 0.01);
Ok(())
}
}