pub struct CompactOrbit {
pub eccentricity: f64,
pub periapsis: f64,
pub inclination: f64,
pub arg_pe: f64,
pub long_asc_node: f64,
pub mean_anomaly: f64,
}Expand description
A minimal struct representing a Keplerian orbit.
This struct minimizes memory footprint by not caching variables.
Because of this, calculations can be slower than caching those variables.
For this reason, you might consider using the Orbit struct instead.
§Example
use keplerian_sim::{CompactOrbit, OrbitTrait};
let orbit = CompactOrbit::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 = CompactOrbit::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.
Fields§
§eccentricity: f64The eccentricity of the orbit.
e < 1: ellipse
e = 1: parabola
e > 1: hyperbola
See more: https://en.wikipedia.org/wiki/Orbital_eccentricity
periapsis: f64The periapsis of the orbit, in meters.
The periapsis of an orbit is the distance at the closest point to the parent body.
More simply, this is the “minimum altitude” of an orbit.
inclination: f64The inclination of the orbit, in radians. The inclination of an orbit is the angle between the plane of the orbit and the reference plane.
In simple terms, it tells you how “tilted” the orbit is.
arg_pe: f64The argument of periapsis of the orbit, in radians.
Wikipedia:
The argument of periapsis is the angle from the body’s
ascending node to its periapsis, measured in the direction of
motion.
https://en.wikipedia.org/wiki/Argument_of_periapsis
In simple terms, it tells you how, and in which direction, the orbit “tilts”.
long_asc_node: f64The longitude of ascending node of the orbit, in radians.
Wikipedia:
The longitude of ascending node is the angle from a specified
reference direction, called the origin of longitude, to the direction
of the ascending node, as measured in a specified reference plane.
https://en.wikipedia.org/wiki/Longitude_of_the_ascending_node
In simple terms, it tells you how, and in which direction, the orbit “tilts”.
mean_anomaly: f64The mean anomaly at orbit epoch, in radians.
For elliptic orbits, it’s measured in radians and so are bounded
between 0 and tau; anything out of range will get wrapped around.
For hyperbolic orbits, it’s unbounded.
Wikipedia:
The mean anomaly at epoch, M_0, is defined as the instantaneous mean
anomaly at a given epoch, t_0.
https://en.wikipedia.org/wiki/Mean_anomaly#Mean_anomaly_at_epoch
In simple terms, this modifies the “offset” of the orbit progression.
Implementations§
Source§impl CompactOrbit
impl CompactOrbit
Source§impl CompactOrbit
impl CompactOrbit
Sourcepub fn new(
eccentricity: f64,
periapsis: f64,
inclination: f64,
arg_pe: f64,
long_asc_node: f64,
mean_anomaly: f64,
) -> CompactOrbit
pub fn new( eccentricity: f64, periapsis: f64, inclination: f64, arg_pe: f64, long_asc_node: f64, mean_anomaly: f64, ) -> CompactOrbit
Creates a new CompactOrbit instance with the given parameters.
Note: This function uses eccentricity instead of apoapsis.
If you want to provide an apoapsis instead, consider using the
CompactOrbit::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,
) -> CompactOrbit
pub fn with_apoapsis( apoapsis: f64, periapsis: f64, inclination: f64, arg_pe: f64, long_asc_node: f64, mean_anomaly: f64, ) -> CompactOrbit
Creates a new CompactOrbit instance 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 CompactOrbit::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() -> CompactOrbit
pub fn new_default() -> CompactOrbit
Creates a unit orbit.
The unit orbit is a perfect circle of radius 1 and no “tilt”.
Source§impl CompactOrbit
impl CompactOrbit
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.”
Trait Implementations§
Source§impl Clone for CompactOrbit
impl Clone for CompactOrbit
Source§fn clone(&self) -> CompactOrbit
fn clone(&self) -> CompactOrbit
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CompactOrbit
impl Debug for CompactOrbit
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 CompactOrbit
impl OrbitTrait for CompactOrbit
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