pub struct MovingMass {
pub mass: f64,
pub velocity: f64,
}Expand description
A moving mass with scalar velocity.
Fields§
§mass: f64§velocity: f64Implementations§
Source§impl MovingMass
impl MovingMass
Sourcepub fn new(mass: f64, velocity: f64) -> Option<MovingMass>
pub fn new(mass: f64, velocity: f64) -> Option<MovingMass>
Creates a moving mass when mass is non-negative and both values are finite.
Sourcepub fn momentum(&self) -> Option<f64>
pub fn momentum(&self) -> Option<f64>
Computes linear momentum using p = m * v.
§Examples
use use_momentum::MovingMass;
let moving_mass = MovingMass::new(2.0, 3.0).unwrap();
assert_eq!(moving_mass.momentum(), Some(6.0));Sourcepub fn kinetic_energy(&self) -> Option<f64>
pub fn kinetic_energy(&self) -> Option<f64>
Computes kinetic energy using 0.5 * m * v^2.
Trait Implementations§
Source§impl Clone for MovingMass
impl Clone for MovingMass
Source§fn clone(&self) -> MovingMass
fn clone(&self) -> MovingMass
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 MovingMass
impl Debug for MovingMass
Source§impl PartialEq for MovingMass
impl PartialEq for MovingMass
Source§fn eq(&self, other: &MovingMass) -> bool
fn eq(&self, other: &MovingMass) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Copy for MovingMass
impl StructuralPartialEq for MovingMass
Auto Trait Implementations§
impl Freeze for MovingMass
impl RefUnwindSafe for MovingMass
impl Send for MovingMass
impl Sync for MovingMass
impl Unpin for MovingMass
impl UnsafeUnpin for MovingMass
impl UnwindSafe for MovingMass
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