pub type UnitVector6<T> = Unit<Matrix<T, Const<nalgebra::::base::dimension::U6::{constant#0}>, Const<1>, ArrayStorage<T, 6, 1>>>;
Expand description

A stack-allocated, 6-dimensional unit vector.

Aliased Type§

struct UnitVector6<T> { /* private fields */ }

Implementations§

source§

impl<T> Unit<T>where T: Normed,

source

pub fn new_normalize(value: T) -> Unit<T>

Normalize the given vector and return it wrapped on a Unit structure.

source

pub fn try_new(value: T, min_norm: <T as Normed>::Norm) -> Option<Unit<T>>where <T as Normed>::Norm: RealField,

Attempts to normalize the given vector and return it wrapped on a Unit structure.

Returns None if the norm was smaller or equal to min_norm.

source

pub fn new_and_get(value: T) -> (Unit<T>, <T as Normed>::Norm)

Normalize the given vector and return it wrapped on a Unit structure and its norm.

source

pub fn try_new_and_get( value: T, min_norm: <T as Normed>::Norm ) -> Option<(Unit<T>, <T as Normed>::Norm)>where <T as Normed>::Norm: RealField,

Normalize the given vector and return it wrapped on a Unit structure and its norm.

Returns None if the norm was smaller or equal to min_norm.

source

pub fn renormalize(&mut self) -> <T as Normed>::Norm

Normalizes this vector again. This is useful when repeated computations might cause a drift in the norm because of float inaccuracies.

Returns the norm before re-normalization. See .renormalize_fast for a faster alternative that may be slightly less accurate if self drifted significantly from having a unit length.

source

pub fn renormalize_fast(&mut self)

Normalizes this vector again using a first-order Taylor approximation. This is useful when repeated computations might cause a drift in the norm because of float inaccuracies.

source§

impl<T> Unit<T>

source

pub const fn new_unchecked(value: T) -> Unit<T>

Wraps the given value, assuming it is already normalized.

source

pub fn from_ref_unchecked(value: &T) -> &Unit<T>

Wraps the given reference, assuming it is already normalized.

source

pub fn into_inner(self) -> T

Retrieves the underlying value.

source

pub fn unwrap(self) -> T

👎Deprecated: use .into_inner() instead

Retrieves the underlying value. Deprecated: use Unit::into_inner instead.

source

pub fn as_mut_unchecked(&mut self) -> &mut T

Returns a mutable reference to the underlying value. This is _unchecked because modifying the underlying value in such a way that it no longer has unit length may lead to unexpected results.

source§

impl<T, D, S> Unit<Matrix<T, D, Const<1>, S>>where T: RealField, D: Dim, S: Storage<T, D, Const<1>>,

source

pub fn slerp<S2>( &self, rhs: &Unit<Matrix<T, D, Const<1>, S2>>, t: T ) -> Unit<Matrix<T, D, Const<1>, <DefaultAllocator as Allocator<T, D, Const<1>>>::Buffer>>where S2: Storage<T, D, Const<1>>, DefaultAllocator: Allocator<T, D, Const<1>>,

Computes the spherical linear interpolation between two unit vectors.

Examples:

let v1 = Unit::new_normalize(Vector2::new(1.0, 2.0));
let v2 = Unit::new_normalize(Vector2::new(2.0, -3.0));

let v = v1.slerp(&v2, 1.0);

assert_eq!(v, v2);
source

pub fn try_slerp<S2>( &self, rhs: &Unit<Matrix<T, D, Const<1>, S2>>, t: T, epsilon: T ) -> Option<Unit<Matrix<T, D, Const<1>, <DefaultAllocator as Allocator<T, D, Const<1>>>::Buffer>>>where S2: Storage<T, D, Const<1>>, DefaultAllocator: Allocator<T, D, Const<1>>,

Computes the spherical linear interpolation between two unit vectors.

Returns None if the two vectors are almost collinear and with opposite direction (in this case, there is an infinity of possible results).

Trait Implementations§

source§

impl<T, R, C, S> AbsDiffEq<Unit<Matrix<T, R, C, S>>> for Unit<Matrix<T, R, C, S>>where R: Dim, C: Dim, T: Scalar + AbsDiffEq<T>, S: RawStorage<T, R, C>, <T as AbsDiffEq<T>>::Epsilon: Clone,

§

type Epsilon = <T as AbsDiffEq<T>>::Epsilon

Used for specifying relative comparisons.
source§

fn default_epsilon( ) -> <Unit<Matrix<T, R, C, S>> as AbsDiffEq<Unit<Matrix<T, R, C, S>>>>::Epsilon

The default tolerance to use when testing values that are close together. Read more
source§

fn abs_diff_eq( &self, other: &Unit<Matrix<T, R, C, S>>, epsilon: <Unit<Matrix<T, R, C, S>> as AbsDiffEq<Unit<Matrix<T, R, C, S>>>>::Epsilon ) -> bool

A test for equality that uses the absolute difference to compute the approximate equality of two numbers.
§

fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool

The inverse of [AbsDiffEq::abs_diff_eq].
source§

impl<T> AsRef<T> for Unit<T>

source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<T> Clone for Unit<T>where T: Clone,

source§

fn clone(&self) -> Unit<T>

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<T> Debug for Unit<T>where T: Debug,

source§

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

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

impl<T> Deref for Unit<T>

§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &T

Dereferences the value.
source§

impl<'de, T> Deserialize<'de> for Unit<T>where T: Deserialize<'de>,

source§

fn deserialize<D>( deserializer: D ) -> Result<Unit<T>, <D as Deserializer<'de>>::Error>where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<T, R, C> From<[Unit<Matrix<<T as SimdValue>::Element, R, C, <DefaultAllocator as Allocator<<T as SimdValue>::Element, R, C>>::Buffer>>; 16]> for Unit<Matrix<T, R, C, <DefaultAllocator as Allocator<T, R, C>>::Buffer>>where T: Scalar + PrimitiveSimdValue + From<[<T as SimdValue>::Element; 16]>, R: Dim, C: Dim, <T as SimdValue>::Element: Scalar, DefaultAllocator: Allocator<T, R, C> + Allocator<<T as SimdValue>::Element, R, C>,

source§

fn from( arr: [Unit<Matrix<<T as SimdValue>::Element, R, C, <DefaultAllocator as Allocator<<T as SimdValue>::Element, R, C>>::Buffer>>; 16] ) -> Unit<Matrix<T, R, C, <DefaultAllocator as Allocator<T, R, C>>::Buffer>>

Converts to this type from the input type.
source§

impl<T, R, C> From<[Unit<Matrix<<T as SimdValue>::Element, R, C, <DefaultAllocator as Allocator<<T as SimdValue>::Element, R, C>>::Buffer>>; 2]> for Unit<Matrix<T, R, C, <DefaultAllocator as Allocator<T, R, C>>::Buffer>>where T: Scalar + PrimitiveSimdValue + From<[<T as SimdValue>::Element; 2]>, R: Dim, C: Dim, <T as SimdValue>::Element: Scalar, DefaultAllocator: Allocator<T, R, C> + Allocator<<T as SimdValue>::Element, R, C>,

source§

fn from( arr: [Unit<Matrix<<T as SimdValue>::Element, R, C, <DefaultAllocator as Allocator<<T as SimdValue>::Element, R, C>>::Buffer>>; 2] ) -> Unit<Matrix<T, R, C, <DefaultAllocator as Allocator<T, R, C>>::Buffer>>

Converts to this type from the input type.
source§

impl<T, R, C> From<[Unit<Matrix<<T as SimdValue>::Element, R, C, <DefaultAllocator as Allocator<<T as SimdValue>::Element, R, C>>::Buffer>>; 4]> for Unit<Matrix<T, R, C, <DefaultAllocator as Allocator<T, R, C>>::Buffer>>where T: Scalar + PrimitiveSimdValue + From<[<T as SimdValue>::Element; 4]>, R: Dim, C: Dim, <T as SimdValue>::Element: Scalar, DefaultAllocator: Allocator<T, R, C> + Allocator<<T as SimdValue>::Element, R, C>,

source§

fn from( arr: [Unit<Matrix<<T as SimdValue>::Element, R, C, <DefaultAllocator as Allocator<<T as SimdValue>::Element, R, C>>::Buffer>>; 4] ) -> Unit<Matrix<T, R, C, <DefaultAllocator as Allocator<T, R, C>>::Buffer>>

Converts to this type from the input type.
source§

impl<T, R, C> From<[Unit<Matrix<<T as SimdValue>::Element, R, C, <DefaultAllocator as Allocator<<T as SimdValue>::Element, R, C>>::Buffer>>; 8]> for Unit<Matrix<T, R, C, <DefaultAllocator as Allocator<T, R, C>>::Buffer>>where T: Scalar + PrimitiveSimdValue + From<[<T as SimdValue>::Element; 8]>, R: Dim, C: Dim, <T as SimdValue>::Element: Scalar, DefaultAllocator: Allocator<T, R, C> + Allocator<<T as SimdValue>::Element, R, C>,

source§

fn from( arr: [Unit<Matrix<<T as SimdValue>::Element, R, C, <DefaultAllocator as Allocator<<T as SimdValue>::Element, R, C>>::Buffer>>; 8] ) -> Unit<Matrix<T, R, C, <DefaultAllocator as Allocator<T, R, C>>::Buffer>>

Converts to this type from the input type.
source§

impl<T> Hash for Unit<T>where T: Hash,

source§

fn hash<__H>(&self, state: &mut __H)where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T, R, C> Neg for Unit<Matrix<T, R, C, <DefaultAllocator as Allocator<T, R, C>>::Buffer>>where T: Scalar + ClosedNeg, R: Dim, C: Dim, DefaultAllocator: Allocator<T, R, C>,

§

type Output = Unit<Matrix<T, R, C, <DefaultAllocator as Allocator<T, R, C>>::Buffer>>

The resulting type after applying the - operator.
source§

fn neg( self ) -> <Unit<Matrix<T, R, C, <DefaultAllocator as Allocator<T, R, C>>::Buffer>> as Neg>::Output

Performs the unary - operation. Read more
source§

impl<T, R, C, S> PartialEq<Unit<Matrix<T, R, C, S>>> for Unit<Matrix<T, R, C, S>>where T: Scalar + PartialEq<T>, R: Dim, C: Dim, S: RawStorage<T, R, C>,

source§

fn eq(&self, rhs: &Unit<Matrix<T, R, C, S>>) -> 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<T, R, C, S> RelativeEq<Unit<Matrix<T, R, C, S>>> for Unit<Matrix<T, R, C, S>>where R: Dim, C: Dim, T: Scalar + RelativeEq<T>, S: Storage<T, R, C>, <T as AbsDiffEq<T>>::Epsilon: Clone,

source§

fn default_max_relative( ) -> <Unit<Matrix<T, R, C, S>> as AbsDiffEq<Unit<Matrix<T, R, C, S>>>>::Epsilon

The default relative tolerance for testing values that are far-apart. Read more
source§

fn relative_eq( &self, other: &Unit<Matrix<T, R, C, S>>, epsilon: <Unit<Matrix<T, R, C, S>> as AbsDiffEq<Unit<Matrix<T, R, C, S>>>>::Epsilon, max_relative: <Unit<Matrix<T, R, C, S>> as AbsDiffEq<Unit<Matrix<T, R, C, S>>>>::Epsilon ) -> bool

A test for equality that uses a relative comparison if the values are far apart.
§

fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon ) -> bool

The inverse of [RelativeEq::relative_eq].
source§

impl<T> Serialize for Unit<T>where T: Serialize,

source§

fn serialize<S>( &self, serializer: S ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<T, R, C, S> UlpsEq<Unit<Matrix<T, R, C, S>>> for Unit<Matrix<T, R, C, S>>where R: Dim, C: Dim, T: Scalar + UlpsEq<T>, S: RawStorage<T, R, C>, <T as AbsDiffEq<T>>::Epsilon: Clone,

source§

fn default_max_ulps() -> u32

The default ULPs to tolerate when testing values that are far-apart. Read more
source§

fn ulps_eq( &self, other: &Unit<Matrix<T, R, C, S>>, epsilon: <Unit<Matrix<T, R, C, S>> as AbsDiffEq<Unit<Matrix<T, R, C, S>>>>::Epsilon, max_ulps: u32 ) -> bool

A test for equality that uses units in the last place (ULP) if the values are far apart.
§

fn ulps_ne(&self, other: &Rhs, epsilon: Self::Epsilon, max_ulps: u32) -> bool

The inverse of [UlpsEq::ulps_eq].
source§

impl<T> Copy for Unit<T>where T: Copy,

source§

impl<T, R, C, S> Eq for Unit<Matrix<T, R, C, S>>where T: Scalar + Eq, R: Dim, C: Dim, S: RawStorage<T, R, C>,