Struct FourMomentum

Source
pub struct FourMomentum<F: Field + 'static>(/* private fields */);
Expand description

Struct which holds energy and three-momentum as a four-vector.

A four-momentum structure with helpful methods for boosts.

This is the basic structure of a Lorentz four-vector of the form $(E, \vec{p})$ where $E$ is the energy and $\vec{p}$ is the momentum.

§Examples

use rustitude_core::prelude::*;

let vec_a = FourMomentum::new(1.3, 0.2, 0.3, 0.1);
let vec_b = FourMomentum::new(4.2, 0.5, 0.4, 0.5);

Implementations§

Source§

impl<F: Field> FourMomentum<F>

Source

pub fn new(e: F, px: F, py: F, pz: F) -> Self

Create a new FourMomentum from energy and momentum components.

Components are listed in the order $(E, p_x, p_y, p_z)$

Source

pub fn e(&self) -> F

Returns the energy of the given FourMomentum.

Source

pub fn px(&self) -> F

Returns the momentum along the $x$-axis of the given FourMomentum.

Source

pub fn py(&self) -> F

Returns the momentum along the $y$-axis of the given FourMomentum.

Source

pub fn pz(&self) -> F

Returns the momentum along the $z$-axis of the given FourMomentum.

Source

pub fn set_e(&mut self, value: F)

Sets the energy of the given FourMomentum.

Source

pub fn set_px(&mut self, value: F)

Sets the momentum along the $x$-axis of the given FourMomentum.

Source

pub fn set_py(&mut self, value: F)

Sets the momentum along the $x$-axis of the given FourMomentum.

Source

pub fn set_pz(&mut self, value: F)

Sets the momentum along the $x$-axis of the given FourMomentum.

Source

pub fn m2(&self) -> F

Calculate the invariant $m^2$ for this FourMomentum instance.

Calculates $m^2 = E^2 - \vec{p}^2$

§Examples
use rustitude_core::prelude::*;

let vec_a = FourMomentum::new(20.0, 1.0, 0.2, -0.1);
//assert_eq!(vec_a.m2(), 20.0 * 20.0 - (1.0 * 1.0 + 0.0 * 0.2 + (-0.1) * (-0.1)));
Source

pub fn m(&self) -> F

Calculate the invariant $m$ for this FourMomentum instance.

Calculates $m = \sqrt{E^2 - \vec{p}^2}$

§See Also:

FourMomentum::m2

Source

pub fn boost_along(&self, other: &Self) -> Self

Boosts an instance of FourMomentum along the $\vec{\beta}$ vector of another FourMomentum.

Calculates $\mathbf{\Lambda} \cdot \mathbf{x}$

§Examples
use rustitude_core::prelude::*;

let vec_a = FourMomentum::new(20.0, 1.0, -3.2, 4.0);
let vec_a_COM = vec_a.boost_along(&vec_a);
assert!(f64::abs(vec_a_COM.px()) < 1e-7);
assert!(f64::abs(vec_a_COM.py()) < 1e-7);
assert!(f64::abs(vec_a_COM.pz()) < 1e-7);
Source

pub fn momentum(&self) -> Vector3<F>

Extract the 3-momentum as a nalgebra::Vector3<Field>

§Examples
use rustitude_core::prelude::*;
use nalgebra::Vector3;

let vec_a = FourMomentum::new(20.0, 1.0, 0.2, -0.1);
assert_eq!(vec_a.momentum(), Vector3::new(1.0, 0.2, -0.1));
Source

pub fn costheta(&self) -> F

Returns the $\cos(\theta)$ of the momentum 3-vector.

Source

pub fn theta_cos(&self) -> F

Returns the $\cos(\theta)$ of the momentum 3-vector.

Alias for FourMomentum::costheta.

Source

pub fn theta(&self) -> F

Returns the $\theta$ polar angle of the momentum 3-vector.

Source

pub fn phi(&self) -> F

Returns the $\phi$ azimuthal angle of the momentum 3-vector.

Source

pub fn beta3(&self) -> Vector3<F>

Construct the 3-vector $\vec{\beta}$ where

$\vec{\beta} = \frac{\vec{p}}{E}$

Source

pub fn direction(&self) -> Vector3<F>

Constructs the 3-vector normal to the 3-momentum

Source

pub fn boost_matrix(&self) -> Matrix4<F>

Construct the Lorentz boost matrix $\mathbf{\Lambda}$ where

\mathbf{\Lambda} = \begin{pmatrix}
\gamma & -\gamma \beta_x & -\gamma \beta_y & -\gamma \beta_z \\
-\gamma \beta_x & 1 + (\gamma - 1) \frac{\beta_x^2}{\vec{\beta}^2} & (\gamma - 1) \frac{\beta_x \beta_y}{\vec{\beta}^2} & (\gamma - 1) \frac{\beta_x \beta_z}{\vec{\beta}^2} \\
-\gamma \beta_y & (\gamma - 1) \frac{\beta_y \beta_x}{\vec{\beta}^2} & 1 + (\gamma - 1) \frac{\beta_y^2}{\vec{\beta}^2} & (\gamma - 1) \frac{\beta_y \beta_z}{\vec{\beta}^2} \\
-\gamma \beta_z & (\gamma - 1) \frac{\beta_z \beta_x}{\vec{\beta}^2} & (\gamma - 1) \frac{\beta_z \beta_y}{\vec{\beta}^2} & 1 + (\gamma - 1) \frac{\beta_z^2}{\vec{\beta}^2}
\end{pmatrix}

where $\vec{\beta} = \frac{\vec{p}}{E}$ and $\gamma = \frac{1}{\sqrt{1 - \vec{\beta}^2}}$.

Trait Implementations§

Source§

impl<F: Field> Add for &FourMomentum<F>

Source§

type Output = <FourMomentum<F> as Add>::Output

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &FourMomentum<F>) -> Self::Output

Performs the + operation. Read more
Source§

impl<F: Field> Add for FourMomentum<F>

Source§

type Output = FourMomentum<F>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<F: Clone + Field + 'static> Clone for FourMomentum<F>

Source§

fn clone(&self) -> FourMomentum<F>

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<F: Debug + Field + 'static> Debug for FourMomentum<F>

Source§

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

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

impl<F: Default + Field + 'static> Default for FourMomentum<F>

Source§

fn default() -> FourMomentum<F>

Returns the “default value” for a type. Read more
Source§

impl<F: Field> Display for FourMomentum<F>

Source§

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

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

impl<F: Field> From<&FourMomentum<F>> for Vector4<F>

Source§

fn from(val: &FourMomentum<F>) -> Self

Converts to this type from the input type.
Source§

impl<F: Field> From<&Matrix<F, Const<4>, Const<1>, ArrayStorage<F, 4, 1>>> for FourMomentum<F>

Source§

fn from(value: &Vector4<F>) -> Self

Converts to this type from the input type.
Source§

impl<F: Field> From<&Vec<F>> for FourMomentum<F>

Source§

fn from(value: &Vec<F>) -> Self

Converts to this type from the input type.
Source§

impl<F: Field> From<FourMomentum<F>> for Vector4<F>

Source§

fn from(val: FourMomentum<F>) -> Self

Converts to this type from the input type.
Source§

impl<F: Field> From<Matrix<F, Const<4>, Const<1>, ArrayStorage<F, 4, 1>>> for FourMomentum<F>

Source§

fn from(value: Vector4<F>) -> Self

Converts to this type from the input type.
Source§

impl<F: Field> From<Vec<F>> for FourMomentum<F>

Source§

fn from(value: Vec<F>) -> Self

Converts to this type from the input type.
Source§

impl<F: PartialEq + Field + 'static> PartialEq for FourMomentum<F>

Source§

fn eq(&self, other: &FourMomentum<F>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<F: Field> Sub for &FourMomentum<F>

Source§

type Output = <FourMomentum<F> as Sub>::Output

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &FourMomentum<F>) -> Self::Output

Performs the - operation. Read more
Source§

impl<F: Field> Sub for FourMomentum<F>

Source§

type Output = FourMomentum<F>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl<F: Field> Sum for FourMomentum<F>

Source§

fn sum<I: Iterator<Item = Self>>(iter: I) -> Self

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

impl<F: Copy + Field + 'static> Copy for FourMomentum<F>

Source§

impl<F: Field> Eq for FourMomentum<F>

Source§

impl<F: Field + 'static> StructuralPartialEq for FourMomentum<F>

Auto Trait Implementations§

§

impl<F> Freeze for FourMomentum<F>
where F: Freeze,

§

impl<F> RefUnwindSafe for FourMomentum<F>
where F: RefUnwindSafe,

§

impl<F> Send for FourMomentum<F>

§

impl<F> Sync for FourMomentum<F>

§

impl<F> Unpin for FourMomentum<F>
where F: Unpin,

§

impl<F> UnwindSafe for FourMomentum<F>
where F: UnwindSafe,

Blanket Implementations§

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 + Sync + Send>

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<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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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

Source§

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

Source§

impl<T> Ungil for T
where T: Send,