pub struct FourVector {
pub t: f64,
pub x: f64,
pub y: f64,
pub z: f64,
}Expand description
A four-vector in Minkowski spacetime with signature (+, -, -, -).
Fields§
§t: f64§x: f64§y: f64§z: f64Implementations§
Source§impl FourVector
impl FourVector
pub fn new(t: f64, x: f64, y: f64, z: f64) -> Self
pub fn zero() -> Self
Sourcepub fn dot(&self, other: &FourVector) -> f64
pub fn dot(&self, other: &FourVector) -> f64
Minkowski dot product with signature (+, -, -, -).
Sourcepub fn norm(&self) -> f64
pub fn norm(&self) -> f64
Minkowski norm. Returns NaN for spacelike vectors if you take sqrt of negative.
Sourcepub fn spatial_magnitude(&self) -> f64
pub fn spatial_magnitude(&self) -> f64
Spatial magnitude.
Sourcepub fn boost(&self, velocity: Vec3, c: f64) -> FourVector
pub fn boost(&self, velocity: Vec3, c: f64) -> FourVector
Apply a Lorentz boost along an arbitrary direction.
Sourcepub fn scale(&self, s: f64) -> FourVector
pub fn scale(&self, s: f64) -> FourVector
Scale by a scalar.
Sourcepub fn add(&self, other: &FourVector) -> FourVector
pub fn add(&self, other: &FourVector) -> FourVector
Add two four-vectors.
Sourcepub fn sub(&self, other: &FourVector) -> FourVector
pub fn sub(&self, other: &FourVector) -> FourVector
Subtract another four-vector.
Trait Implementations§
Source§impl Add for FourVector
impl Add for FourVector
Source§type Output = FourVector
type Output = FourVector
The resulting type after applying the
+ operator.Source§fn add(self, rhs: FourVector) -> FourVector
fn add(self, rhs: FourVector) -> FourVector
Performs the
+ operation. Read moreSource§impl Clone for FourVector
impl Clone for FourVector
Source§fn clone(&self) -> FourVector
fn clone(&self) -> FourVector
Returns a duplicate of the value. Read more
1.0.0 · 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 FourVector
impl Debug for FourVector
Source§impl Mul<f64> for FourVector
impl Mul<f64> for FourVector
Source§type Output = FourVector
type Output = FourVector
The resulting type after applying the
* operator.Source§impl Neg for FourVector
impl Neg for FourVector
Source§type Output = FourVector
type Output = FourVector
The resulting type after applying the
- operator.Source§fn neg(self) -> FourVector
fn neg(self) -> FourVector
Performs the unary
- operation. Read moreSource§impl PartialEq for FourVector
impl PartialEq for FourVector
Source§impl Sub for FourVector
impl Sub for FourVector
Source§type Output = FourVector
type Output = FourVector
The resulting type after applying the
- operator.Source§fn sub(self, rhs: FourVector) -> FourVector
fn sub(self, rhs: FourVector) -> FourVector
Performs the
- operation. Read moreimpl Copy for FourVector
impl StructuralPartialEq for FourVector
Auto Trait Implementations§
impl Freeze for FourVector
impl RefUnwindSafe for FourVector
impl Send for FourVector
impl Sync for FourVector
impl Unpin for FourVector
impl UnsafeUnpin for FourVector
impl UnwindSafe for FourVector
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.