pub type UnitVector6<T> = Unit<Matrix<T, U6, U1, ArrayStorage<T, 6, 1>>>;
Expand description
A stack-allocated, 6-dimensional unit vector.
Aliased Type§
struct UnitVector6<T> { /* private fields */ }
Implementations
Source§impl<T: RealField, D: Dim, S: Storage<T, D>> Unit<Vector<T, D, S>>
impl<T: RealField, D: Dim, S: Storage<T, D>> Unit<Vector<T, D, S>>
§Interpolation between two unit vectors
Sourcepub fn slerp<S2: Storage<T, D>>(
&self,
rhs: &Unit<Vector<T, D, S2>>,
t: T,
) -> Unit<OVector<T, D>>where
DefaultAllocator: Allocator<T, D>,
pub fn slerp<S2: Storage<T, D>>(
&self,
rhs: &Unit<Vector<T, D, S2>>,
t: T,
) -> Unit<OVector<T, D>>where
DefaultAllocator: Allocator<T, D>,
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);
Sourcepub fn try_slerp<S2: Storage<T, D>>(
&self,
rhs: &Unit<Vector<T, D, S2>>,
t: T,
epsilon: T,
) -> Option<Unit<OVector<T, D>>>where
DefaultAllocator: Allocator<T, D>,
pub fn try_slerp<S2: Storage<T, D>>(
&self,
rhs: &Unit<Vector<T, D, S2>>,
t: T,
epsilon: T,
) -> Option<Unit<OVector<T, D>>>where
DefaultAllocator: Allocator<T, D>,
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).
Source§impl<T: Normed> Unit<T>
impl<T: Normed> Unit<T>
§Construction with normalization
Sourcepub fn new_normalize(value: T) -> Self
pub fn new_normalize(value: T) -> Self
Normalize the given vector and return it wrapped on a Unit
structure.
Sourcepub fn try_new(value: T, min_norm: T::Norm) -> Option<Self>
pub fn try_new(value: T, min_norm: T::Norm) -> Option<Self>
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
.
Sourcepub fn new_and_get(value: T) -> (Self, T::Norm)
pub fn new_and_get(value: T) -> (Self, T::Norm)
Normalize the given vector and return it wrapped on a Unit
structure and its norm.
Sourcepub fn try_new_and_get(value: T, min_norm: T::Norm) -> Option<(Self, T::Norm)>
pub fn try_new_and_get(value: T, min_norm: T::Norm) -> Option<(Self, T::Norm)>
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
.
Sourcepub fn renormalize(&mut self) -> T::Norm
pub fn renormalize(&mut self) -> T::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.
Sourcepub fn renormalize_fast(&mut self)
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>
impl<T> Unit<T>
§Data extraction and construction without normalization
Sourcepub const fn new_unchecked(value: T) -> Self
pub const fn new_unchecked(value: T) -> Self
Wraps the given value, assuming it is already normalized.
Sourcepub fn from_ref_unchecked(value: &T) -> &Self
pub fn from_ref_unchecked(value: &T) -> &Self
Wraps the given reference, assuming it is already normalized.
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Retrieves the underlying value.
Sourcepub fn unwrap(self) -> T
👎Deprecated: use .into_inner()
instead
pub fn unwrap(self) -> T
.into_inner()
insteadRetrieves the underlying value.
Deprecated: use Unit::into_inner
instead.
Sourcepub fn as_mut_unchecked(&mut self) -> &mut T
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.
Trait Implementations
Source§impl<T, R: Dim, C: Dim, S> AbsDiffEq for Unit<Matrix<T, R, C, S>>
impl<T, R: Dim, C: Dim, S> AbsDiffEq for Unit<Matrix<T, R, C, S>>
Source§fn default_epsilon() -> Self::Epsilon
fn default_epsilon() -> Self::Epsilon
Source§fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
Source§fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
AbsDiffEq::abs_diff_eq
.Source§impl<'de, T: Deserialize<'de>> Deserialize<'de> for Unit<T>
impl<'de, T: Deserialize<'de>> Deserialize<'de> for Unit<T>
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<T, R: Dim, C: Dim> From<[Unit<Matrix<<T as SimdValue>::Element, R, C, <DefaultAllocator as Allocator<<T as SimdValue>::Element, R, C>>::Buffer>>; 16]> for Unit<OMatrix<T, R, C>>
impl<T, R: Dim, C: Dim> From<[Unit<Matrix<<T as SimdValue>::Element, R, C, <DefaultAllocator as Allocator<<T as SimdValue>::Element, R, C>>::Buffer>>; 16]> for Unit<OMatrix<T, R, C>>
Source§impl<T, R: Dim, C: Dim> From<[Unit<Matrix<<T as SimdValue>::Element, R, C, <DefaultAllocator as Allocator<<T as SimdValue>::Element, R, C>>::Buffer>>; 2]> for Unit<OMatrix<T, R, C>>
impl<T, R: Dim, C: Dim> From<[Unit<Matrix<<T as SimdValue>::Element, R, C, <DefaultAllocator as Allocator<<T as SimdValue>::Element, R, C>>::Buffer>>; 2]> for Unit<OMatrix<T, R, C>>
Source§impl<T, R: Dim, C: Dim> From<[Unit<Matrix<<T as SimdValue>::Element, R, C, <DefaultAllocator as Allocator<<T as SimdValue>::Element, R, C>>::Buffer>>; 4]> for Unit<OMatrix<T, R, C>>
impl<T, R: Dim, C: Dim> From<[Unit<Matrix<<T as SimdValue>::Element, R, C, <DefaultAllocator as Allocator<<T as SimdValue>::Element, R, C>>::Buffer>>; 4]> for Unit<OMatrix<T, R, C>>
Source§impl<T, R: Dim, C: Dim> From<[Unit<Matrix<<T as SimdValue>::Element, R, C, <DefaultAllocator as Allocator<<T as SimdValue>::Element, R, C>>::Buffer>>; 8]> for Unit<OMatrix<T, R, C>>
impl<T, R: Dim, C: Dim> From<[Unit<Matrix<<T as SimdValue>::Element, R, C, <DefaultAllocator as Allocator<<T as SimdValue>::Element, R, C>>::Buffer>>; 8]> for Unit<OMatrix<T, R, C>>
Source§impl<T: Scalar + ClosedNeg, R: Dim, C: Dim> Neg for Unit<OMatrix<T, R, C>>where
DefaultAllocator: Allocator<T, R, C>,
impl<T: Scalar + ClosedNeg, R: Dim, C: Dim> Neg for Unit<OMatrix<T, R, C>>where
DefaultAllocator: Allocator<T, R, C>,
Source§impl<T, R: Dim, C: Dim, S> RelativeEq for Unit<Matrix<T, R, C, S>>
impl<T, R: Dim, C: Dim, S> RelativeEq for Unit<Matrix<T, R, C, S>>
Source§fn default_max_relative() -> Self::Epsilon
fn default_max_relative() -> Self::Epsilon
Source§fn relative_eq(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool
fn relative_eq( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool
Source§fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool
fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool
RelativeEq::relative_eq
.