pub struct QuaternionPair<T, const K: i8> { /* private fields */ }Expand description
An element a + e*b, where a and b are ordinary quaternions and
the central unit satisfies e*e = K.
K must be -1 (complex), 0 (dual), or 1 (split). Different values
are different types and cannot accidentally be multiplied together.
Both quaternions use scalar-first component order. This is an algebra
element, not necessarily a normalized isometry.
Quaternion conjugation, scalar conjugation (e -> -e), and their
combination are distinct operations. The quaternion norm is itself a
central pair, so ordinary eight-dimensional Euclidean normalization is
not appropriate.
Implementations§
Source§impl<T, const K: i8> QuaternionPair<T, K>
impl<T, const K: i8> QuaternionPair<T, K>
Sourcepub fn new(real: Quaternion<T>, unreal: Quaternion<T>) -> Self
pub fn new(real: Quaternion<T>, unreal: Quaternion<T>) -> Self
Construct an algebra element. Panics if K is not -1, 0, or 1.
pub fn into_parts(self) -> (Quaternion<T>, Quaternion<T>)
Sourcepub fn from_array(values: [T; 8]) -> Self
pub fn from_array(values: [T; 8]) -> Self
Construct from [a.w, a.x, a.y, a.z, b.w, b.x, b.y, b.z].
Sourcepub fn into_array(self) -> [T; 8]
pub fn into_array(self) -> [T; 8]
Return [a.w, a.x, a.y, a.z, b.w, b.x, b.y, b.z].
Source§impl<T: Copy, const K: i8> QuaternionPair<T, K>
impl<T: Copy, const K: i8> QuaternionPair<T, K>
pub fn real(&self) -> Quaternion<T>
pub fn unreal(&self) -> Quaternion<T>
Source§impl<T: Neg<Output = T>, const K: i8> QuaternionPair<T, K>
impl<T: Neg<Output = T>, const K: i8> QuaternionPair<T, K>
Sourcepub fn quaternion_conj(self) -> Self
pub fn quaternion_conj(self) -> Self
Quaternion conjugation: (conj(a), conj(b)). Reverses products.
Sourcepub fn scalar_conj(self) -> Self
pub fn scalar_conj(self) -> Self
Conjugation of the central unit: (a, -b). Preserves product order.
Sourcepub fn combined_conj(self) -> Self
pub fn combined_conj(self) -> Self
Combined conjugation: (conj(a), -conj(b)). Reverses products.
Source§impl<T: Float, const K: i8> QuaternionPair<T, K>
impl<T: Float, const K: i8> QuaternionPair<T, K>
pub fn is_finite(self) -> bool
Sourcepub fn try_inv(self) -> Option<Self>
pub fn try_inv(self) -> Option<Self>
Invert a nonsingular element. Returns None for singular/nonfinite
inputs or when intermediate arithmetic overflows.
Sourcepub fn try_normalize(self) -> Option<Self>
pub fn try_normalize(self) -> Option<Self>
Divide by a central square root of the quaternion norm.
The result has norm_sqr() = (1, 0) up to roundoff. Complex pairs
use the principal complex square root; dual and split pairs use
the positive real branches. Returns None for singular/nonfinite
inputs or when intermediate arithmetic overflows. This selects a
normalization branch, not a canonical sign for the double cover.