Struct DualQuat

Source
#[repr(C, align(16))]
pub struct DualQuat { pub real: Quat, pub dual: Quat, }
Expand description

Represents a rigid body transformation which can be thought of as a “screw” motion which is the combination of a translation along a vector and a rotation around that vector.

Represents the same kind of transformation as an IsoTransform but interpolates and transforms in a way that preserves volume.

Fields§

§real: Quat

The real quaternion part, i.e. the rotator

§dual: Quat

The dual quaternion part, i.e. the translator

Implementations§

Source§

impl DualQuat

Source

pub const IDENTITY: Self

The identity transform: doesn’t transform at all. Like multiplying with 1.

Source

pub const ZERO: Self

Not a valid quaternion in and of itself. All values filled with 0s. Can be useful when blending a set of transforms.

Source

pub fn from_iso_transform(iso_transform: IsoTransform) -> Self

Create a dual quaternion from an IsoTransform

Source

pub fn from_rotation_translation(rotation: Quat, translation: Vec3) -> Self

Create a dual quaternion that rotates and then translates by the specified amount. rotation is assumed to be normalized.

Source

pub fn from_translation(translation: Vec3) -> Self

A pure translation without any rotation.

Source

pub fn from_quat(rotation: Quat) -> Self

A pure rotation without any translation.

Source

pub fn to_rotation_translation(self) -> (Quat, Vec3)

Returns this transform decomposed into (rotation, translation). Assumes self is already normalized. If not, consider using normalize_to_rotation_translation

You can then apply this to a point by doing rotation.mul_vec3(point) + translation.

Source

pub fn conjugate(self) -> Self

Quaternion conjugate of this dual quaternion, which is given q = (real + dual), q* = (real* + dual*). This form of conjugate is also the inverse as long as this dual quaternion is unit.

Source

pub fn inverse(self) -> Self

Gives the inverse of this dual quaternion such that self * self.inverse() = identity.

This function should only be used if self is unit, i.e if self.is_normalized() is true. Will panic in debug builds if it is not normalized.

Source

pub fn norm_squared(self) -> DualScalar

Gives the norm squared of the dual quaternion.

self is normalized if real = 1.0 and dual = 0.0.

Source

pub fn norm(self) -> DualScalar

Gives the norm of the dual quaternion.

self is normalized if real = 1.0 and dual = 0.0.

Source

pub fn is_normalized(self) -> bool

Whether self is normalized, i.e. a unit dual quaternion.

Source

pub fn normalize_full(self) -> Self

Normalizes self to make it a unit dual quaternion.

If you will immediately apply the normalized dual quat to transform a point/vector, consider using normalize_to_rotation_translation instead.

Source

pub fn normalize_to_rotation_translation(self) -> (Quat, Vec3)

Normalize self and then extract its rotation and translation components which can be applied to a point by doing rotation.mul_vec3(point) + translation

This will be faster than self.normalize().to_rotation_translation() as we can use the full expansion of the operation to cancel out some calculations that would otherwise need to be performed. For justification of this, see https://users.cs.utah.edu/~ladislav/kavan07skinning/kavan07skinning.pdf particularly equation (4) and section 3.4.

You can then apply this to a point by doing (rotation * point + translation)

Source

pub fn abs_diff_eq(self, other: Self, max_abs_diff: f32) -> bool

Whether self is approximately equal to other with max_abs_diff error

Source

pub fn right_mul_translation(self, trans: Vec3) -> Self

An optimized form of self * DualQuat::from_translation(trans) (note the order!)

Trait Implementations§

Source§

impl Add for DualQuat

Source§

type Output = DualQuat

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl AddAssign for DualQuat

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl Clone for DualQuat

Source§

fn clone(&self) -> DualQuat

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for DualQuat

Source§

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

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

impl Mul<DualQuat> for DualScalar

Source§

type Output = DualQuat

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: DualQuat) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<DualQuat> for f32

Source§

type Output = DualQuat

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: DualQuat) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<DualScalar> for DualQuat

Source§

type Output = DualQuat

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: DualScalar) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<f32> for DualQuat

Source§

type Output = DualQuat

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f32) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul for DualQuat

Source§

type Output = DualQuat

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl PartialEq for DualQuat

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 Sub for DualQuat

Source§

type Output = DualQuat

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl SubAssign for DualQuat

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl Copy for DualQuat

Source§

impl StructuralPartialEq for DualQuat

Auto Trait Implementations§

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