pub struct FrameN<N, D>{ /* private fields */ }
Expand description

Inertial frame of reference in $n$-dimensional Lorentzian space $\R^{-,+} = \R^{1,n-1}$.

Holds a statically sized direction axis $\hat u \in \R^{n-1}$ and two boost parameters precomputed from either velocity $u^\mu$, rapidity $\vec \zeta$, or velocity ratio $\vec \beta$ whether using Self::from_velocity, Self::from_zeta, or Self::from_beta:

$$ \cosh \zeta = \gamma $$

$$ \sinh \zeta = \beta \gamma $$

Where $\gamma$ is the Lorentz factor.

Implementations§

source§

impl<N, D> FrameN<N, D>

source

pub fn from_velocity<R, C>(u: &OMatrix<N, R, C>) -> Self

Inertial frame of reference with velocity $u^\mu$.

source

pub fn from_zeta(scaled_axis: OVector<N, DimNameDiff<D, U1>>) -> Self

Inertial frame of reference with rapidity $\vec \zeta$.

source

pub fn from_axis_zeta( axis: Unit<OVector<N, DimNameDiff<D, U1>>>, zeta: N ) -> Self

Inertial frame of reference along $\hat u$ with rapidity $\zeta$.

source

pub fn from_beta(scaled_axis: OVector<N, DimNameDiff<D, U1>>) -> Self

Inertial frame of reference with velocity ratio $\vec \beta$.

source

pub fn from_axis_beta( axis: Unit<OVector<N, DimNameDiff<D, U1>>>, beta: N ) -> Self

Inertial frame of reference along $\hat u$ with velocity ratio $\beta$.

source

pub fn velocity(&self) -> OVector<N, D>

Velocity $u^\mu$.

source

pub fn axis(&self) -> Unit<OVector<N, DimNameDiff<D, U1>>>

Direction $\hat u$.

source

pub fn zeta(&self) -> N

Rapidity $\zeta$.

source

pub fn beta(&self) -> N

Velocity ratio $\beta$.

source

pub const fn gamma(&self) -> N

Lorentz factor $\gamma$.

source

pub const fn beta_gamma(&self) -> N

Product of velocity ratio $\beta$ and Lorentz factor $\gamma$.

source

pub fn compose(&self, frame: &Self) -> Self

Relativistic velocity addition self$\oplus$frame.

Equals frame.velocity().boost(&-self.clone()).frame().

source§

impl<N, D> FrameN<N, D>

source

pub fn axis_angle( &self, frame: &Self ) -> (Unit<OVector<N, DimNameDiff<D, U1>>>, N)

$ \gdef \Bu {B^{\mu’}_{\phantom {\mu’} \mu} (\vec \beta_u)} \gdef \Bv {B^{\mu’‘}_{\phantom {\mu’‘} \mu’} (\vec \beta_v)} \gdef \Puv {u \oplus v} \gdef \Buv {B^{\mu’}_{\phantom {\mu’} \mu} (\vec \beta_{\Puv})} \gdef \Ruv {R^{\mu’‘}_{\phantom {\mu’‘} \mu’} (\epsilon)} \gdef \Luv {\Lambda^{\mu’‘}_{\phantom {\mu’’} \mu} (\vec \beta_{\Puv})} $ Wigner rotation axis $\widehat {\vec \beta_u \times \vec \beta_v}$ and angle $\epsilon$ of the boost composition self$\oplus$frame.

The composition of two pure boosts, $\Bu$ to self followed by $\Bv$ to frame, results in a composition of a pure boost $\Buv$ and a non-vanishing spatial rotation $\Ruv$ for non-collinear boosts:

$$ \Luv = \Ruv \Buv = \Bv \Bu $$

$$ \epsilon = \arcsin \Bigg({ 1 + \gamma + \gamma_u + \gamma_v \over (1 + \gamma) (1 + \gamma_u) (1 + \gamma_v) } \gamma_u \gamma_v |\vec \beta_u \times \vec \beta_v| \Bigg) $$

$$ \gamma = \gamma_u \gamma_v (1 + \vec \beta_u \cdot \vec \beta_v) $$

use approx::{assert_abs_diff_ne, assert_ulps_eq};
use nalgebra::Vector3;
use nalgebra_spacetime::{Frame4, LorentzianN};

let u = Frame4::from_beta(Vector3::new(0.18, 0.73, 0.07));
let v = Frame4::from_beta(Vector3::new(0.41, 0.14, 0.25));

let ucv = u.compose(&v).axis();
let vcu = v.compose(&u).axis();

let (axis, angle) = u.axis_angle(&v);
let axis = axis.into_inner();

assert_abs_diff_ne!(angle, 0.0, epsilon = 1e-15);
assert_ulps_eq!(angle, ucv.angle(&vcu), epsilon = 1e-15);
assert_ulps_eq!(axis, ucv.cross(&vcu).normalize(), epsilon = 1e-15);
source

pub fn rotation(&self, frame: &Self) -> Matrix4<N>

Wigner rotation matrix $R(\widehat {\vec \beta_u \times \vec \beta_v}, \epsilon)$ of the boost composition self$\oplus$frame.

See Self::axis_angle for further details.

use approx::{assert_ulps_eq, assert_ulps_ne};
use nalgebra::{Matrix4, Vector3};
use nalgebra_spacetime::{Frame4, LorentzianN};

let u = Frame4::from_beta(Vector3::new(0.18, 0.73, 0.07));
let v = Frame4::from_beta(Vector3::new(0.41, 0.14, 0.25));
let ucv = u.compose(&v);
let vcu = v.compose(&u);

let boost_u = Matrix4::new_boost(&u);
let boost_v = Matrix4::new_boost(&v);
let boost_ucv = Matrix4::new_boost(&ucv);
let boost_vcu = Matrix4::new_boost(&vcu);

let rotation_ucv = u.rotation(&v);

assert_ulps_ne!(boost_ucv, boost_v * boost_u);
assert_ulps_ne!(boost_vcu, boost_u * boost_v);
assert_ulps_eq!(rotation_ucv * boost_ucv, boost_v * boost_u);
assert_ulps_eq!(boost_vcu * rotation_ucv, boost_v * boost_u);

Trait Implementations§

source§

impl<N, D> Add for FrameN<N, D>

§

type Output = FrameN<N, D>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<N, D> Clone for FrameN<N, D>

source§

fn clone(&self) -> FrameN<N, D>

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<N, D> Debug for FrameN<N, D>

source§

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

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

impl<N, D> From<FrameN<N, D>> for OVector<N, D>

source§

fn from(frame: FrameN<N, D>) -> Self

Converts to this type from the input type.
source§

impl<N, R, C> From<Matrix<N, R, C, <DefaultAllocator as Allocator<N, R, C>>::Buffer>> for FrameN<N, R>

source§

fn from(u: OMatrix<N, R, C>) -> Self

Converts to this type from the input type.
source§

impl<N, D> Neg for FrameN<N, D>

§

type Output = FrameN<N, D>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl<N, D> PartialEq for FrameN<N, D>

source§

fn eq(&self, other: &FrameN<N, D>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<N, D> Copy for FrameN<N, D>

source§

impl<N, D> Eq for FrameN<N, D>

source§

impl<N, D> StructuralEq for FrameN<N, D>

source§

impl<N, D> StructuralPartialEq for FrameN<N, D>

Auto Trait Implementations§

§

impl<N, D> !RefUnwindSafe for FrameN<N, D>

§

impl<N, D> !Send for FrameN<N, D>

§

impl<N, D> !Sync for FrameN<N, D>

§

impl<N, D> !Unpin for FrameN<N, D>

§

impl<N, D> !UnwindSafe for FrameN<N, D>

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> 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> 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> Same for T

§

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,

§

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

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

source§

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