Struct rustitude_core::four_momentum::FourMomentum
source · pub struct FourMomentum(/* private fields */);
Implementations§
source§impl FourMomentum
impl FourMomentum
A four-momentum structure with helpful methods for boosts.
This is the basic structure of a Lorentz four-vector
of the form $(E, \overrightarrow{p})
$ where $E
$ is the energy and $\overrightarrow{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);
sourcepub const fn new(e: f64, px: f64, py: f64, pz: f64) -> Self
pub const fn new(e: f64, px: f64, py: f64, pz: f64) -> Self
Create a new FourMomentum
from energy and momentum components.
Components are listed in the order $(E, p_x, p_y, p_z)
$
pub fn e(&self) -> f64
pub fn px(&self) -> f64
pub fn py(&self) -> f64
pub fn pz(&self) -> f64
pub fn set_e(&mut self, value: f64)
pub fn set_px(&mut self, value: f64)
pub fn set_py(&mut self, value: f64)
pub fn set_pz(&mut self, value: f64)
sourcepub fn m2(&self) -> f64
pub fn m2(&self) -> f64
Calculate the invariant $ m^2 $ for this FourMomentum
instance.
Calculates $m^2 = E^2 - \overrightarrow{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) -> f64
pub fn m(&self) -> f64
Calculate the invariant $ m $ for this FourMomentum
instance.
Calculates $m = \sqrt{E^2 - \overrightarrow{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 $\overrightarrow{\beta}
$
vector of another FourMomentum
.
Calculates $\mathbf{\Lambda} \cdot \mathbf{x}
$
§Examples
#[macro_use]
use approx::*;
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_abs_diff_eq!(vec_a_COM.px(), 0.0, epsilon = 1e-15);
assert_abs_diff_eq!(vec_a_COM.py(), 0.0, epsilon = 1e-15);
assert_abs_diff_eq!(vec_a_COM.pz(), 0.0, epsilon = 1e-15);
source§impl FourMomentum
impl FourMomentum
sourcepub fn momentum(&self) -> Vector3<f64>
pub fn momentum(&self) -> Vector3<f64>
Extract the 3-momentum as a nalgebra::Vector3<f64>
§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 beta3(&self) -> Vector3<f64>
pub fn beta3(&self) -> Vector3<f64>
Construct the 3-vector $\overrightarrow{\beta}$ where
$\overrightarrow{\beta} = \frac{\overrightarrow{p}}{E}
$
sourcepub fn boost_matrix(&self) -> Matrix4<f64>
pub fn boost_matrix(&self) -> Matrix4<f64>
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}{\overrightarrow{\beta}^2} & (\gamma - 1) \frac{\beta_x \beta_y}{\overrightarrow{\beta}^2} & (\gamma - 1) \frac{\beta_x \beta_z}{\overrightarrow{\beta}^2} \\
-\gamma \beta_y & (\gamma - 1) \frac{\beta_y \beta_x}{\overrightarrow{\beta}^2} & 1 + (\gamma - 1) \frac{\beta_y^2}{\overrightarrow{\beta}^2} & (\gamma - 1) \frac{\beta_y \beta_z}{\overrightarrow{\beta}^2} \\
-\gamma \beta_z & (\gamma - 1) \frac{\beta_z \beta_x}{\overrightarrow{\beta}^2} & (\gamma - 1) \frac{\beta_z \beta_y}{\overrightarrow{\beta}^2} & 1 + (\gamma - 1) \frac{\beta_z^2}{\overrightarrow{\beta}^2}
\end{pmatrix}
where
$\overrightarrow{\beta} = \frac{\overrightarrow{p}}{E}
$ and $\gamma = \frac{1}{\sqrt{1 - \overrightarrow{\beta}^2}}
$.
Trait Implementations§
source§impl Add for &FourMomentum
impl Add for &FourMomentum
source§impl Add for FourMomentum
impl Add for FourMomentum
source§impl Clone for FourMomentum
impl Clone for FourMomentum
source§fn clone(&self) -> FourMomentum
fn clone(&self) -> FourMomentum
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for FourMomentum
impl Debug for FourMomentum
source§impl Default for FourMomentum
impl Default for FourMomentum
source§fn default() -> FourMomentum
fn default() -> FourMomentum
source§impl Display for FourMomentum
impl Display for FourMomentum
source§impl From<&FourMomentum> for Vector4<f64>
impl From<&FourMomentum> for Vector4<f64>
source§fn from(val: &FourMomentum) -> Self
fn from(val: &FourMomentum) -> Self
source§impl From<&Matrix<f64, Const<4>, Const<1>, ArrayStorage<f64, 4, 1>>> for FourMomentum
impl From<&Matrix<f64, Const<4>, Const<1>, ArrayStorage<f64, 4, 1>>> for FourMomentum
source§impl From<FourMomentum> for Vector4<f64>
impl From<FourMomentum> for Vector4<f64>
source§fn from(val: FourMomentum) -> Self
fn from(val: FourMomentum) -> Self
source§impl From<Matrix<f64, Const<4>, Const<1>, ArrayStorage<f64, 4, 1>>> for FourMomentum
impl From<Matrix<f64, Const<4>, Const<1>, ArrayStorage<f64, 4, 1>>> for FourMomentum
source§impl HasPyGilRef for FourMomentum
impl HasPyGilRef for FourMomentum
§type AsRefTarget = PyCell<FourMomentum>
type AsRefTarget = PyCell<FourMomentum>
source§impl PartialEq for FourMomentum
impl PartialEq for FourMomentum
source§fn eq(&self, other: &FourMomentum) -> bool
fn eq(&self, other: &FourMomentum) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PyClassImpl for FourMomentum
impl PyClassImpl for FourMomentum
source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
§type ThreadChecker = SendablePyClass<FourMomentum>
type ThreadChecker = SendablePyClass<FourMomentum>
§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny
by default, and when you declare
#[pyclass(extends=PyDict)]
, it’s PyDict
.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
source§impl PyClassNewTextSignature<FourMomentum> for PyClassImplCollector<FourMomentum>
impl PyClassNewTextSignature<FourMomentum> for PyClassImplCollector<FourMomentum>
fn new_text_signature(self) -> Option<&'static str>
source§impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a FourMomentum
impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a FourMomentum
source§impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a mut FourMomentum
impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a mut FourMomentum
source§impl PyMethods<FourMomentum> for PyClassImplCollector<FourMomentum>
impl PyMethods<FourMomentum> for PyClassImplCollector<FourMomentum>
fn py_methods(self) -> &'static PyClassItems
source§impl PyTypeInfo for FourMomentum
impl PyTypeInfo for FourMomentum
source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
source§fn type_object(py: Python<'_>) -> &PyType
fn type_object(py: Python<'_>) -> &PyType
PyTypeInfo::type_object
will be replaced by PyTypeInfo::type_object_bound
in a future PyO3 versionsource§fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
source§fn is_type_of(object: &PyAny) -> bool
fn is_type_of(object: &PyAny) -> bool
PyTypeInfo::is_type_of
will be replaced by PyTypeInfo::is_type_of_bound
in a future PyO3 versionobject
is an instance of this type or a subclass of this type.source§fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
object
is an instance of this type or a subclass of this type.source§fn is_exact_type_of(object: &PyAny) -> bool
fn is_exact_type_of(object: &PyAny) -> bool
PyTypeInfo::is_exact_type_of
will be replaced by PyTypeInfo::is_exact_type_of_bound
in a future PyO3 versionobject
is an instance of this type.source§impl Sub for &FourMomentum
impl Sub for &FourMomentum
source§impl Sub for FourMomentum
impl Sub for FourMomentum
source§impl<'a> Sum<&'a FourMomentum> for FourMomentum
impl<'a> Sum<&'a FourMomentum> for FourMomentum
impl Copy for FourMomentum
impl DerefToPyAny for FourMomentum
impl Eq for FourMomentum
impl StructuralPartialEq for FourMomentum
Auto Trait Implementations§
impl Freeze for FourMomentum
impl RefUnwindSafe for FourMomentum
impl Send for FourMomentum
impl Sync for FourMomentum
impl Unpin for FourMomentum
impl UnwindSafe for FourMomentum
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> FromPyObject<'_> for T
impl<T> FromPyObject<'_> for T
source§impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
T: FromPyObject<'py>,
impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
T: FromPyObject<'py>,
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<T> PyErrArguments for T
impl<T> PyErrArguments for T
source§impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
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.