Struct SwingTwist

Source
pub struct SwingTwist {
    pub swing: Quat,
    pub twist: Quat,
    pub twist_angle: f32,
    pub is_singular: bool,
}
Expand description

Checked factorization of a rotation into swing * twist (twist acts first).

Both factors are normalized. twist rotates about the requested local axis; swing carries that axis to its final direction. Reconstruction agrees with the normalized input orientation, up to floating-point rounding and sign.

use ferravex_math::{Quat, SwingTwist, Vec3};
let parts: SwingTwist = Quat::from_rotation_y(0.4).try_swing_twist(Vec3::Y).unwrap();
assert!(!parts.is_singular);
assert!(parts.swing.try_angle_between(Quat::IDENTITY).unwrap() < 1.0e-6);
assert!((parts.twist_angle - 0.4).abs() < 1.0e-6);

Fields§

§swing: Quat

Swing factor; applied after Self::twist.

§twist: Quat

Twist factor about the normalized authored axis.

§twist_angle: f32

Signed shortest twist in radians, in [-pi, pi].

§is_singular: bool

True for an exact half-turn swing with underdetermined twist.

In that case twist is identity, twist_angle is zero and swing retains the entire input rotation. This is a convention, not a measured zero twist. Near-singular rotations are not snapped to this convention.

Trait Implementations§

Source§

impl Clone for SwingTwist

Source§

fn clone(&self) -> SwingTwist

Returns a duplicate 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 SwingTwist

Source§

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

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

impl PartialEq for SwingTwist

Source§

fn eq(&self, other: &SwingTwist) -> 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 Copy for SwingTwist

Source§

impl StructuralPartialEq for SwingTwist

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.