diff options
| author | Jon Santmyer <jon@jonsantmyer.com> | 2026-05-05 09:12:50 -0400 |
|---|---|---|
| committer | Jon Santmyer <jon@jonsantmyer.com> | 2026-05-05 09:12:50 -0400 |
| commit | be2cf936ca48f3d638c3ef01f4e338dfc904c5e3 (patch) | |
| tree | 9fbdbfbf3e0d427f3a6c4bd4c74901e421ef0ad6 /src/solar_system | |
| parent | b35d6cf47ed154697fb45e10586206295148eb35 (diff) | |
| download | systemic4x-be2cf936ca48f3d638c3ef01f4e338dfc904c5e3.tar.gz systemic4x-be2cf936ca48f3d638c3ef01f4e338dfc904c5e3.tar.bz2 systemic4x-be2cf936ca48f3d638c3ef01f4e338dfc904c5e3.zip | |
seperate orbit logic from body
Diffstat (limited to 'src/solar_system')
| -rw-r--r-- | src/solar_system/orbit.rs | 29 | ||||
| -rw-r--r-- | src/solar_system/ship.rs | 4 |
2 files changed, 33 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 + } +} diff --git a/src/solar_system/ship.rs b/src/solar_system/ship.rs new file mode 100644 index 0000000..eb4cdf3 --- /dev/null +++ b/src/solar_system/ship.rs @@ -0,0 +1,4 @@ +pub struct Ship +{ + +} |
