#[non_exhaustive]pub struct Body {
pub position: [f64; 3],
pub velocity: [f64; 3],
pub mass: f64,
pub mu: Option<f64>,
}Expand description
A gravitating body with position, velocity, and mass.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.position: [f64; 3]Position [x, y, z] (metres).
velocity: [f64; 3]Velocity [vx, vy, vz] (m/s).
mass: f64Mass (kg).
mu: Option<f64>Gravitational parameter μ (m³/s²). If None, uses G × mass.
Implementations§
Source§impl Body
impl Body
Sourcepub fn new(position: [f64; 3], velocity: [f64; 3], mass: f64) -> Self
pub fn new(position: [f64; 3], velocity: [f64; 3], mass: f64) -> Self
Create a new body (gravity computed as G × mass).
Sourcepub fn with_mu(
position: [f64; 3],
velocity: [f64; 3],
mass: f64,
mu: f64,
) -> Self
pub fn with_mu( position: [f64; 3], velocity: [f64; 3], mass: f64, mu: f64, ) -> Self
Create a new body with an explicit gravitational parameter μ.
Use this when the standard μ value is known more precisely than G × M (e.g., μ_Earth = 3.986004418e14 m³/s²).
Sourcepub fn gravitational_parameter(&self) -> f64
pub fn gravitational_parameter(&self) -> f64
Effective gravitational parameter (m³/s²).
Sourcepub fn kinetic_energy(&self) -> f64
pub fn kinetic_energy(&self) -> f64
Kinetic energy (J).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Body
impl<'de> Deserialize<'de> for Body
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Body
Auto Trait Implementations§
impl Freeze for Body
impl RefUnwindSafe for Body
impl Send for Body
impl Sync for Body
impl Unpin for Body
impl UnsafeUnpin for Body
impl UnwindSafe for Body
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more