Struct nalgebra::Unit [] [src]

pub struct Unit<T> {
    // some 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: Norm> Unit<T>
[src]

fn new(v: &T) -> Self

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

fn try_new(v: &T, min_norm: T::NormType) -> 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.

fn new_and_get(v: T) -> (Self, T::NormType)

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

fn try_new_and_get(v: T, min_norm: T::NormType) -> Option<(Self, T::NormType)>

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.

fn renormalize(&mut self) -> T::NormType

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]

fn from_unit_value_unchecked(v: T) -> Self

Wraps the given value, assuming it is already normalized.

This function is not safe because v is not verified to be actually normalized.

fn unwrap(self) -> T

Retrieves the underlying value.

Trait Implementations

impl<T: Copy> Copy for Unit<T>
[src]

impl<T: Debug> Debug for Unit<T>
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl<T: Hash> Hash for Unit<T>
[src]

fn hash<__HT: Hasher>(&self, __arg_0: &mut __HT)

Feeds this value into the state given, updating the hasher as necessary.

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

Feeds a slice of this type into the state provided.

impl<T: Clone> Clone for 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

Performs copy-assignment from source. Read more

impl<T: Decodable> Decodable for Unit<T>
[src]

fn decode<__DT: Decoder>(__arg_0: &mut __DT) -> Result<Unit<T>, __DT::Error>

impl<T: Encodable> Encodable for Unit<T>
[src]

fn encode<__ST: Encoder>(&self, __arg_0: &mut __ST) -> Result<(), __ST::Error>

impl<T: PartialEq> PartialEq for Unit<T>
[src]

fn eq(&self, __arg_0: &Unit<T>) -> bool

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

This method tests for !=.

impl<T: Eq> Eq for Unit<T>
[src]

impl<T> AsRef<T> for Unit<T>
[src]

fn as_ref(&self) -> &T

Performs the conversion.