Skip to main content

QuaternionPair

Struct QuaternionPair 

Source
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>

Source

pub fn new(real: Quaternion<T>, unreal: Quaternion<T>) -> Self

Construct an algebra element. Panics if K is not -1, 0, or 1.

Source

pub fn into_parts(self) -> (Quaternion<T>, Quaternion<T>)

Source

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].

Source

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>

Source

pub fn real(&self) -> Quaternion<T>

Source

pub fn unreal(&self) -> Quaternion<T>

Source§

impl<T: Neg<Output = T>, const K: i8> QuaternionPair<T, K>

Source

pub fn quaternion_conj(self) -> Self

Quaternion conjugation: (conj(a), conj(b)). Reverses products.

Source

pub fn scalar_conj(self) -> Self

Conjugation of the central unit: (a, -b). Preserves product order.

Source

pub fn combined_conj(self) -> Self

Combined conjugation: (conj(a), -conj(b)). Reverses products.

Source§

impl<T: Num + Copy, const K: i8> QuaternionPair<T, K>

Source

pub fn norm_sqr(self) -> (T, T)

The central coefficients (n, m) of self * self.quaternion_conj(): n = |a|² + K |b|², m = 2 dot(a,b).

Source§

impl<T: Float, const K: i8> QuaternionPair<T, K>

Source

pub fn is_finite(self) -> bool

Source

pub fn try_inv(self) -> Option<Self>

Invert a nonsingular element. Returns None for singular/nonfinite inputs or when intermediate arithmetic overflows.

Source

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.

Trait Implementations§

Source§

impl<T: Add<Output = T>, const K: i8> Add for QuaternionPair<T, K>

Source§

type Output = QuaternionPair<T, K>

The resulting type after applying the + operator.
Source§

fn add(self, other: Self) -> Self

Performs the + operation. Read more
Source§

impl<T: Clone, const K: i8> Clone for QuaternionPair<T, K>

Source§

fn clone(&self) -> Self

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<T: Copy, const K: i8> Copy for QuaternionPair<T, K>

Source§

impl<T: Debug, const K: i8> Debug for QuaternionPair<T, K>

Source§

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

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

impl<T: Zero, const K: i8> Default for QuaternionPair<T, K>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: Div<Output = T> + Copy, const K: i8> Div<T> for QuaternionPair<T, K>

Source§

type Output = QuaternionPair<T, K>

The resulting type after applying the / operator.
Source§

fn div(self, scalar: T) -> Self

Performs the / operation. Read more
Source§

impl<T: Num + Copy, const K: i8> Mul for QuaternionPair<T, K>

Source§

type Output = QuaternionPair<T, K>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Self) -> Self

Performs the * operation. Read more
Source§

impl<T: Mul<Output = T> + Copy, const K: i8> Mul<T> for QuaternionPair<T, K>

Source§

type Output = QuaternionPair<T, K>

The resulting type after applying the * operator.
Source§

fn mul(self, scalar: T) -> Self

Performs the * operation. Read more
Source§

impl<T: Neg<Output = T>, const K: i8> Neg for QuaternionPair<T, K>

Source§

type Output = QuaternionPair<T, K>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl<T: Num + Copy, const K: i8> One for QuaternionPair<T, K>

Source§

fn one() -> Self

Returns the multiplicative identity element of Self, 1. Read more
Source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
Source§

fn is_one(&self) -> bool
where Self: PartialEq,

Returns true if self is equal to the multiplicative identity. Read more
Source§

impl<T: PartialEq, const K: i8> PartialEq for QuaternionPair<T, K>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<T: PartialEq, const K: i8> StructuralPartialEq for QuaternionPair<T, K>

Source§

impl<T: Sub<Output = T>, const K: i8> Sub for QuaternionPair<T, K>

Source§

type Output = QuaternionPair<T, K>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Self) -> Self

Performs the - operation. Read more
Source§

impl<T: Zero, const K: i8> Zero for QuaternionPair<T, K>

Source§

fn zero() -> Self

Returns the additive identity element of Self, 0. Read more
Source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
Source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.

Auto Trait Implementations§

§

impl<T, const K: i8> Freeze for QuaternionPair<T, K>
where Quaternion<T>: Freeze,

§

impl<T, const K: i8> RefUnwindSafe for QuaternionPair<T, K>

§

impl<T, const K: i8> Send for QuaternionPair<T, K>
where Quaternion<T>: Send,

§

impl<T, const K: i8> Sync for QuaternionPair<T, K>
where Quaternion<T>: Sync,

§

impl<T, const K: i8> Unpin for QuaternionPair<T, K>
where Quaternion<T>: Unpin,

§

impl<T, const K: i8> UnsafeUnpin for QuaternionPair<T, K>

§

impl<T, const K: i8> UnwindSafe for QuaternionPair<T, K>

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, const M: usize, const N: usize> Broadcast<Matrix<T, M, N>> for T
where T: Copy,

Source§

fn broadcast(self) -> Matrix<T, M, N>

Copy values along axes to get V.
Source§

impl<T, const N: usize> Broadcast<Vector<T, N>> for T
where T: Copy,

Source§

fn broadcast(self) -> Vector<T, N>

Copy values along axes to get V.
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V