pub struct Orbit { /* private fields */ }Expand description
A struct representing a Keplerian orbit with some cached values.
This struct consumes significantly more memory because of the cache.
However, this will speed up orbital calculations.
If memory efficiency is your goal, you may consider using the CompactOrbit struct instead.
§Example
use keplerian_sim::{Orbit, OrbitTrait};
let orbit = Orbit::new(
// Initialize using eccentricity, periapsis, inclination,
// argument of periapsis, longitude of ascending node,
// and mean anomaly at epoch
// Eccentricity
0.0,
// Periapsis
1.0,
// Inclination
0.0,
// Argument of periapsis
0.0,
// Longitude of ascending node
0.0,
// Mean anomaly at epoch
0.0,
// Gravitational parameter of the parent body
1.0,
);
let orbit = Orbit::with_apoapsis(
// Initialize using apoapsis in place of eccentricity
// Apoapsis
2.0,
// Periapsis
1.0,
// Inclination
0.0,
// Argument of periapsis
0.0,
// Longitude of ascending node
0.0,
// Mean anomaly at epoch
0.0,
// Gravitational parameter of the parent body
1.0,
);See Orbit::new and Orbit::with_apoapsis for more information.
Implementations§
Source§impl Orbit
impl Orbit
Sourcepub fn new(
eccentricity: f64,
periapsis: f64,
inclination: f64,
arg_pe: f64,
long_asc_node: f64,
mean_anomaly: f64,
mu: f64,
) -> Orbit
pub fn new( eccentricity: f64, periapsis: f64, inclination: f64, arg_pe: f64, long_asc_node: f64, mean_anomaly: f64, mu: f64, ) -> Orbit
Creates a new orbit with the given parameters.
Note: This function uses eccentricity instead of apoapsis.
If you want to provide an apoapsis instead, consider using the
Orbit::with_apoapsis function instead.
§Parameters
eccentricity: The eccentricity of the orbit.periapsis: The periapsis of the orbit, in meters.inclination: The inclination of the orbit, in radians.arg_pe: The argument of periapsis of the orbit, in radians.long_asc_node: The longitude of ascending node of the orbit, in radians.mean_anomaly: The mean anomaly of the orbit at epoch, in radians.mu: The gravitational parameter of the parent body, in m^3 s^-2.
Sourcepub fn with_apoapsis(
apoapsis: f64,
periapsis: f64,
inclination: f64,
arg_pe: f64,
long_asc_node: f64,
mean_anomaly: f64,
mu: f64,
) -> Orbit
pub fn with_apoapsis( apoapsis: f64, periapsis: f64, inclination: f64, arg_pe: f64, long_asc_node: f64, mean_anomaly: f64, mu: f64, ) -> Orbit
Creates a new orbit with the given parameters.
Note: This function uses apoapsis instead of eccentricity.
Because of this, it’s not recommended to initialize
parabolic or hyperbolic ‘orbits’ with this function.
If you’re looking to initialize a parabolic or hyperbolic
trajectory, consider using the Orbit::new function instead.
§Parameters
apoapsis: The apoapsis of the orbit, in meters.periapsis: The periapsis of the orbit, in meters.inclination: The inclination of the orbit, in radians.arg_pe: The argument of periapsis of the orbit, in radians.long_asc_node: The longitude of ascending node of the orbit, in radians.mean_anomaly: The mean anomaly of the orbit, in radians.mu: The gravitational parameter of the parent body, in m^3 s^-2.
Trait Implementations§
Source§impl From<CompactOrbit> for Orbit
impl From<CompactOrbit> for Orbit
Source§fn from(compact: CompactOrbit) -> Self
fn from(compact: CompactOrbit) -> Self
Source§impl From<Orbit> for CompactOrbit
impl From<Orbit> for CompactOrbit
Source§impl OrbitTrait for Orbit
impl OrbitTrait for Orbit
Source§fn set_apoapsis(&mut self, apoapsis: f64) -> Result<(), ApoapsisSetterError>
fn set_apoapsis(&mut self, apoapsis: f64) -> Result<(), ApoapsisSetterError>
Errors when the apoapsis is less than the periapsis, or less than zero.
If you want a setter that does not error, use
set_apoapsis_force, which will
try its best to interpret what you might have meant, but may have
undesirable behavior. Read moreSource§fn set_apoapsis_force(&mut self, apoapsis: f64)
fn set_apoapsis_force(&mut self, apoapsis: f64)
This function will not error, but may have undesirable behavior: Read more
Source§fn get_transformation_matrix(&self) -> Matrix3x2
fn get_transformation_matrix(&self) -> Matrix3x2
Source§fn get_eccentricity(&self) -> f64
fn get_eccentricity(&self) -> f64
Source§fn get_periapsis(&self) -> f64
fn get_periapsis(&self) -> f64
Source§fn get_inclination(&self) -> f64
fn get_inclination(&self) -> f64
Source§fn get_arg_pe(&self) -> f64
fn get_arg_pe(&self) -> f64
Source§fn get_long_asc_node(&self) -> f64
fn get_long_asc_node(&self) -> f64
Source§fn get_mean_anomaly_at_epoch(&self) -> f64
fn get_mean_anomaly_at_epoch(&self) -> f64
Source§fn get_gravitational_parameter(&self) -> f64
fn get_gravitational_parameter(&self) -> f64
Source§fn set_eccentricity(&mut self, value: f64)
fn set_eccentricity(&mut self, value: f64)
Source§fn set_periapsis(&mut self, value: f64)
fn set_periapsis(&mut self, value: f64)
Source§fn set_inclination(&mut self, value: f64)
fn set_inclination(&mut self, value: f64)
Source§fn set_arg_pe(&mut self, value: f64)
fn set_arg_pe(&mut self, value: f64)
Source§fn set_long_asc_node(&mut self, value: f64)
fn set_long_asc_node(&mut self, value: f64)
Source§fn set_mean_anomaly_at_epoch(&mut self, value: f64)
fn set_mean_anomaly_at_epoch(&mut self, value: f64)
Source§fn set_gravitational_parameter(
&mut self,
gravitational_parameter: f64,
mode: MuSetterMode,
)
fn set_gravitational_parameter( &mut self, gravitational_parameter: f64, mode: MuSetterMode, )
Source§fn get_semi_major_axis(&self) -> f64
fn get_semi_major_axis(&self) -> f64
Source§fn get_semi_minor_axis(&self) -> f64
fn get_semi_minor_axis(&self) -> f64
Source§fn get_semi_latus_rectum(&self) -> f64
fn get_semi_latus_rectum(&self) -> f64
Source§fn get_linear_eccentricity(&self) -> f64
fn get_linear_eccentricity(&self) -> f64
Source§fn get_apoapsis(&self) -> f64
fn get_apoapsis(&self) -> f64
Returns infinity for parabolic orbits.
Returns negative values for hyperbolic orbits. Read more