Skip to main content

RealVec4

Struct RealVec4 

Source
pub struct RealVec4 {
    pub e: f64,
    pub px: f64,
    pub py: f64,
    pub pz: f64,
}
Expand description

A four-vector (Lorentz vector) stored in (E, p_x, p_y, p_z) order.

§Examples

use laddu_physics::vectors::{RealVec3, RealVec4};

let momentum = RealVec3::new(1.0, 0.0, 0.0);
let four_vector = momentum.with_mass(2.0);
assert!((four_vector.m2() - 4.0).abs() < 1e-12);

Fields§

§e: f64

Energy component.

§px: f64

Momentum in the x direction.

§py: f64

Momentum in the y direction.

§pz: f64

Momentum in the z direction.

Implementations§

Source§

impl RealVec4

Source

pub fn new(e: f64, px: f64, py: f64, pz: f64) -> RealVec4

Create a four-vector in metric order (E, p_x, p_y, p_z).

Source

pub fn px(&self) -> f64

Momentum in the x-direction

Source

pub fn py(&self) -> f64

Momentum in the y-direction

Source

pub fn pz(&self) -> f64

Momentum in the z-direction

Source

pub fn e(&self) -> f64

The energy of the 4-vector

Source

pub fn momentum(&self) -> RealVec3

The 3-momentum

Source

pub fn gamma(&self) -> Result<f64, LadduPhysicsError>

The $\gamma$ factor $\frac{1}{\sqrt{1 - \beta^2}}$.

§Errors

Returns LadduPhysicsError when the energy is not positive or the resulting velocity is not subluminal.

Source

pub fn beta(&self) -> Result<RealVec3, LadduPhysicsError>

The $\vec{\beta}$ vector $\frac{\vec{p}}{E}$.

§Errors

Returns LadduPhysicsError when the four-momentum energy is not positive.

Source

pub fn m(&self) -> Result<f64, LadduPhysicsError>

The invariant mass corresponding to this 4-momentum

§Errors

Returns LadduPhysicsError when the invariant mass squared is non-finite or negative.

Source

pub fn m_unchecked(&self) -> f64

Return the invariant mass without checking for a spacelike vector.

Source

pub fn signed_m(&self) -> Result<f64, LadduPhysicsError>

Return the signed invariant mass.

§Errors

Returns LadduPhysicsError when the invariant mass squared is non-finite.

Source

pub fn signed_m_unchecked(&self) -> f64

Return the signed invariant mass without checking for finite components.

Source

pub fn m2(&self) -> f64

The squared invariant mass corresponding to this 4-momentum

Source

pub fn dot(&self, other: &RealVec4) -> f64

Compute the Lorentz inner product with another four-vector.

Source

pub fn to_p4_string(&self) -> String

Pretty-prints the four-momentum.

Source

pub fn mag(&self) -> Result<f64, LadduPhysicsError>

Alias for Self::m using the $+---$ metric.

§Errors

Returns LadduPhysicsError for non-finite or spacelike four-vectors, where m2 < 0.

Source

pub fn signed_mag(&self) -> Result<f64, LadduPhysicsError>

Signed invariant mass useful for diagnostics:

  • sqrt(mag2) for timelike/null vectors
  • -sqrt(-mag2) for spacelike vectors
§Errors

Returns LadduPhysicsError when the invariant magnitude squared is non-finite.

Source

pub fn signed_mag_unchecked(&self) -> f64

Return the signed magnitude without checking for finite components.

Source

pub fn mag2(&self) -> f64

Alias for Self::m2, the squared invariant mass in the $+---$ metric.

Source

pub fn boost(&self, beta: &RealVec3) -> RealVec4

Gives the vector boosted along a $\vec{\beta}$ vector.

Source

pub fn vec3(&self) -> RealVec3

The 3-vector contained in this 4-vector

Trait Implementations§

Source§

impl AbsDiffEq for RealVec4

Source§

type Epsilon = <f64 as AbsDiffEq>::Epsilon

Used for specifying relative comparisons.
Source§

fn default_epsilon() -> <RealVec4 as AbsDiffEq>::Epsilon

The default tolerance to use when testing values that are close together. Read more
Source§

fn abs_diff_eq( &self, other: &RealVec4, epsilon: <RealVec4 as AbsDiffEq>::Epsilon, ) -> bool

A test for equality that uses the absolute difference to compute the approximate equality of two numbers.
Source§

fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool

The inverse of AbsDiffEq::abs_diff_eq.
Source§

impl Add for RealVec4

Source§

type Output = RealVec4

The resulting type after applying the + operator.
Source§

fn add(self, rhs: RealVec4) -> <RealVec4 as Add>::Output

Performs the + operation. Read more
Source§

impl Add<&RealVec4> for &RealVec4

Source§

type Output = RealVec4

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &RealVec4) -> <&RealVec4 as Add<&RealVec4>>::Output

Performs the + operation. Read more
Source§

impl Add<&RealVec4> for RealVec4

Source§

type Output = RealVec4

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &RealVec4) -> <RealVec4 as Add<&RealVec4>>::Output

Performs the + operation. Read more
Source§

impl Add<RealVec4> for &RealVec4

Source§

type Output = RealVec4

The resulting type after applying the + operator.
Source§

fn add(self, rhs: RealVec4) -> <&RealVec4 as Add<RealVec4>>::Output

Performs the + operation. Read more
Source§

impl Clone for RealVec4

Source§

fn clone(&self) -> RealVec4

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for RealVec4

Source§

impl Debug for RealVec4

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for RealVec4

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<RealVec4, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for RealVec4

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl From<Matrix<f64, Const<4>, Const<1>, ArrayStorage<f64, 4, 1>>> for RealVec4

Source§

fn from( value: Matrix<f64, Const<4>, Const<1>, ArrayStorage<f64, 4, 1>>, ) -> RealVec4

Converts to this type from the input type.
Source§

impl From<[f64; 4]> for RealVec4

Source§

fn from(value: [f64; 4]) -> RealVec4

Converts to this type from the input type.
Source§

impl Neg for &RealVec4

Source§

type Output = RealVec4

The resulting type after applying the - operator.
Source§

fn neg(self) -> <&RealVec4 as Neg>::Output

Performs the unary - operation. Read more
Source§

impl Neg for RealVec4

Source§

type Output = RealVec4

The resulting type after applying the - operator.
Source§

fn neg(self) -> <RealVec4 as Neg>::Output

Performs the unary - operation. Read more
Source§

impl PartialEq for RealVec4

Source§

fn eq(&self, other: &RealVec4) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl RelativeEq for RealVec4

Source§

fn default_max_relative() -> <RealVec4 as AbsDiffEq>::Epsilon

The default relative tolerance for testing values that are far-apart. Read more
Source§

fn relative_eq( &self, other: &RealVec4, epsilon: <RealVec4 as AbsDiffEq>::Epsilon, max_relative: <RealVec4 as AbsDiffEq>::Epsilon, ) -> bool

A test for equality that uses a relative comparison if the values are far apart.
Source§

fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool

The inverse of RelativeEq::relative_eq.
Source§

impl Serialize for RealVec4

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for RealVec4

Source§

impl Sub for RealVec4

Source§

type Output = RealVec4

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: RealVec4) -> <RealVec4 as Sub>::Output

Performs the - operation. Read more
Source§

impl Sub<&RealVec4> for &RealVec4

Source§

type Output = RealVec4

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &RealVec4) -> <&RealVec4 as Sub<&RealVec4>>::Output

Performs the - operation. Read more
Source§

impl Sub<&RealVec4> for RealVec4

Source§

type Output = RealVec4

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &RealVec4) -> <RealVec4 as Sub<&RealVec4>>::Output

Performs the - operation. Read more
Source§

impl Sub<RealVec4> for &RealVec4

Source§

type Output = RealVec4

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: RealVec4) -> <&RealVec4 as Sub<RealVec4>>::Output

Performs the - operation. Read more
Source§

impl Sum for RealVec4

Source§

fn sum<I>(iter: I) -> RealVec4
where I: Iterator<Item = RealVec4>,

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl<'a> Sum<&'a RealVec4> for RealVec4

Source§

fn sum<I>(iter: I) -> RealVec4
where I: Iterator<Item = &'a RealVec4>,

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl TryFrom<Vec<f64>> for RealVec4

Source§

type Error = LadduPhysicsError

The type returned in the event of a conversion error.
Source§

fn try_from( value: Vec<f64>, ) -> Result<RealVec4, <RealVec4 as TryFrom<Vec<f64>>>::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Any for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Source§

fn type_name(&self) -> &'static str

Source§

impl<T> AnySync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ClosedNeg for T
where T: Neg<Output = T>,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.