summaryrefslogtreecommitdiffstats
path: root/src/solar_system/orbit.rs
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2026-05-05 09:12:50 -0400
committerJon Santmyer <jon@jonsantmyer.com>2026-05-05 09:12:50 -0400
commitbe2cf936ca48f3d638c3ef01f4e338dfc904c5e3 (patch)
tree9fbdbfbf3e0d427f3a6c4bd4c74901e421ef0ad6 /src/solar_system/orbit.rs
parentb35d6cf47ed154697fb45e10586206295148eb35 (diff)
downloadsystemic4x-be2cf936ca48f3d638c3ef01f4e338dfc904c5e3.tar.gz
systemic4x-be2cf936ca48f3d638c3ef01f4e338dfc904c5e3.tar.bz2
systemic4x-be2cf936ca48f3d638c3ef01f4e338dfc904c5e3.zip
seperate orbit logic from body
Diffstat (limited to 'src/solar_system/orbit.rs')
-rw-r--r--src/solar_system/orbit.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/solar_system/orbit.rs b/src/solar_system/orbit.rs
new file mode 100644
index 0000000..fe55e4f
--- /dev/null
+++ b/src/solar_system/orbit.rs
@@ -0,0 +1,29 @@
+use crate::solar_system::{Angle, BodyId, Kilometers, OrbitalBody, Percentage};
+use crate::timeman::{Second};
+
+pub struct StaticOrbit
+{
+ pub parent: Option<BodyId>,
+ pub eccentricity: Percentage,
+ pub inclination: Angle,
+ pub long_asc_node: Angle,
+ pub long_periapsis: Angle,
+ pub mean_long: Angle,
+
+ pub semi_major_axis: Kilometers,
+}
+
+impl StaticOrbit
+{
+ pub fn period(
+ &self,
+ this_body: &OrbitalBody)
+ -> Second
+ {
+ ((self.semi_major_axis.powf(3.0) / this_body.sgp).sqrt() * std::f64::consts::TAU) as u64
+ }
+
+ pub fn parent(&self) -> Option<BodyId> {
+ self.parent
+ }
+}