pub struct Orbit2D { /* private fields */ }Expand description
A struct representing a 2D Keplerian orbit with some cached values.
This struct consumes significantly more memory because of the cache.
However, this will slightly speed up orbital calculations.
If memory efficiency is your goal, you may consider using the CompactOrbit2D
struct instead.
§Example
use keplerian_sim::{Orbit2D, OrbitTrait2D};
let orbit = Orbit2D::new(
// Initialize using eccentricity, periapsis,
// argument of periapsis, mean anomaly at epoch,
// and gravitational parameter
// Eccentricity
0.0,
// Periapsis
1.0,
// Argument of periapsis
0.0,
// Mean anomaly at epoch
0.0,
// Gravitational parameter of the parent body
1.0,
);
let orbit = Orbit2D::with_apoapsis(
// Initialize using apoapsis in place of eccentricity
// Apoapsis
2.0,
// Periapsis
1.0,
// Argument of periapsis
0.0,
// Mean anomaly at epoch
0.0,
// Gravitational parameter of the parent body
1.0,
);See Orbit2D::new and Orbit2D::with_apoapsis for more information.
Implementations§
Source§impl Orbit2D
impl Orbit2D
Sourcepub fn new(
eccentricity: f64,
periapsis: f64,
arg_pe: f64,
mean_anomaly: f64,
mu: f64,
) -> Self
pub fn new( eccentricity: f64, periapsis: f64, arg_pe: f64, mean_anomaly: f64, mu: f64, ) -> Self
Creates a new orbit with the given parameters.
Note: This function uses eccentricity instead of periapsis.
If you want to provide an apoapsis instead, consider using the
Orbit2D::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::{Orbit2D, OrbitTrait2D};
let eccentricity = 0.2;
let periapsis = 2.8;
let argument_of_periapsis = 0.7;
let mean_anomaly_at_epoch = 2.9;
let gravitational_parameter = 9.2;
let orbit = Orbit2D::new(
eccentricity,
periapsis,
argument_of_periapsis,
mean_anomaly_at_epoch,
gravitational_parameter
);
assert_eq!(orbit.get_eccentricity(), eccentricity);
assert_eq!(orbit.get_periapsis(), periapsis);
assert_eq!(orbit.get_arg_pe(), argument_of_periapsis);
assert_eq!(orbit.get_mean_anomaly_at_epoch(), mean_anomaly_at_epoch);
assert_eq!(orbit.get_gravitational_parameter(), gravitational_parameter);Sourcepub fn with_apoapsis(
apoapsis: f64,
periapsis: f64,
arg_pe: f64,
mean_anomaly: f64,
mu: f64,
) -> Self
pub fn with_apoapsis( apoapsis: f64, periapsis: f64, arg_pe: f64, mean_anomaly: f64, mu: f64, ) -> Self
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 Orbit2D::new 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::{Orbit2D, OrbitTrait2D};
let apoapsis = 4.1;
let periapsis = 2.8;
let argument_of_periapsis = 0.7;
let mean_anomaly_at_epoch = 2.9;
let gravitational_parameter = 9.2;
let orbit = Orbit2D::with_apoapsis(
apoapsis,
periapsis,
argument_of_periapsis,
mean_anomaly_at_epoch,
gravitational_parameter
);
let eccentricity = (apoapsis - periapsis) / (apoapsis + periapsis);
assert_eq!(orbit.get_eccentricity(), eccentricity);
assert_eq!(orbit.get_periapsis(), periapsis);
assert_eq!(orbit.get_arg_pe(), argument_of_periapsis);
assert_eq!(orbit.get_mean_anomaly_at_epoch(), mean_anomaly_at_epoch);
assert_eq!(orbit.get_gravitational_parameter(), gravitational_parameter);Sourcepub fn new_circular(radius: f64, mean_anomaly: f64, mu: f64) -> Self
pub fn new_circular(radius: f64, mean_anomaly: f64, mu: f64) -> Self
Creates a new circular Orbit2D instance with the given parameters.
§Parameters
radius: The radius 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::{Orbit2D, OrbitTrait2D};
let radius = 4.2;
let mean_anomaly_at_epoch = 1.5;
let gravitational_parameter = 5.0;
let orbit = Orbit2D::new_circular(
radius,
mean_anomaly_at_epoch,
gravitational_parameter,
);
assert_eq!(orbit.get_eccentricity(), 0.0);
assert_eq!(orbit.get_periapsis(), radius);
assert_eq!(orbit.get_arg_pe(), 0.0);
assert_eq!(orbit.get_mean_anomaly_at_epoch(), mean_anomaly_at_epoch);
assert_eq!(orbit.get_gravitational_parameter(), gravitational_parameter);Trait Implementations§
Source§impl From<CompactOrbit2D> for Orbit2D
impl From<CompactOrbit2D> for Orbit2D
Source§fn from(compact: CompactOrbit2D) -> Self
fn from(compact: CompactOrbit2D) -> Self
Source§impl From<Orbit2D> for CompactOrbit2D
impl From<Orbit2D> for CompactOrbit2D
Source§impl OrbitTrait2D for Orbit2D
impl OrbitTrait2D for Orbit2D
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) -> DMat2
fn get_transformation_matrix(&self) -> DMat2
Source§fn get_pqw_basis_vector_p(&self) -> DVec2
fn get_pqw_basis_vector_p(&self) -> DVec2
Source§fn get_pqw_basis_vector_q(&self) -> DVec2
fn get_pqw_basis_vector_q(&self) -> DVec2
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_arg_pe(&self) -> f64
fn get_arg_pe(&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_arg_pe(&mut self, value: f64)
fn set_arg_pe(&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: MuSetterMode2D,
)
fn set_gravitational_parameter( &mut self, gravitational_parameter: f64, mode: MuSetterMode2D, )
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) -> DVec2
fn get_position_at_periapsis(&self) -> DVec2
Source§fn get_position_at_periapsis_unchecked(&self, p_vector: DVec2) -> DVec2
fn get_position_at_periapsis_unchecked(&self, p_vector: DVec2) -> DVec2
Source§fn get_position_at_apoapsis(&self) -> DVec2
fn get_position_at_apoapsis(&self) -> DVec2
Source§fn get_position_at_apoapsis_unchecked(&self, p_vector: DVec2) -> DVec2
fn get_position_at_apoapsis_unchecked(&self, p_vector: DVec2) -> DVec2
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