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: QuatSwing factor; applied after Self::twist.
twist: QuatTwist factor about the normalized authored axis.
twist_angle: f32Signed shortest twist in radians, in [-pi, pi].
is_singular: boolTrue 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
impl Clone for SwingTwist
Source§fn clone(&self) -> SwingTwist
fn clone(&self) -> SwingTwist
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SwingTwist
impl Debug for SwingTwist
Source§impl PartialEq for SwingTwist
impl PartialEq for SwingTwist
impl Copy for SwingTwist
impl StructuralPartialEq for SwingTwist
Auto Trait Implementations§
impl Freeze for SwingTwist
impl RefUnwindSafe for SwingTwist
impl Send for SwingTwist
impl Sync for SwingTwist
impl Unpin for SwingTwist
impl UnwindSafe for SwingTwist
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more