pub struct CollisionBody1D {
pub mass: f64,
pub velocity: f64,
}Expand description
A one-dimensional body with scalar mass and velocity.
Fields§
§mass: f64§velocity: f64Implementations§
Source§impl CollisionBody1D
impl CollisionBody1D
Sourcepub fn new(mass: f64, velocity: f64) -> Option<Self>
pub fn new(mass: f64, velocity: f64) -> Option<Self>
Creates a one-dimensional collision body when mass is non-negative and both values are
finite.
Sourcepub fn kinetic_energy(&self) -> Option<f64>
pub fn kinetic_energy(&self) -> Option<f64>
Computes kinetic energy for this body.
§Examples
use use_collision::CollisionBody1D;
let body = CollisionBody1D::new(2.0, 3.0).unwrap();
assert_eq!(body.kinetic_energy(), Some(9.0));Trait Implementations§
Source§impl Clone for CollisionBody1D
impl Clone for CollisionBody1D
Source§fn clone(&self) -> CollisionBody1D
fn clone(&self) -> CollisionBody1D
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 CollisionBody1D
impl Debug for CollisionBody1D
Source§impl PartialEq for CollisionBody1D
impl PartialEq for CollisionBody1D
Source§fn eq(&self, other: &CollisionBody1D) -> bool
fn eq(&self, other: &CollisionBody1D) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Copy for CollisionBody1D
impl StructuralPartialEq for CollisionBody1D
Auto Trait Implementations§
impl Freeze for CollisionBody1D
impl RefUnwindSafe for CollisionBody1D
impl Send for CollisionBody1D
impl Sync for CollisionBody1D
impl Unpin for CollisionBody1D
impl UnsafeUnpin for CollisionBody1D
impl UnwindSafe for CollisionBody1D
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