pub struct Quaternion {
pub w: f32,
pub x: f32,
pub y: f32,
pub z: f32,
}Expand description
Unit quaternion for 3D rotation: q = w + xi + yj + zk.
Fields§
§w: f32§x: f32§y: f32§z: f32Implementations§
Source§impl Quaternion
impl Quaternion
pub const IDENTITY: Self
pub fn new(w: f32, x: f32, y: f32, z: f32) -> Self
Sourcepub fn from_axis_angle(axis: Vec3, angle: f32) -> Self
pub fn from_axis_angle(axis: Vec3, angle: f32) -> Self
Create from axis-angle (axis must be normalized).
Sourcepub fn from_euler(roll: f32, pitch: f32, yaw: f32) -> Self
pub fn from_euler(roll: f32, pitch: f32, yaw: f32) -> Self
Create from Euler angles (roll, pitch, yaw) in radians.
pub fn norm(self) -> f32
pub fn normalize(self) -> Self
pub fn conjugate(self) -> Self
pub fn inverse(self) -> Self
pub fn dot(self, rhs: Self) -> f32
Sourcepub fn slerp(self, other: Self, t: f32) -> Self
pub fn slerp(self, other: Self, t: f32) -> Self
Spherical linear interpolation between two quaternions.
Sourcepub fn axis(self) -> Vec3
pub fn axis(self) -> Vec3
Extract the rotation axis (normalized). Returns Y if rotation is near zero.
Sourcepub fn exp_map(v: Vec3) -> Self
pub fn exp_map(v: Vec3) -> Self
Exponential map: converts a rotation vector (axis * angle) to a quaternion.
Trait Implementations§
Source§impl Clone for Quaternion
impl Clone for Quaternion
Source§fn clone(&self) -> Quaternion
fn clone(&self) -> Quaternion
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 Quaternion
impl Debug for Quaternion
Source§impl Default for Quaternion
impl Default for Quaternion
Source§impl Mul for Quaternion
impl Mul for Quaternion
Source§impl PartialEq for Quaternion
impl PartialEq for Quaternion
impl Copy for Quaternion
impl StructuralPartialEq for Quaternion
Auto Trait Implementations§
impl Freeze for Quaternion
impl RefUnwindSafe for Quaternion
impl Send for Quaternion
impl Sync for Quaternion
impl Unpin for Quaternion
impl UnsafeUnpin for Quaternion
impl UnwindSafe for Quaternion
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.