Struct nalgebra::core::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<T: NormedSpace> Unit<T>
[src]
pub fn new_normalize(value: T) -> Self
[src]
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]
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]
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]
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]
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]
pub fn new_unchecked(value: T) -> Self
[src]
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]
Retrieves the underlying value.
ⓘImportant traits for &'a mut Ipub fn as_mut_unchecked(&mut self) -> &mut T
[src]
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, R: Dim, C: Dim, S> ApproxEq for Unit<Matrix<N, R, C, S>> where
N: Scalar + ApproxEq,
S: Storage<N, R, C>,
N::Epsilon: Copy,
[src]
N: Scalar + ApproxEq,
S: Storage<N, R, C>,
N::Epsilon: Copy,
type Epsilon = N::Epsilon
Used for specifying relative comparisons.
fn default_epsilon() -> Self::Epsilon
[src]
The default tolerance to use when testing values that are close together. Read more
fn default_max_relative() -> Self::Epsilon
[src]
The default relative tolerance for testing values that are far-apart. Read more
fn default_max_ulps() -> u32
[src]
The default ULPs to tolerate when testing values that are far-apart. Read more
fn relative_eq(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
[src]
&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 ulps_eq(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool
[src]
A test for equality that uses units in the last place (ULP) if the values are far apart.
fn relative_ne(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
[src]
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
The inverse of ApproxEq::relative_eq
.
fn ulps_ne(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool
[src]
The inverse of ApproxEq::ulps_eq
.
impl<T: Eq> Eq for Unit<T>
[src]
impl<T: PartialEq> PartialEq for Unit<T>
[src]
fn eq(&self, __arg_0: &Unit<T>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Unit<T>) -> bool
[src]
This method tests for !=
.
impl<T: Clone> Clone for Unit<T>
[src]
fn clone(&self) -> Unit<T>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: Hash> Hash for Unit<T>
[src]
fn hash<__HT: Hasher>(&self, __arg_0: &mut __HT)
[src]
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]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<T: Debug> Debug for Unit<T>
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<T: Copy> Copy for Unit<T>
[src]
impl<T> AsRef<T> for Unit<T>
[src]
impl<T: NormedSpace> SubsetOf<T> for Unit<T> where
T::Field: ApproxEq,
[src]
T::Field: ApproxEq,
fn to_superset(&self) -> T
[src]
The inclusion map: converts self
to the equivalent element of its superset.
fn is_in_subset(value: &T) -> bool
[src]
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]
Use with care! Same as self.to_superset
but without any property checks. Always succeeds.
fn from_superset(element: &T) -> Option<Self>
[src]
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]
type Output = Unit<T::Output>
The resulting type after applying the -
operator.
fn neg(self) -> Self::Output
[src]
Performs the unary -
operation.
impl<T> Deref for Unit<T>
[src]
type Target = T
The resulting type after dereferencing.
ⓘImportant traits for &'a mut Ifn deref(&self) -> &T
[src]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
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]
DefaultAllocator: Allocator<N, U2, U1>,