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>
impl<L, T> NormalizedQuat<L, T>
Sourcepub const DEFAULT_TOLERANCE: f64 = 1e-12
pub const DEFAULT_TOLERANCE: f64 = 1e-12
Default tolerance: norm must lie within 1 ± 1e-12.
Sourcepub fn new(q: Quat<L, T>) -> Result<NormalizedQuat<L, T>, NotNormalized>
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.
Sourcepub fn new_with_tolerance(
q: Quat<L, T>,
tolerance: f64,
) -> Result<NormalizedQuat<L, T>, NotNormalized>
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.
Sourcepub fn renormalize(q: Quat<L, T>) -> Option<NormalizedQuat<L, T>>
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§impl NormalizedQuat<ScalarFirst, LeftTransform>
impl NormalizedQuat<ScalarFirst, LeftTransform>
Sourcepub fn left_quat_to_transformation(&self) -> DMat3
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.
Sourcepub fn left_quat_transform(&self, v: DVec3) -> DVec3
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>
impl<L, T> Clone for NormalizedQuat<L, T>
Source§fn clone(&self) -> NormalizedQuat<L, T>
fn clone(&self) -> NormalizedQuat<L, T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<L, T> Debug for NormalizedQuat<L, T>
impl<L, T> Debug for NormalizedQuat<L, T>
Source§impl<L, T> PartialEq for NormalizedQuat<L, T>
impl<L, T> PartialEq for NormalizedQuat<L, T>
Source§fn eq(&self, other: &NormalizedQuat<L, T>) -> bool
fn eq(&self, other: &NormalizedQuat<L, T>) -> bool
self and other values to be equal, and is used by ==.