pub struct GravityBody {
pub mass: f64,
pub radius: f64,
}Expand description
Mass and radius for a body used in gravity calculations.
Fields§
§mass: f64§radius: f64Implementations§
Source§impl GravityBody
impl GravityBody
Sourcepub fn new(mass: f64, radius: f64) -> Option<GravityBody>
pub fn new(mass: f64, radius: f64) -> Option<GravityBody>
Creates a gravity body from a mass and radius.
Returns None when mass is negative, when radius is less than or equal to zero, or
when either input is not finite.
Sourcepub fn surface_gravity(&self) -> Option<f64>
pub fn surface_gravity(&self) -> Option<f64>
Computes the surface gravity of the body.
§Examples
use use_gravity::GravityBody;
let earth = GravityBody::new(5.972e24, 6.371e6).unwrap();
let gravity = earth.surface_gravity().unwrap();
assert!((gravity - 9.82).abs() < 0.05);Sourcepub fn escape_velocity(&self) -> Option<f64>
pub fn escape_velocity(&self) -> Option<f64>
Computes the escape velocity from the body’s surface.
Sourcepub fn circular_orbital_velocity_at_radius(
&self,
orbital_radius: f64,
) -> Option<f64>
pub fn circular_orbital_velocity_at_radius( &self, orbital_radius: f64, ) -> Option<f64>
Computes the circular orbital velocity at a given radius from the body’s center.
Trait Implementations§
Source§impl Clone for GravityBody
impl Clone for GravityBody
Source§fn clone(&self) -> GravityBody
fn clone(&self) -> GravityBody
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for GravityBody
impl Debug for GravityBody
Source§impl PartialEq for GravityBody
impl PartialEq for GravityBody
Source§fn eq(&self, other: &GravityBody) -> bool
fn eq(&self, other: &GravityBody) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Copy for GravityBody
impl StructuralPartialEq for GravityBody
Auto Trait Implementations§
impl Freeze for GravityBody
impl RefUnwindSafe for GravityBody
impl Send for GravityBody
impl Sync for GravityBody
impl Unpin for GravityBody
impl UnsafeUnpin for GravityBody
impl UnwindSafe for GravityBody
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