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,
);
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,
);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,
) -> Orbit
pub fn new( eccentricity: f64, periapsis: f64, inclination: f64, arg_pe: f64, long_asc_node: f64, mean_anomaly: 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, in radians.
Sourcepub fn with_apoapsis(
apoapsis: f64,
periapsis: f64,
inclination: f64,
arg_pe: f64,
long_asc_node: f64,
mean_anomaly: f64,
) -> Orbit
pub fn with_apoapsis( apoapsis: f64, periapsis: f64, inclination: f64, arg_pe: f64, long_asc_node: f64, mean_anomaly: 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.
Sourcepub fn new_default() -> Orbit
pub fn new_default() -> Orbit
Creates a unit orbit.
The unit orbit is a perfect circle of radius 1 and no “tilt”.
Source§impl Orbit
impl Orbit
Sourcepub fn get_approx_hyp_ecc_anomaly(&self, mean_anomaly: f64) -> f64
pub fn get_approx_hyp_ecc_anomaly(&self, mean_anomaly: f64) -> f64
Get an initial guess for the hyperbolic eccentric anomaly of an orbit.
Returns a tuple containing the initial guess and the approximate error of the guess.
From the paper:
“A new method for solving the hyperbolic Kepler equation”
by Baisheng Wu et al.
Quote:
“we divide the hyperbolic eccentric anomaly interval into two parts:
a finite interval and an infinite interval. For the finite interval,
we apply a piecewise Pade approximation to establish an initial
approximate solution of HKE. For the infinite interval, an analytical
initial approximate solution is constructed.”
Source§impl Orbit
impl Orbit
Sourcepub fn compactify(self) -> CompactOrbit
pub fn compactify(self) -> CompactOrbit
Compactify the cached orbit into a compact orbit to increase memory efficiency while sacrificing calculation speed.
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 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_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
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