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,
pub mu: 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,
// mean anomaly at epoch, and gravitational parameter
// 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 = 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,
// Gravitational parameter of the parent body
1.0,
);See CompactOrbit::new and CompactOrbit::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.
mu: f64The gravitational parameter of the parent body.
This is a constant value that represents the mass of the parent body multiplied by the gravitational constant.
In other words, mu = GM.
Implementations§
Source§impl CompactOrbit
impl CompactOrbit
Sourcepub fn new(
eccentricity: f64,
periapsis: f64,
inclination: f64,
arg_pe: f64,
long_asc_node: f64,
mean_anomaly: f64,
mu: f64,
) -> Self
pub fn new( eccentricity: f64, periapsis: f64, inclination: f64, arg_pe: f64, long_asc_node: f64, mean_anomaly: f64, mu: f64, ) -> Self
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 at epoch, in radians.mu: The gravitational parameter of the parent body, in m^3 s^-2.
§Example
use keplerian_sim::{CompactOrbit, OrbitTrait};
let eccentricity = 0.2;
let periapsis = 2.8;
let inclination = 1.0;
let argument_of_periapsis = 0.7;
let longitude_of_ascending_node = 4.5;
let mean_anomaly_at_epoch = 2.9;
let gravitational_parameter = 9.2;
let orbit = CompactOrbit::new(
eccentricity,
periapsis,
inclination,
argument_of_periapsis,
longitude_of_ascending_node,
mean_anomaly_at_epoch,
gravitational_parameter
);
assert_eq!(orbit.eccentricity, eccentricity);
assert_eq!(orbit.periapsis, periapsis);
assert_eq!(orbit.inclination, inclination);
assert_eq!(orbit.arg_pe, argument_of_periapsis);
assert_eq!(orbit.long_asc_node, longitude_of_ascending_node);
assert_eq!(orbit.mean_anomaly, mean_anomaly_at_epoch);
assert_eq!(orbit.mu, gravitational_parameter);Sourcepub fn with_apoapsis(
apoapsis: f64,
periapsis: f64,
inclination: f64,
arg_pe: f64,
long_asc_node: f64,
mean_anomaly: f64,
mu: f64,
) -> Self
pub fn with_apoapsis( apoapsis: f64, periapsis: f64, inclination: f64, arg_pe: f64, long_asc_node: f64, mean_anomaly: f64, mu: f64, ) -> Self
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 create
parabolic or hyperbolic trajectories 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. Must be more than the periapsis.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.
§Example
use keplerian_sim::{CompactOrbit, OrbitTrait};
let apoapsis = 4.1;
let periapsis = 2.8;
let inclination = 1.0;
let argument_of_periapsis = 0.7;
let longitude_of_ascending_node = 4.5;
let mean_anomaly_at_epoch = 2.9;
let gravitational_parameter = 9.2;
let orbit = CompactOrbit::with_apoapsis(
apoapsis,
periapsis,
inclination,
argument_of_periapsis,
longitude_of_ascending_node,
mean_anomaly_at_epoch,
gravitational_parameter
);
let eccentricity = (apoapsis - periapsis) / (apoapsis + periapsis);
assert_eq!(orbit.eccentricity, eccentricity);
assert_eq!(orbit.periapsis, periapsis);
assert_eq!(orbit.inclination, inclination);
assert_eq!(orbit.arg_pe, argument_of_periapsis);
assert_eq!(orbit.long_asc_node, longitude_of_ascending_node);
assert_eq!(orbit.mean_anomaly, mean_anomaly_at_epoch);
assert_eq!(orbit.mu, gravitational_parameter);Sourcepub fn new_circular(
radius: f64,
inclination: f64,
long_asc_node: f64,
mean_anomaly: f64,
mu: f64,
) -> Self
pub fn new_circular( radius: f64, inclination: f64, long_asc_node: f64, mean_anomaly: f64, mu: f64, ) -> Self
Creates a new circular CompactOrbit instance with the given parameters.
§Parameters
radius: The radius 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.
§Example
use keplerian_sim::{CompactOrbit, OrbitTrait};
let radius = 4.2;
let inclination = 1.8;
let longitude_of_ascending_node = 3.1;
let mean_anomaly_at_epoch = 1.5;
let gravitational_parameter = 5.0;
let orbit = CompactOrbit::new_circular(
radius,
inclination,
longitude_of_ascending_node,
mean_anomaly_at_epoch,
gravitational_parameter,
);
assert_eq!(orbit.eccentricity, 0.0);
assert_eq!(orbit.periapsis, radius);
assert_eq!(orbit.inclination, inclination);
assert_eq!(orbit.arg_pe, 0.0);
assert_eq!(orbit.long_asc_node, longitude_of_ascending_node);
assert_eq!(orbit.mean_anomaly, mean_anomaly_at_epoch);
assert_eq!(orbit.mu, gravitational_parameter);Sourcepub fn new_flat(
eccentricity: f64,
periapsis: f64,
arg_pe: f64,
mean_anomaly: f64,
mu: f64,
) -> Self
pub fn new_flat( eccentricity: f64, periapsis: f64, arg_pe: f64, mean_anomaly: f64, mu: f64, ) -> Self
Creates a new CompactOrbit instance parallel to
the XY plane with the given parameters.
Note: This function uses eccentricity instead of apoapsis.
If you want to provide an apoapsis instead, consider using the
CompactOrbit::new_flat_with_apoapsis function instead.
§Parameters
eccentricity: The eccentricity of the orbit.periapsis: The periapsis of the orbit, in meters.arg_pe: The argument of periapsis 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.
§Example
use keplerian_sim::{CompactOrbit, OrbitTrait};
let eccentricity = 2.0;
let periapsis = 8.0;
let argument_of_periapsis = 2.1;
let mean_anomaly_at_epoch = 9.8;
let gravitational_parameter = 5.0;
let orbit = CompactOrbit::new_flat(
eccentricity,
periapsis,
argument_of_periapsis,
mean_anomaly_at_epoch,
gravitational_parameter,
);
assert_eq!(orbit.eccentricity, eccentricity);
assert_eq!(orbit.periapsis, periapsis);
assert_eq!(orbit.inclination, 0.0);
assert_eq!(orbit.arg_pe, argument_of_periapsis);
assert_eq!(orbit.long_asc_node, 0.0);
assert_eq!(orbit.mean_anomaly, mean_anomaly_at_epoch);
assert_eq!(orbit.mu, gravitational_parameter);Sourcepub fn new_flat_with_apoapsis(
apoapsis: f64,
periapsis: f64,
arg_pe: f64,
mean_anomaly: f64,
mu: f64,
) -> Self
pub fn new_flat_with_apoapsis( apoapsis: f64, periapsis: f64, arg_pe: f64, mean_anomaly: f64, mu: f64, ) -> Self
Creates a new CompactOrbit instance parallel to
the XY plane with the given parameters.
Note: This function uses apoapsis instead of eccentricity.
Because of this, it’s not recommended to create
parabolic or hyperbolic trajectories with this function.
If you’re looking to initialize a parabolic or hyperbolic
trajectory, consider using the CompactOrbit::new_flat function instead.
§Parameters
apoapsis: The apoapsis of the orbit, in meters.periapsis: The periapsis of the orbit, in meters.arg_pe: The argument of periapsis 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.
§Example
use keplerian_sim::{CompactOrbit, OrbitTrait};
let apoapsis = 10.1;
let periapsis = 8.0;
let argument_of_periapsis = 2.1;
let mean_anomaly_at_epoch = 9.8;
let gravitational_parameter = 5.0;
let orbit = CompactOrbit::new_flat_with_apoapsis(
apoapsis,
periapsis,
argument_of_periapsis,
mean_anomaly_at_epoch,
gravitational_parameter,
);
let eccentricity = (apoapsis - periapsis) / (apoapsis + periapsis);
assert_eq!(orbit.eccentricity, eccentricity);
assert_eq!(orbit.periapsis, periapsis);
assert_eq!(orbit.inclination, 0.0);
assert_eq!(orbit.arg_pe, argument_of_periapsis);
assert_eq!(orbit.long_asc_node, 0.0);
assert_eq!(orbit.mean_anomaly, mean_anomaly_at_epoch);
assert_eq!(orbit.mu, gravitational_parameter);Sourcepub fn new_flat_circular(radius: f64, mean_anomaly: f64, mu: f64) -> Self
pub fn new_flat_circular(radius: f64, mean_anomaly: f64, mu: f64) -> Self
Creates a new circular CompactOrbit instance parallel to
the XY plane with the given parameters.
§Parameters
radius: The radius of the orbit, in meters.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.
§Example
use keplerian_sim::{CompactOrbit, OrbitTrait};
let radius = 90.0;
let mean_anomaly_at_epoch = 0.5;
let gravitational_parameter = 6.0;
let orbit = CompactOrbit::new_flat_circular(
radius,
mean_anomaly_at_epoch,
gravitational_parameter
);
assert_eq!(orbit.eccentricity, 0.0);
assert_eq!(orbit.periapsis, radius);
assert_eq!(orbit.inclination, 0.0);
assert_eq!(orbit.arg_pe, 0.0);
assert_eq!(orbit.long_asc_node, 0.0);
assert_eq!(orbit.mean_anomaly, mean_anomaly_at_epoch);
assert_eq!(orbit.mu, gravitational_parameter);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 Default for CompactOrbit
impl Default 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 set_apoapsis(&mut self, apoapsis: f64) -> Result<(), ApoapsisSetterError>
fn set_apoapsis(&mut self, apoapsis: f64) -> Result<(), ApoapsisSetterError>
Source§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_pqw_basis_vector_p(&self) -> DVec3
fn get_pqw_basis_vector_p(&self) -> DVec3
Source§fn get_pqw_basis_vector_q(&self) -> DVec3
fn get_pqw_basis_vector_q(&self) -> DVec3
Source§fn get_pqw_basis_vector_w(&self) -> DVec3
fn get_pqw_basis_vector_w(&self) -> DVec3
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_true_anomaly_at_asymptote(&self) -> f64
fn get_true_anomaly_at_asymptote(&self) -> f64
Source§fn get_position_at_periapsis(&self) -> DVec3
fn get_position_at_periapsis(&self) -> DVec3
Source§fn get_position_at_periapsis_unchecked(&self, p_vector: DVec3) -> DVec3
fn get_position_at_periapsis_unchecked(&self, p_vector: DVec3) -> DVec3
Source§fn get_position_at_apoapsis(&self) -> DVec3
fn get_position_at_apoapsis(&self) -> DVec3
Source§fn get_position_at_apoapsis_unchecked(&self, p_vector: DVec3) -> DVec3
fn get_position_at_apoapsis_unchecked(&self, p_vector: DVec3) -> DVec3
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 get_mean_motion(&self) -> f64
fn get_mean_motion(&self) -> f64
Source§fn get_focal_parameter(&self) -> f64
fn get_focal_parameter(&self) -> f64
Source§fn get_specific_angular_momentum(&self) -> f64
fn get_specific_angular_momentum(&self) -> f64
Source§fn get_specific_orbital_energy(&self) -> f64
fn get_specific_orbital_energy(&self) -> f64
ε of the orbit,
in joules per kilogram (J/kg, equiv. to m^2 ⋅ s^-2). Read more