Struct nalgebra::base::Unit [−][src]
#[repr(C)]pub struct Unit<T> { /* fields omitted */ }
A wrapper that ensures the undelying algebraic entity has a unit norm.
Use .as_ref()
or .unwrap()
to obtain the undelying value by-reference or by-move.
Methods
impl<N: Real, D: Dim, S: Storage<N, D>> Unit<Vector<N, D, S>>
[src]
impl<N: Real, D: Dim, S: Storage<N, D>> Unit<Vector<N, D, S>>
pub fn slerp<S2: Storage<N, D>>(
&self,
rhs: &Unit<Vector<N, D, S2>>,
t: N
) -> Unit<VectorN<N, D>> where
DefaultAllocator: Allocator<N, D>,
[src]
pub fn slerp<S2: Storage<N, D>>(
&self,
rhs: &Unit<Vector<N, D, S2>>,
t: N
) -> Unit<VectorN<N, D>> where
DefaultAllocator: Allocator<N, D>,
Computes the spherical linear interpolation between two unit vectors.
pub fn try_slerp<S2: Storage<N, D>>(
&self,
rhs: &Unit<Vector<N, D, S2>>,
t: N,
epsilon: N
) -> Option<Unit<VectorN<N, D>>> where
DefaultAllocator: Allocator<N, D>,
[src]
pub fn try_slerp<S2: Storage<N, D>>(
&self,
rhs: &Unit<Vector<N, D, S2>>,
t: N,
epsilon: N
) -> Option<Unit<VectorN<N, D>>> where
DefaultAllocator: Allocator<N, 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).
impl<T: NormedSpace> Unit<T>
[src]
impl<T: NormedSpace> Unit<T>
pub fn new_normalize(value: T) -> Self
[src]
pub fn new_normalize(value: T) -> Self
Normalize the given value and return it wrapped on a Unit
structure.
pub fn try_new(value: T, min_norm: T::Field) -> Option<Self>
[src]
pub fn try_new(value: T, min_norm: T::Field) -> Option<Self>
Attempts to normalize the given value and return it wrapped on a Unit
structure.
Returns None
if the norm was smaller or equal to min_norm
.
pub fn new_and_get(value: T) -> (Self, T::Field)
[src]
pub fn new_and_get(value: T) -> (Self, T::Field)
Normalize the given value and return it wrapped on a Unit
structure and its norm.
pub fn try_new_and_get(value: T, min_norm: T::Field) -> Option<(Self, T::Field)>
[src]
pub fn try_new_and_get(value: T, min_norm: T::Field) -> Option<(Self, T::Field)>
Normalize the given value and return it wrapped on a Unit
structure and its norm.
Returns None
if the norm was smaller or equal to min_norm
.
pub fn renormalize(&mut self) -> T::Field
[src]
pub fn renormalize(&mut self) -> T::Field
Normalizes this value again. This is useful when repeated computations might cause a drift in the norm because of float inaccuracies.
Returns the norm before re-normalization (should be close to 1.0
).
impl<T> Unit<T>
[src]
impl<T> Unit<T>
pub fn new_unchecked(value: T) -> Self
[src]
pub fn new_unchecked(value: T) -> Self
Wraps the given value, assuming it is already normalized.
This function is not safe because value
is not verified to be actually normalized.
pub fn unwrap(self) -> T
[src]
pub fn unwrap(self) -> T
Retrieves the underlying value.
ⓘImportant traits for &'a mut Rpub fn as_mut_unchecked(&mut self) -> &mut T
[src]
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
impl<N: Real, D: DimName> Distribution<Unit<VectorN<N, D>>> for Standard where
DefaultAllocator: Allocator<N, D>,
StandardNormal: Distribution<N>,
[src]
impl<N: Real, D: DimName> Distribution<Unit<VectorN<N, D>>> for Standard where
DefaultAllocator: Allocator<N, D>,
StandardNormal: Distribution<N>,
fn sample<'a, G: Rng + ?Sized>(&self, rng: &'a mut G) -> Unit<VectorN<N, D>>
[src]
fn sample<'a, G: Rng + ?Sized>(&self, rng: &'a mut G) -> Unit<VectorN<N, D>>
Generate a uniformly distributed random unit vector.
ⓘImportant traits for DistIter<'a, D, R, T>fn sample_iter<R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T> where
R: Rng,
[src]
fn sample_iter<R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T> where
R: Rng,
Create an iterator that generates random values of T
, using rng
as the source of randomness. Read more
impl<N, R: Dim, C: Dim, S> AbsDiffEq for Unit<Matrix<N, R, C, S>> where
N: Scalar + AbsDiffEq,
S: Storage<N, R, C>,
N::Epsilon: Copy,
[src]
impl<N, R: Dim, C: Dim, S> AbsDiffEq for Unit<Matrix<N, R, C, S>> where
N: Scalar + AbsDiffEq,
S: Storage<N, R, C>,
N::Epsilon: Copy,
type Epsilon = N::Epsilon
Used for specifying relative comparisons.
fn default_epsilon() -> Self::Epsilon
[src]
fn default_epsilon() -> Self::Epsilon
The default tolerance to use when testing values that are close together. Read more
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
[src]
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
A test for equality that uses the absolute difference to compute the approximate equality of two numbers. Read more
fn abs_diff_ne(&self, other: &Self, epsilon: Self::Epsilon) -> bool
[src]
fn abs_diff_ne(&self, other: &Self, epsilon: Self::Epsilon) -> bool
The inverse of ApproxEq::abs_diff_eq
.
impl<N, R: Dim, C: Dim, S> RelativeEq for Unit<Matrix<N, R, C, S>> where
N: Scalar + RelativeEq,
S: Storage<N, R, C>,
N::Epsilon: Copy,
[src]
impl<N, R: Dim, C: Dim, S> RelativeEq for Unit<Matrix<N, R, C, S>> where
N: Scalar + RelativeEq,
S: Storage<N, R, C>,
N::Epsilon: Copy,
fn default_max_relative() -> Self::Epsilon
[src]
fn default_max_relative() -> Self::Epsilon
The default relative tolerance for testing values that are far-apart. Read more
fn relative_eq(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
[src]
fn relative_eq(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
A test for equality that uses a relative comparison if the values are far apart.
fn relative_ne(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
[src]
fn relative_ne(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
The inverse of ApproxEq::relative_eq
.
impl<N, R: Dim, C: Dim, S> UlpsEq for Unit<Matrix<N, R, C, S>> where
N: Scalar + UlpsEq,
S: Storage<N, R, C>,
N::Epsilon: Copy,
[src]
impl<N, R: Dim, C: Dim, S> UlpsEq for Unit<Matrix<N, R, C, S>> where
N: Scalar + UlpsEq,
S: Storage<N, R, C>,
N::Epsilon: Copy,
fn default_max_ulps() -> u32
[src]
fn default_max_ulps() -> u32
The default ULPs to tolerate when testing values that are far-apart. Read more
fn ulps_eq(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool
[src]
fn ulps_eq(&self, other: &Self, epsilon: Self::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: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool
[src]
fn ulps_ne(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool
The inverse of ApproxEq::ulps_eq
.
impl<T: Eq> Eq for Unit<T>
[src]
impl<T: Eq> Eq for Unit<T>
impl<T: PartialEq> PartialEq for Unit<T>
[src]
impl<T: PartialEq> PartialEq for Unit<T>
fn eq(&self, other: &Unit<T>) -> bool
[src]
fn eq(&self, other: &Unit<T>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Unit<T>) -> bool
[src]
fn ne(&self, other: &Unit<T>) -> bool
This method tests for !=
.
impl<T: Clone> Clone for Unit<T>
[src]
impl<T: Clone> Clone for Unit<T>
fn clone(&self) -> Unit<T>
[src]
fn clone(&self) -> Unit<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<T: Hash> Hash for Unit<T>
[src]
impl<T: Hash> Hash for Unit<T>
fn hash<__HT: Hasher>(&self, state: &mut __HT)
[src]
fn hash<__HT: Hasher>(&self, state: &mut __HT)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<T: Debug> Debug for Unit<T>
[src]
impl<T: Debug> Debug for Unit<T>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<T: Copy> Copy for Unit<T>
[src]
impl<T: Copy> Copy for Unit<T>
impl<T> AsRef<T> for Unit<T>
[src]
impl<T> AsRef<T> for Unit<T>
impl<T: NormedSpace> SubsetOf<T> for Unit<T> where
T::Field: RelativeEq,
[src]
impl<T: NormedSpace> SubsetOf<T> for Unit<T> where
T::Field: RelativeEq,
fn to_superset(&self) -> T
[src]
fn to_superset(&self) -> T
The inclusion map: converts self
to the equivalent element of its superset.
fn is_in_subset(value: &T) -> bool
[src]
fn is_in_subset(value: &T) -> bool
Checks if element
is actually part of the subset Self
(and can be converted to it).
unsafe fn from_superset_unchecked(value: &T) -> Self
[src]
unsafe fn from_superset_unchecked(value: &T) -> Self
Use with care! Same as self.to_superset
but without any property checks. Always succeeds.
fn from_superset(element: &T) -> Option<Self>
[src]
fn from_superset(element: &T) -> Option<Self>
The inverse inclusion map: attempts to construct self
from the equivalent element of its superset. Read more
impl<T: Neg> Neg for Unit<T>
[src]
impl<T: Neg> Neg for Unit<T>
type Output = Unit<T::Output>
The resulting type after applying the -
operator.
fn neg(self) -> Self::Output
[src]
fn neg(self) -> Self::Output
Performs the unary -
operation.
impl<T> Deref for Unit<T>
[src]
impl<T> Deref for Unit<T>
type Target = T
The resulting type after dereferencing.
ⓘImportant traits for &'a mut Rfn deref(&self) -> &T
[src]
fn deref(&self) -> &T
Dereferences the value.
impl<'a, 'b, N: Real, SB: Storage<N, U3>> Mul<&'b Unit<Vector<N, U3, SB>>> for &'a UnitQuaternion<N> where
DefaultAllocator: Allocator<N, U4, U1> + Allocator<N, U3, U1>,
[src]
impl<'a, 'b, N: Real, SB: Storage<N, U3>> Mul<&'b Unit<Vector<N, U3, SB>>> for &'a UnitQuaternion<N> where
DefaultAllocator: Allocator<N, U4, U1> + Allocator<N, U3, U1>,
type Output = Unit<Vector3<N>>
The resulting type after applying the *
operator.
fn mul(self, rhs: &'b Unit<Vector<N, U3, SB>>) -> Self::Output
[src]
fn mul(self, rhs: &'b Unit<Vector<N, U3, SB>>) -> Self::Output
Performs the *
operation.
impl<'a, N: Real, SB: Storage<N, U3>> Mul<Unit<Vector<N, U3, SB>>> for &'a UnitQuaternion<N> where
DefaultAllocator: Allocator<N, U4, U1> + Allocator<N, U3, U1>,
[src]
impl<'a, N: Real, SB: Storage<N, U3>> Mul<Unit<Vector<N, U3, SB>>> for &'a UnitQuaternion<N> where
DefaultAllocator: Allocator<N, U4, U1> + Allocator<N, U3, U1>,
type Output = Unit<Vector3<N>>
The resulting type after applying the *
operator.
fn mul(self, rhs: Unit<Vector<N, U3, SB>>) -> Self::Output
[src]
fn mul(self, rhs: Unit<Vector<N, U3, SB>>) -> Self::Output
Performs the *
operation.
impl<'b, N: Real, SB: Storage<N, U3>> Mul<&'b Unit<Vector<N, U3, SB>>> for UnitQuaternion<N> where
DefaultAllocator: Allocator<N, U4, U1> + Allocator<N, U3, U1>,
[src]
impl<'b, N: Real, SB: Storage<N, U3>> Mul<&'b Unit<Vector<N, U3, SB>>> for UnitQuaternion<N> where
DefaultAllocator: Allocator<N, U4, U1> + Allocator<N, U3, U1>,
type Output = Unit<Vector3<N>>
The resulting type after applying the *
operator.
fn mul(self, rhs: &'b Unit<Vector<N, U3, SB>>) -> Self::Output
[src]
fn mul(self, rhs: &'b Unit<Vector<N, U3, SB>>) -> Self::Output
Performs the *
operation.
impl<N: Real, SB: Storage<N, U3>> Mul<Unit<Vector<N, U3, SB>>> for UnitQuaternion<N> where
DefaultAllocator: Allocator<N, U4, U1> + Allocator<N, U3, U1>,
[src]
impl<N: Real, SB: Storage<N, U3>> Mul<Unit<Vector<N, U3, SB>>> for UnitQuaternion<N> where
DefaultAllocator: Allocator<N, U4, U1> + Allocator<N, U3, U1>,
type Output = Unit<Vector3<N>>
The resulting type after applying the *
operator.
fn mul(self, rhs: Unit<Vector<N, U3, SB>>) -> Self::Output
[src]
fn mul(self, rhs: Unit<Vector<N, U3, SB>>) -> Self::Output
Performs the *
operation.
impl<N: Real, S: Storage<N, U2>> Mul<Unit<Vector<N, U2, S>>> for UnitComplex<N> where
DefaultAllocator: Allocator<N, U2, U1>,
[src]
impl<N: Real, S: Storage<N, U2>> Mul<Unit<Vector<N, U2, S>>> for UnitComplex<N> where
DefaultAllocator: Allocator<N, U2, U1>,
type Output = Unit<Vector2<N>>
The resulting type after applying the *
operator.
fn mul(self, rhs: Unit<Vector<N, U2, S>>) -> Self::Output
[src]
fn mul(self, rhs: Unit<Vector<N, U2, S>>) -> Self::Output
Performs the *
operation.
impl<'a, N: Real, S: Storage<N, U2>> Mul<Unit<Vector<N, U2, S>>> for &'a UnitComplex<N> where
DefaultAllocator: Allocator<N, U2, U1>,
[src]
impl<'a, N: Real, S: Storage<N, U2>> Mul<Unit<Vector<N, U2, S>>> for &'a UnitComplex<N> where
DefaultAllocator: Allocator<N, U2, U1>,
type Output = Unit<Vector2<N>>
The resulting type after applying the *
operator.
fn mul(self, rhs: Unit<Vector<N, U2, S>>) -> Self::Output
[src]
fn mul(self, rhs: Unit<Vector<N, U2, S>>) -> Self::Output
Performs the *
operation.
impl<'b, N: Real, S: Storage<N, U2>> Mul<&'b Unit<Vector<N, U2, S>>> for UnitComplex<N> where
DefaultAllocator: Allocator<N, U2, U1>,
[src]
impl<'b, N: Real, S: Storage<N, U2>> Mul<&'b Unit<Vector<N, U2, S>>> for UnitComplex<N> where
DefaultAllocator: Allocator<N, U2, U1>,
type Output = Unit<Vector2<N>>
The resulting type after applying the *
operator.
fn mul(self, rhs: &'b Unit<Vector<N, U2, S>>) -> Self::Output
[src]
fn mul(self, rhs: &'b Unit<Vector<N, U2, S>>) -> Self::Output
Performs the *
operation.
impl<'a, 'b, N: Real, S: Storage<N, U2>> Mul<&'b Unit<Vector<N, U2, S>>> for &'a UnitComplex<N> where
DefaultAllocator: Allocator<N, U2, U1>,
[src]
impl<'a, 'b, N: Real, S: Storage<N, U2>> Mul<&'b Unit<Vector<N, U2, S>>> for &'a UnitComplex<N> where
DefaultAllocator: Allocator<N, U2, U1>,
type Output = Unit<Vector2<N>>
The resulting type after applying the *
operator.
fn mul(self, rhs: &'b Unit<Vector<N, U2, S>>) -> Self::Output
[src]
fn mul(self, rhs: &'b Unit<Vector<N, U2, S>>) -> Self::Output
Performs the *
operation.
impl<N: Real, D: DimName, R> Mul<Unit<VectorN<N, D>>> for Isometry<N, D, R> where
R: AlgaRotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D>,
[src]
impl<N: Real, D: DimName, R> Mul<Unit<VectorN<N, D>>> for Isometry<N, D, R> where
R: AlgaRotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D>,
type Output = Unit<VectorN<N, D>>
The resulting type after applying the *
operator.
fn mul(self, right: Unit<VectorN<N, D>>) -> Self::Output
[src]
fn mul(self, right: Unit<VectorN<N, D>>) -> Self::Output
Performs the *
operation.
impl<'a, N: Real, D: DimName, R> Mul<Unit<VectorN<N, D>>> for &'a Isometry<N, D, R> where
R: AlgaRotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D>,
[src]
impl<'a, N: Real, D: DimName, R> Mul<Unit<VectorN<N, D>>> for &'a Isometry<N, D, R> where
R: AlgaRotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D>,
type Output = Unit<VectorN<N, D>>
The resulting type after applying the *
operator.
fn mul(self, right: Unit<VectorN<N, D>>) -> Self::Output
[src]
fn mul(self, right: Unit<VectorN<N, D>>) -> Self::Output
Performs the *
operation.
impl<'b, N: Real, D: DimName, R> Mul<&'b Unit<VectorN<N, D>>> for Isometry<N, D, R> where
R: AlgaRotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D>,
[src]
impl<'b, N: Real, D: DimName, R> Mul<&'b Unit<VectorN<N, D>>> for Isometry<N, D, R> where
R: AlgaRotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D>,
type Output = Unit<VectorN<N, D>>
The resulting type after applying the *
operator.
fn mul(self, right: &'b Unit<VectorN<N, D>>) -> Self::Output
[src]
fn mul(self, right: &'b Unit<VectorN<N, D>>) -> Self::Output
Performs the *
operation.
impl<'a, 'b, N: Real, D: DimName, R> Mul<&'b Unit<VectorN<N, D>>> for &'a Isometry<N, D, R> where
R: AlgaRotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D>,
[src]
impl<'a, 'b, N: Real, D: DimName, R> Mul<&'b Unit<VectorN<N, D>>> for &'a Isometry<N, D, R> where
R: AlgaRotation<Point<N, D>>,
DefaultAllocator: Allocator<N, D>,