#[repr(C)]pub struct Quat {
pub x: Float,
pub y: Float,
pub z: Float,
pub w: Float,
}Expand description
A quaternion for representing rotations.
Stored as (x, y, z, w) where w is the scalar component.
Fields§
§x: FloatX component (vector part).
y: FloatY component (vector part).
z: FloatZ component (vector part).
w: FloatW component (scalar part).
Implementations§
Source§impl Quat
impl Quat
Sourcepub const fn new(x: Float, y: Float, z: Float, w: Float) -> Self
pub const fn new(x: Float, y: Float, z: Float, w: Float) -> Self
Creates a quaternion from components.
Sourcepub fn from_axis_angle(axis: Vec3, angle: Float) -> Self
pub fn from_axis_angle(axis: Vec3, angle: Float) -> Self
Creates a quaternion from an axis and angle.
Sourcepub fn from_euler_xyz(x: Float, y: Float, z: Float) -> Self
pub fn from_euler_xyz(x: Float, y: Float, z: Float) -> Self
Creates a quaternion from Euler angles (XYZ order).
Sourcepub fn length_squared(self) -> Float
pub fn length_squared(self) -> Float
Computes the squared length.
Sourcepub fn lerp(self, other: Self, t: Float) -> Self
pub fn lerp(self, other: Self, t: Float) -> Self
Linear interpolation between quaternions.
Note: For most cases, prefer slerp for smooth interpolation.
Sourcepub fn nlerp(self, other: Self, t: Float) -> Self
pub fn nlerp(self, other: Self, t: Float) -> Self
Normalized linear interpolation (faster than slerp, nearly as good).
Sourcepub fn slerp(self, other: Self, t: Float) -> Self
pub fn slerp(self, other: Self, t: Float) -> Self
Spherical linear interpolation between quaternions.
Sourcepub fn to_euler_xyz(self) -> (Float, Float, Float)
pub fn to_euler_xyz(self) -> (Float, Float, Float)
Converts to Euler angles (XYZ order) in radians.
Sourcepub fn to_axis_angle(self) -> (Vec3, Float)
pub fn to_axis_angle(self) -> (Vec3, Float)
Returns the axis and angle of this rotation.
Trait Implementations§
impl Copy for Quat
impl StructuralPartialEq for Quat
Auto Trait Implementations§
impl Freeze for Quat
impl RefUnwindSafe for Quat
impl Send for Quat
impl Sync for Quat
impl Unpin for Quat
impl UnwindSafe for Quat
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more