pub struct Quaternion {
pub x: f32,
pub y: f32,
pub z: f32,
pub w: f32,
}Expand description
Unit quaternion used for 3D rotation interpolation.
The components are stored as (x, y, z, w). Interpolate uses
shortest-path spherical linear interpolation.
Fields§
§x: f32X component of the vector part.
y: f32Y component of the vector part.
z: f32Z component of the vector part.
w: f32Scalar part.
Implementations§
Source§impl Quaternion
impl Quaternion
Sourcepub const IDENTITY: Quaternion
pub const IDENTITY: Quaternion
Identity rotation.
Sourcepub fn from_axis_angle(axis: [f32; 3], angle: Angle) -> Quaternion
pub fn from_axis_angle(axis: [f32; 3], angle: Angle) -> Quaternion
Create a quaternion from an axis and angle in degrees.
Sourcepub fn dot(self, other: Quaternion) -> f32
pub fn dot(self, other: Quaternion) -> f32
Dot product between two quaternions.
Sourcepub fn normalized(self) -> Quaternion
pub fn normalized(self) -> Quaternion
Return a normalized quaternion, or identity when length is invalid.
Sourcepub fn negated(self) -> Quaternion
pub fn negated(self) -> Quaternion
Return the negated representation of the same rotation.
Sourcepub fn slerp(self, other: Quaternion, t: f32) -> Quaternion
pub fn slerp(self, other: Quaternion, t: f32) -> Quaternion
Spherical linear interpolation using the shortest rotation path.
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 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for Quaternion
Source§impl Debug for Quaternion
impl Debug for Quaternion
Source§impl Interpolate for Quaternion
impl Interpolate for Quaternion
Source§fn lerp(&self, other: &Quaternion, t: f32) -> Quaternion
fn lerp(&self, other: &Quaternion, t: f32) -> Quaternion
Source§impl PartialEq for Quaternion
impl PartialEq for Quaternion
Source§fn eq(&self, other: &Quaternion) -> bool
fn eq(&self, other: &Quaternion) -> bool
Tests for
self and other values to be equal, and is used by ==.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§
impl<T> Animatable for Twhere
T: Interpolate + Clone + 'static,
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