pub struct EllipticalOrbit {
pub mu: f64,
pub periapsis_radius: f64,
pub apoapsis_radius: f64,
}Expand description
Elliptical orbit state described by a gravitational parameter and apsides.
Fields§
§mu: f64Central-body gravitational parameter in cubic meters per second squared.
periapsis_radius: f64Periapsis radius in meters.
apoapsis_radius: f64Apoapsis radius in meters.
Implementations§
Source§impl EllipticalOrbit
impl EllipticalOrbit
Sourcepub fn new(mu: f64, periapsis_radius: f64, apoapsis_radius: f64) -> Option<Self>
pub fn new(mu: f64, periapsis_radius: f64, apoapsis_radius: f64) -> Option<Self>
Creates an elliptical orbit from a gravitational parameter and apsides.
Returns None when mu is less than or equal to zero or not finite, or when the apsides
are invalid.
Examples found in repository?
examples/basic_usage.rs (line 15)
3fn main() {
4 let earth = CentralBody::with_radius(5.972e24, 6.371e6);
5 let low_orbit_radius = earth.and_then(|body| body.orbital_radius_from_altitude(400_000.0));
6 let low_orbit_speed = earth.and_then(|body| {
7 low_orbit_radius.and_then(|radius| body.circular_orbital_speed_at_radius(radius))
8 });
9 let transfer = hohmann_total_delta_v(398_600_441_800_000.0, 6_771_000.0, 42_164_000.0);
10
11 assert_eq!(low_orbit_radius, Some(6_771_000.0));
12 assert!(low_orbit_speed.is_some_and(|speed| speed > 7_600.0));
13 assert!(transfer.is_some_and(|delta_v| delta_v > 0.0));
14 assert!(
15 EllipticalOrbit::new(100.0, 10.0, 20.0)
16 .and_then(|orbit| orbit.period())
17 .is_some_and(|period| period > 0.0)
18 );
19}Sourcepub fn semi_major_axis(&self) -> Option<f64>
pub fn semi_major_axis(&self) -> Option<f64>
Computes the semi-major axis.
Sourcepub fn eccentricity(&self) -> Option<f64>
pub fn eccentricity(&self) -> Option<f64>
Computes eccentricity.
Sourcepub fn period(&self) -> Option<f64>
pub fn period(&self) -> Option<f64>
Computes the orbital period.
§Examples
use use_orbit::EllipticalOrbit;
let orbit = EllipticalOrbit::new(100.0, 10.0, 20.0);
assert!(orbit.and_then(|value| value.period()).is_some_and(|period| period > 0.0));Examples found in repository?
examples/basic_usage.rs (line 16)
3fn main() {
4 let earth = CentralBody::with_radius(5.972e24, 6.371e6);
5 let low_orbit_radius = earth.and_then(|body| body.orbital_radius_from_altitude(400_000.0));
6 let low_orbit_speed = earth.and_then(|body| {
7 low_orbit_radius.and_then(|radius| body.circular_orbital_speed_at_radius(radius))
8 });
9 let transfer = hohmann_total_delta_v(398_600_441_800_000.0, 6_771_000.0, 42_164_000.0);
10
11 assert_eq!(low_orbit_radius, Some(6_771_000.0));
12 assert!(low_orbit_speed.is_some_and(|speed| speed > 7_600.0));
13 assert!(transfer.is_some_and(|delta_v| delta_v > 0.0));
14 assert!(
15 EllipticalOrbit::new(100.0, 10.0, 20.0)
16 .and_then(|orbit| orbit.period())
17 .is_some_and(|period| period > 0.0)
18 );
19}Sourcepub fn periapsis_speed(&self) -> Option<f64>
pub fn periapsis_speed(&self) -> Option<f64>
Computes speed at periapsis.
Sourcepub fn apoapsis_speed(&self) -> Option<f64>
pub fn apoapsis_speed(&self) -> Option<f64>
Computes speed at apoapsis.
Trait Implementations§
Source§impl Clone for EllipticalOrbit
impl Clone for EllipticalOrbit
Source§fn clone(&self) -> EllipticalOrbit
fn clone(&self) -> EllipticalOrbit
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for EllipticalOrbit
impl Debug for EllipticalOrbit
Source§impl PartialEq for EllipticalOrbit
impl PartialEq for EllipticalOrbit
Source§fn eq(&self, other: &EllipticalOrbit) -> bool
fn eq(&self, other: &EllipticalOrbit) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Copy for EllipticalOrbit
impl StructuralPartialEq for EllipticalOrbit
Auto Trait Implementations§
impl Freeze for EllipticalOrbit
impl RefUnwindSafe for EllipticalOrbit
impl Send for EllipticalOrbit
impl Sync for EllipticalOrbit
impl Unpin for EllipticalOrbit
impl UnsafeUnpin for EllipticalOrbit
impl UnwindSafe for EllipticalOrbit
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more