pub struct Unit<S> where
S: InnerSpace, { /* private fields */ }
Expand description
Unit vector.
Primarily represents a direction within an InnerSpace
.
Implementations
sourceimpl<S> Unit<S> where
S: InnerSpace,
impl<S> Unit<S> where
S: InnerSpace,
sourcepub fn try_from_inner(inner: S) -> Option<Unit<S>>
pub fn try_from_inner(inner: S) -> Option<Unit<S>>
Creates a Unit
from a non-zero magnitude vector.
The given vector is normalized. If the vector’s magnitude is zero, then
None
is returned.
Examples
use nalgebra::Vector3;
use theon::query::Unit;
use theon::space::Basis;
type R3 = Vector3<f64>;
let unit = Unit::<R3>::try_from_inner(Basis::i()).unwrap();
pub fn into_inner(self) -> S
pub fn x() -> Unit<S> where
S: Basis + FiniteDimensional,
<S as FiniteDimensional>::N: Cmp<UTerm>,
<<S as FiniteDimensional>::N as Cmp<UTerm>>::Output == Greater,
pub fn y() -> Unit<S> where
S: Basis + FiniteDimensional,
<S as FiniteDimensional>::N: Cmp<UInt<UTerm, B1>>,
<<S as FiniteDimensional>::N as Cmp<UInt<UTerm, B1>>>::Output == Greater,
pub fn z() -> Unit<S> where
S: Basis + FiniteDimensional,
<S as FiniteDimensional>::N: Cmp<UInt<UInt<UTerm, B1>, B0>>,
<<S as FiniteDimensional>::N as Cmp<UInt<UInt<UTerm, B1>, B0>>>::Output == Greater,
pub fn get(&self) -> &S
pub fn try_set(&mut self, inner: S) -> Option<&S>
pub fn reverse(self) -> Unit<S>
Trait Implementations
sourceimpl<S> AsRef<S> for Unit<S> where
S: InnerSpace,
impl<S> AsRef<S> for Unit<S> where
S: InnerSpace,
sourceimpl<S> Clone for Unit<S> where
S: Clone + InnerSpace,
impl<S> Clone for Unit<S> where
S: Clone + InnerSpace,
sourceimpl<S> Debug for Unit<S> where
S: Debug + InnerSpace,
impl<S> Debug for Unit<S> where
S: Debug + InnerSpace,
sourceimpl<S> Default for Unit<S> where
S: Basis + InnerSpace,
impl<S> Default for Unit<S> where
S: Basis + InnerSpace,
sourceimpl<S> Neg for Unit<S> where
S: InnerSpace,
impl<S> Neg for Unit<S> where
S: InnerSpace,
impl<S> Copy for Unit<S> where
S: Copy + InnerSpace,
impl<S> StructuralPartialEq for Unit<S> where
S: InnerSpace,
Auto Trait Implementations
impl<S> RefUnwindSafe for Unit<S> where
S: RefUnwindSafe,
impl<S> Send for Unit<S> where
S: Send,
impl<S> Sync for Unit<S> where
S: Sync,
impl<S> Unpin for Unit<S> where
S: Unpin,
impl<S> UnwindSafe for Unit<S> where
S: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> FromGeometry<T> for T
impl<T> FromGeometry<T> for T
fn from_geometry(other: T) -> T
sourceimpl<T, U> IntoGeometry<U> for T where
U: FromGeometry<T>,
impl<T, U> IntoGeometry<U> for T where
U: FromGeometry<T>,
fn into_geometry(self) -> U
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.