Skip to content

Commit 4ce7541

Browse files
committed
Use body defs from lox_core and futz with (C)
1 parent b88295e commit 4ce7541

File tree

39 files changed

+337
-297
lines changed

39 files changed

+337
-297
lines changed

.idea/copyright/Lox.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/lox-space/examples/iss.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

99
use lox_space::prelude::*;

crates/lox-space/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

99
pub mod prelude;

crates/lox-space/src/prelude.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

99
pub use lox_core::bodies::barycenters::*;

crates/lox_core/benches/iau_frames.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, you can obtain one at http://mozilla.org/MPL/2.0/.
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

99
use divan::Bencher;

crates/lox_core/src/bin/lox.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

99
use lox_core::bodies::{Body, MercuryBarycenter};

crates/lox_core/src/bodies.rs

+32-14
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, you can obtain one at http://mozilla.org/MPL/2.0/.
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

99
use std::f64::consts::PI;
@@ -42,7 +42,13 @@ macro_rules! body {
4242
}
4343

4444
fn name(&self) -> &'static str {
45-
stringify!($ident)
45+
stringify!($i)
46+
}
47+
}
48+
49+
impl Display for $i {
50+
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
51+
write!(f, "{}", self.name())
4652
}
4753
}
4854
};
@@ -59,6 +65,12 @@ macro_rules! body {
5965
$name
6066
}
6167
}
68+
69+
impl Display for $i {
70+
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
71+
write!(f, "{}", self.name())
72+
}
73+
}
6274
};
6375
}
6476

@@ -659,18 +671,7 @@ mod tests {
659671
// Jupiter is manually redefined here using known data. This avoids a dependency on the
660672
// correctness of the PCK parser to test RotationalElements, and prevents compiler errors
661673
// when generated files are malformed or deleted in preparation for regeneration.
662-
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
663-
struct Jupiter;
664-
665-
impl Body for Jupiter {
666-
fn id(&self) -> NaifId {
667-
NaifId(599)
668-
}
669-
670-
fn name(&self) -> &'static str {
671-
"Jupiter"
672-
}
673-
}
674+
body! { Jupiter, 599 }
674675

675676
impl PointMass for Jupiter {
676677
fn gravitational_parameter() -> f64 {
@@ -788,6 +789,23 @@ mod tests {
788789
);
789790
}
790791

792+
body! { Rupert, "Persephone/Rupert", 1099 }
793+
794+
#[test]
795+
fn test_body() {
796+
let body = Jupiter;
797+
let id = body.id().0;
798+
let name = body.name();
799+
assert_eq!(id, 599);
800+
assert_eq!(name, "Jupiter");
801+
802+
let body = Rupert;
803+
let id = body.id().0;
804+
let name = body.name();
805+
assert_eq!(id, 1099);
806+
assert_eq!(name, "Persephone/Rupert");
807+
}
808+
791809
#[test]
792810
fn test_naif_id() {
793811
let id = NaifId(0);

crates/lox_core/src/bodies/generated/barycenters.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, you can obtain one at http://mozilla.org/MPL/2.0/.
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

99
// Auto-generated by `lox_gen`. Do not edit!

crates/lox_core/src/bodies/generated/minor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, you can obtain one at http://mozilla.org/MPL/2.0/.
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

99
// Auto-generated by `lox_gen`. Do not edit!

crates/lox_core/src/bodies/generated/planets.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, you can obtain one at http://mozilla.org/MPL/2.0/.
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

99
// Auto-generated by `lox_gen`. Do not edit!

crates/lox_core/src/bodies/generated/satellites.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, you can obtain one at http://mozilla.org/MPL/2.0/.
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

99
// Auto-generated by `lox_gen`. Do not edit!

crates/lox_core/src/bodies/generated/sun.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, you can obtain one at http://mozilla.org/MPL/2.0/.
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

99
// Auto-generated by `lox_gen`. Do not edit!

crates/lox_core/src/communications.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

99
pub mod antennae;

crates/lox_core/src/communications/antennae.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

99
use std::f64::consts::PI;

crates/lox_core/src/ephemeris.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1+
/*
2+
* Copyright (c) 2023. Helge Eichhorn and the LOX contributors
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
7+
*/
8+
19
pub mod daf_spk;
+8
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
1+
/*
2+
* Copyright (c) 2023. Helge Eichhorn and the LOX contributors
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
7+
*/
8+
19
pub mod api;
210
pub mod parser;

crates/lox_core/src/ephemeris/daf_spk/api.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/*
2+
* Copyright (c) 2023. Helge Eichhorn and the LOX contributors
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
7+
*/
8+
19
use std::collections::HashMap;
210

311
use super::parser::{DafSpkError, Spk, SpkSegment, SpkType2Array, SpkType2Coefficients};

crates/lox_core/src/ephemeris/daf_spk/parser.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/*
2+
* Copyright (c) 2023. Helge Eichhorn and the LOX contributors
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
7+
*/
8+
19
use std::collections::HashMap;
210
use std::iter::zip;
311

crates/lox_core/src/errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

99
use thiserror::Error;

crates/lox_core/src/frames.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, you can obtain one at http://mozilla.org/MPL/2.0/.
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

99
use std::fmt::{Debug, Display, Formatter};

crates/lox_core/src/frames/iau.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, you can obtain one at http://mozilla.org/MPL/2.0/.
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

99
use std::fmt::Debug;

crates/lox_core/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

99
pub mod bodies;

crates/lox_core/src/time.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, you can obtain one at http://mozilla.org/MPL/2.0/.
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

99
pub mod constants;

crates/lox_core/src/time/constants.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, you can obtain one at http://mozilla.org/MPL/2.0/.
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

99
pub mod f64;

crates/lox_core/src/time/constants/f64.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, you can obtain one at http://mozilla.org/MPL/2.0/.
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

99
pub const SECONDS_PER_MINUTE: f64 = 60.0;

crates/lox_core/src/time/constants/i64.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, you can obtain one at http://mozilla.org/MPL/2.0/.
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

99
pub const SECONDS_PER_MINUTE: i64 = 60;

crates/lox_core/src/time/dates.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

99
use crate::errors::LoxError;

crates/lox_core/src/time/epochs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, you can obtain one at http://mozilla.org/MPL/2.0/.
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

99
use std::fmt;

crates/lox_core/src/two_body.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

99
pub use glam::DVec3;

crates/lox_core/src/two_body/elements.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

99
use float_eq::float_eq;

crates/lox_core/tests/dates.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

99
use lox_core::time::dates::{Date, Time};

crates/lox_io/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

99
pub mod spice;

crates/lox_io/src/spice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

99
use nom::branch::alt;

crates/lox_io/tests/gm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

99
use lox_io::spice::Kernel;

crates/lox_io/tests/pck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* This Source Code Form is subject to the terms of the Mozilla Public
55
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
77
*/
88

99
use lox_io::spice::Kernel;

0 commit comments

Comments
 (0)