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>
impl<F: Field> FourMomentum<F>
Sourcepub fn new(e: F, px: F, py: F, pz: F) -> Self
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)
$
Sourcepub fn e(&self) -> F
pub fn e(&self) -> F
Returns the energy of the given FourMomentum
.
Sourcepub fn px(&self) -> F
pub fn px(&self) -> F
Returns the momentum along the $x
$-axis of the given FourMomentum
.
Sourcepub fn py(&self) -> F
pub fn py(&self) -> F
Returns the momentum along the $y
$-axis of the given FourMomentum
.
Sourcepub fn pz(&self) -> F
pub fn pz(&self) -> F
Returns the momentum along the $z
$-axis of the given FourMomentum
.
Sourcepub fn set_e(&mut self, value: F)
pub fn set_e(&mut self, value: F)
Sets the energy of the given FourMomentum
.
Sourcepub fn set_px(&mut self, value: F)
pub fn set_px(&mut self, value: F)
Sets the momentum along the $x
$-axis of the given FourMomentum
.
Sourcepub fn set_py(&mut self, value: F)
pub fn set_py(&mut self, value: F)
Sets the momentum along the $x
$-axis of the given FourMomentum
.
Sourcepub fn set_pz(&mut self, value: F)
pub fn set_pz(&mut self, value: F)
Sets the momentum along the $x
$-axis of the given FourMomentum
.
Sourcepub fn m2(&self) -> F
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)));
Sourcepub fn m(&self) -> F
pub fn m(&self) -> F
Calculate the invariant $m
$ for this FourMomentum
instance.
Calculates $m = \sqrt{E^2 - \vec{p}^2}
$
§See Also:
Sourcepub fn boost_along(&self, other: &Self) -> Self
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);
Sourcepub fn momentum(&self) -> Vector3<F>
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));
Sourcepub fn theta_cos(&self) -> F
pub fn theta_cos(&self) -> F
Returns the $\cos(\theta)
$ of the momentum 3-vector.
Alias for FourMomentum::costheta
.
Sourcepub fn beta3(&self) -> Vector3<F>
pub fn beta3(&self) -> Vector3<F>
Construct the 3-vector $\vec{\beta}
$ where
$\vec{\beta} = \frac{\vec{p}}{E}
$
Sourcepub fn boost_matrix(&self) -> Matrix4<F>
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>
impl<F: Field> Add for &FourMomentum<F>
Source§impl<F: Field> Add for FourMomentum<F>
impl<F: Field> Add for FourMomentum<F>
Source§impl<F: Clone + Field + 'static> Clone for FourMomentum<F>
impl<F: Clone + Field + 'static> Clone for FourMomentum<F>
Source§fn clone(&self) -> FourMomentum<F>
fn clone(&self) -> FourMomentum<F>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<F: Default + Field + 'static> Default for FourMomentum<F>
impl<F: Default + Field + 'static> Default for FourMomentum<F>
Source§fn default() -> FourMomentum<F>
fn default() -> FourMomentum<F>
Source§impl<F: Field> Display for FourMomentum<F>
impl<F: Field> Display for FourMomentum<F>
Source§impl<F: Field> From<&FourMomentum<F>> for Vector4<F>
impl<F: Field> From<&FourMomentum<F>> for Vector4<F>
Source§fn from(val: &FourMomentum<F>) -> Self
fn from(val: &FourMomentum<F>) -> Self
Source§impl<F: Field> From<&Matrix<F, Const<4>, Const<1>, ArrayStorage<F, 4, 1>>> for FourMomentum<F>
impl<F: Field> From<&Matrix<F, Const<4>, Const<1>, ArrayStorage<F, 4, 1>>> for FourMomentum<F>
Source§impl<F: Field> From<FourMomentum<F>> for Vector4<F>
impl<F: Field> From<FourMomentum<F>> for Vector4<F>
Source§fn from(val: FourMomentum<F>) -> Self
fn from(val: FourMomentum<F>) -> Self
Source§impl<F: Field> From<Matrix<F, Const<4>, Const<1>, ArrayStorage<F, 4, 1>>> for FourMomentum<F>
impl<F: Field> From<Matrix<F, Const<4>, Const<1>, ArrayStorage<F, 4, 1>>> for FourMomentum<F>
Source§impl<F: Field> Sub for &FourMomentum<F>
impl<F: Field> Sub for &FourMomentum<F>
Source§impl<F: Field> Sub for FourMomentum<F>
impl<F: Field> Sub for FourMomentum<F>
Source§impl<F: Field> Sum for FourMomentum<F>
impl<F: Field> Sum for FourMomentum<F>
impl<F: Copy + Field + 'static> Copy for FourMomentum<F>
impl<F: Field> Eq for FourMomentum<F>
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> 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.