Skip to main content

NormalizedQuat

Struct NormalizedQuat 

Source
pub struct NormalizedQuat<L, T>(/* private fields */)
where
    L: Layout,
    T: Transform;
Expand description

A quaternion witnessed to have unit norm at construction time.

Witnesses are invalidated silently by arithmetic on the inner data, so this type exposes no mutable accessor — all transformations that could denormalize go through re-normalizing constructors.

Implementations§

Source§

impl<L, T> NormalizedQuat<L, T>
where L: Layout, T: Transform,

Source

pub const DEFAULT_TOLERANCE: f64 = 1e-12

Default tolerance: norm must lie within 1 ± 1e-12.

Source

pub fn new(q: Quat<L, T>) -> Result<NormalizedQuat<L, T>, NotNormalized>

Wrap a quaternion iff its norm is within Self::DEFAULT_TOLERANCE of 1.

Source

pub fn new_with_tolerance( q: Quat<L, T>, tolerance: f64, ) -> Result<NormalizedQuat<L, T>, NotNormalized>

Wrap a quaternion iff its norm is within the given tolerance of 1.

Source

pub fn renormalize(q: Quat<L, T>) -> Option<NormalizedQuat<L, T>>

Renormalize an arbitrary quaternion into this witness.

Returns None if the norm is not finite and strictly positive — i.e. the input is all zeros, contains any NaN, or has components so large that ‖q‖ overflows to infinity. All three cases would otherwise produce a non-unit witness.

Source

pub const fn inner(self) -> Quat<L, T>

Read-only view of the underlying quaternion.

Source§

impl NormalizedQuat<ScalarFirst, LeftTransform>

Source

pub fn left_quat_to_transformation(&self) -> DMat3

Build the 3x3 rotation (transformation) matrix from a witnessed unit-norm left quaternion.

Preferred over JeodQuat::left_quat_to_transformation because the witness proves the unit-norm precondition at the type level.

Source

pub fn left_quat_transform(&self, v: DVec3) -> DVec3

Transform a vector using a witnessed unit-norm left quaternion.

Trait Implementations§

Source§

impl<L, T> Clone for NormalizedQuat<L, T>
where L: Clone + Layout, T: Clone + Transform,

Source§

fn clone(&self) -> NormalizedQuat<L, T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<L, T> Debug for NormalizedQuat<L, T>
where L: Debug + Layout, T: Debug + Transform,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<L, T> PartialEq for NormalizedQuat<L, T>

Source§

fn eq(&self, other: &NormalizedQuat<L, T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<L, T> Copy for NormalizedQuat<L, T>
where L: Copy + Layout, T: Copy + Transform,

Source§

impl<L, T> RequiresNormalizedQuat for NormalizedQuat<L, T>
where L: Layout, T: Transform,

Source§

impl<L, T> StructuralPartialEq for NormalizedQuat<L, T>
where L: Layout, T: Transform,

Auto Trait Implementations§

§

impl<L, T> Freeze for NormalizedQuat<L, T>

§

impl<L, T> RefUnwindSafe for NormalizedQuat<L, T>

§

impl<L, T> Send for NormalizedQuat<L, T>
where L: Send, T: Send,

§

impl<L, T> Sync for NormalizedQuat<L, T>
where L: Sync, T: Sync,

§

impl<L, T> Unpin for NormalizedQuat<L, T>
where L: Unpin, T: Unpin,

§

impl<L, T> UnsafeUnpin for NormalizedQuat<L, T>

§

impl<L, T> UnwindSafe for NormalizedQuat<L, T>
where L: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.