pub struct RelativisticBody {
pub rest_mass: f64,
pub velocity: f64,
}Expand description
A body with scalar rest mass and signed velocity.
Fields§
§rest_mass: f64Rest mass in kilograms.
velocity: f64Signed velocity in meters per second.
Implementations§
Source§impl RelativisticBody
impl RelativisticBody
Sourcepub fn new(rest_mass: f64, velocity: f64) -> Option<Self>
pub fn new(rest_mass: f64, velocity: f64) -> Option<Self>
Creates a relativistic body when rest_mass is finite and non-negative and velocity is
finite with a magnitude strictly less than the speed of light.
Sourcepub fn beta(&self) -> Option<f64>
pub fn beta(&self) -> Option<f64>
Computes the speed ratio magnitude β for the body’s current velocity.
Sourcepub fn lorentz_factor(&self) -> Option<f64>
pub fn lorentz_factor(&self) -> Option<f64>
Computes the Lorentz factor γ for the body’s current speed magnitude.
Sourcepub fn rest_energy(&self) -> Option<f64>
pub fn rest_energy(&self) -> Option<f64>
Computes the body’s rest energy in joules.
Sourcepub fn total_energy(&self) -> Option<f64>
pub fn total_energy(&self) -> Option<f64>
Computes the body’s total relativistic energy in joules.
§Examples
use use_relativity::{RelativisticBody, SPEED_OF_LIGHT};
let body = RelativisticBody::new(1.0, SPEED_OF_LIGHT * 0.6).unwrap();
let expected = 1.25 * SPEED_OF_LIGHT * SPEED_OF_LIGHT;
assert!((body.total_energy().unwrap() - expected).abs() < 1.0e-3);Sourcepub fn kinetic_energy(&self) -> Option<f64>
pub fn kinetic_energy(&self) -> Option<f64>
Computes the body’s relativistic kinetic energy in joules.
Trait Implementations§
Source§impl Clone for RelativisticBody
impl Clone for RelativisticBody
Source§fn clone(&self) -> RelativisticBody
fn clone(&self) -> RelativisticBody
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 RelativisticBody
impl Debug for RelativisticBody
Source§impl PartialEq for RelativisticBody
impl PartialEq for RelativisticBody
Source§fn eq(&self, other: &RelativisticBody) -> bool
fn eq(&self, other: &RelativisticBody) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Copy for RelativisticBody
impl StructuralPartialEq for RelativisticBody
Auto Trait Implementations§
impl Freeze for RelativisticBody
impl RefUnwindSafe for RelativisticBody
impl Send for RelativisticBody
impl Sync for RelativisticBody
impl Unpin for RelativisticBody
impl UnsafeUnpin for RelativisticBody
impl UnwindSafe for RelativisticBody
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