[][src]Struct nalgebra_spacetime::FrameN

pub struct FrameN<N, D> where
    N: Scalar,
    D: DimNameSub<U1>,
    DefaultAllocator: Allocator<N, DimNameDiff<D, U1>>, 
{ /* fields omitted */ }

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

impl<N, D> FrameN<N, D> where
    N: SimdRealField + Signed + Real,
    D: DimNameSub<U1>,
    DefaultAllocator: Allocator<N, DimNameDiff<D, U1>>, 
[src]

pub fn from_velocity<R, C>(u: &MatrixMN<N, R, C>) -> Self where
    R: Dim,
    C: Dim,
    ShapeConstraint: SameNumberOfRows<R, D> + SameNumberOfColumns<C, U1>,
    DefaultAllocator: Allocator<N, R, C>, 
[src]

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

pub fn from_zeta(scaled_axis: VectorN<N, DimNameDiff<D, U1>>) -> Self[src]

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

pub fn from_axis_zeta(
    axis: Unit<VectorN<N, DimNameDiff<D, U1>>>,
    zeta: N
) -> Self
[src]

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

pub fn from_beta(scaled_axis: VectorN<N, DimNameDiff<D, U1>>) -> Self[src]

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

pub fn from_axis_beta(
    axis: Unit<VectorN<N, DimNameDiff<D, U1>>>,
    beta: N
) -> Self
[src]

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

pub fn velocity(&self) -> VectorN<N, D> where
    DefaultAllocator: Allocator<N, D>, 
[src]

Velocity $u^\mu$.

pub fn axis(&self) -> Unit<VectorN<N, DimNameDiff<D, U1>>>[src]

Direction $\hat u$.

pub fn zeta(&self) -> N[src]

Rapidity $\zeta$.

pub fn beta(&self) -> N[src]

Velocity ratio $\beta$.

pub fn gamma(&self) -> N[src]

Lorentz factor $\gamma$.

pub fn beta_gamma(&self) -> N[src]

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

pub fn compose(&self, frame: &Self) -> Self where
    DefaultAllocator: Allocator<N, D>, 
[src]

Relativistic velocity addition self$\oplus$frame.

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

impl<N> FrameN<N, U4> where
    N: SimdRealField + Signed + Real,
    DefaultAllocator: Allocator<N, U3>, 
[src]

pub fn axis_angle(&self, frame: &Self) -> (Unit<Vector3<N>>, N)[src]

$ \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 nalgebra::Vector3;
use nalgebra_spacetime::{LorentzianN, Frame4};
use approx::{assert_abs_diff_ne, assert_ulps_eq};

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);

pub fn rotation(&self, frame: &Self) -> Matrix4<N> where
    N::Element: SimdRealField,
    DefaultAllocator: Allocator<N, U4, U4>, 
[src]

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 nalgebra::{Vector3, Matrix4};
use nalgebra_spacetime::{LorentzianN, Frame4};
use approx::{assert_ulps_eq, assert_ulps_ne};

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

impl<N, D> Add<FrameN<N, D>> for FrameN<N, D> where
    N: SimdRealField + Signed + Real,
    D: DimNameSub<U1>,
    DefaultAllocator: Allocator<N, DimNameDiff<D, U1>> + Allocator<N, D>, 
[src]

type Output = Self

The resulting type after applying the + operator.

impl<N: Clone, D: Clone> Clone for FrameN<N, D> where
    N: Scalar,
    D: DimNameSub<U1>,
    DefaultAllocator: Allocator<N, DimNameDiff<D, U1>>, 
[src]

impl<N, D> Copy for FrameN<N, D> where
    N: SimdRealField + Signed + Real,
    D: DimNameSub<U1>,
    DefaultAllocator: Allocator<N, DimNameDiff<D, U1>>,
    Owned<N, DimNameDiff<D, U1>>: Copy
[src]

impl<N: Debug, D: Debug> Debug for FrameN<N, D> where
    N: Scalar,
    D: DimNameSub<U1>,
    DefaultAllocator: Allocator<N, DimNameDiff<D, U1>>, 
[src]

impl<N: Eq, D: Eq> Eq for FrameN<N, D> where
    N: Scalar,
    D: DimNameSub<U1>,
    DefaultAllocator: Allocator<N, DimNameDiff<D, U1>>, 
[src]

impl<N, D> From<FrameN<N, D>> for VectorN<N, D> where
    N: SimdRealField + Signed + Real,
    D: DimNameSub<U1>,
    DefaultAllocator: Allocator<N, DimNameDiff<D, U1>> + Allocator<N, D>, 
[src]

impl<N, R, C> From<Matrix<N, R, C, <DefaultAllocator as Allocator<N, R, C>>::Buffer>> for FrameN<N, R> where
    N: SimdRealField + Signed + Real,
    R: DimNameSub<U1>,
    C: DimName,
    ShapeConstraint: SameNumberOfColumns<C, U1>,
    DefaultAllocator: Allocator<N, R, C> + Allocator<N, DimNameDiff<R, U1>>, 
[src]

impl<N, D> Neg for FrameN<N, D> where
    N: SimdRealField + Signed + Real,
    D: DimNameSub<U1>,
    DefaultAllocator: Allocator<N, DimNameDiff<D, U1>>, 
[src]

type Output = Self

The resulting type after applying the - operator.

impl<N: PartialEq, D: PartialEq> PartialEq<FrameN<N, D>> for FrameN<N, D> where
    N: Scalar,
    D: DimNameSub<U1>,
    DefaultAllocator: Allocator<N, DimNameDiff<D, U1>>, 
[src]

impl<N, D> StructuralEq for FrameN<N, D> where
    N: Scalar,
    D: DimNameSub<U1>,
    DefaultAllocator: Allocator<N, DimNameDiff<D, U1>>, 
[src]

impl<N, D> StructuralPartialEq for FrameN<N, D> where
    N: Scalar,
    D: DimNameSub<U1>,
    DefaultAllocator: Allocator<N, DimNameDiff<D, U1>>, 
[src]

Auto Trait Implementations

impl<N, D> !RefUnwindSafe for FrameN<N, D>[src]

impl<N, D> !Send for FrameN<N, D>[src]

impl<N, D> !Sync for FrameN<N, D>[src]

impl<N, D> !Unpin for FrameN<N, D>[src]

impl<N, D> !UnwindSafe for FrameN<N, D>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Scalar for T where
    T: PartialEq<T> + Copy + Any + Debug
[src]

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,