#[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: QuatThe real quaternion part, i.e. the rotator
dual: QuatThe dual quaternion part, i.e. the translator
Implementations§
Source§impl DualQuat
impl DualQuat
Sourcepub const IDENTITY: Self
pub const IDENTITY: Self
The identity transform: doesn’t transform at all. Like multiplying with 1.
Sourcepub const ZERO: Self
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.
Sourcepub fn from_iso_transform(iso_transform: IsoTransform) -> Self
pub fn from_iso_transform(iso_transform: IsoTransform) -> Self
Create a dual quaternion from an IsoTransform
Sourcepub fn from_rotation_translation(rotation: Quat, translation: Vec3) -> Self
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.
Sourcepub fn from_translation(translation: Vec3) -> Self
pub fn from_translation(translation: Vec3) -> Self
A pure translation without any rotation.
Sourcepub fn to_rotation_translation(self) -> (Quat, Vec3)
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.
Sourcepub fn conjugate(self) -> Self
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.
Sourcepub fn inverse(self) -> Self
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.
Sourcepub fn norm_squared(self) -> DualScalar
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.
Sourcepub fn norm(self) -> DualScalar
pub fn norm(self) -> DualScalar
Gives the norm of the dual quaternion.
self is normalized if real = 1.0 and dual = 0.0.
Sourcepub fn is_normalized(self) -> bool
pub fn is_normalized(self) -> bool
Whether self is normalized, i.e. a unit dual quaternion.
Sourcepub fn normalize_full(self) -> Self
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.
Sourcepub fn normalize_to_rotation_translation(self) -> (Quat, Vec3)
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)
Sourcepub fn abs_diff_eq(self, other: Self, max_abs_diff: f32) -> bool
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
Sourcepub fn right_mul_translation(self, trans: Vec3) -> Self
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 AddAssign for DualQuat
impl AddAssign for DualQuat
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+= operation. Read moreSource§impl Mul<DualQuat> for DualScalar
impl Mul<DualQuat> for DualScalar
Source§impl Mul<DualScalar> for DualQuat
impl Mul<DualScalar> for DualQuat
Source§impl SubAssign for DualQuat
impl SubAssign for DualQuat
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-= operation. Read more