#[repr(C)]pub struct Quat {
pub x: f32,
pub y: f32,
pub z: f32,
pub w: f32,
}Expand description
Quaternion stored as vector part (x,y,z) followed by scalar part w.
Fields§
§x: f32§y: f32§z: f32§w: f32Implementations§
Source§impl Quat
impl Quat
pub const IDENTITY: Quat
pub const NAN: Quat
pub const fn from_xyzw(x: f32, y: f32, z: f32, w: f32) -> Quat
pub const fn from_array(v: [f32; 4]) -> Quat
pub const fn to_array(self) -> [f32; 4]
pub const fn from_vec4(v: Vec4) -> Quat
pub const fn to_vec4(self) -> Vec4
pub const fn xyz(self) -> Vec3
Sourcepub fn from_axis_angle(axis: Vec3, angle: f32) -> Quat
pub fn from_axis_angle(axis: Vec3, angle: f32) -> Quat
Finite nonzero axes are normalized. A zero axis returns NaNs.
pub fn from_rotation_x(angle: f32) -> Quat
pub fn from_rotation_y(angle: f32) -> Quat
pub fn from_rotation_z(angle: f32) -> Quat
pub fn from_euler(order: EulerRot, a: f32, b: f32, c: f32) -> Quat
pub fn from_scaled_axis(axis: Vec3) -> Quat
Sourcepub fn from_rotation_arc(from: Vec3, to: Vec3) -> Quat
pub fn from_rotation_arc(from: Vec3, to: Vec3) -> Quat
Shortest rotation between two finite nonzero directions.
pub fn to_axis_angle(self) -> (Vec3, f32)
pub fn to_scaled_axis(self) -> Vec3
pub fn dot(self, rhs: Quat) -> f32
pub fn length_squared(self) -> f32
pub fn length(self) -> f32
pub fn is_finite(self) -> bool
pub fn is_nan(self) -> bool
pub fn is_normalized(self) -> bool
pub fn try_normalize(self) -> Option<Quat>
pub fn normalize(self) -> Quat
pub const fn conjugate(self) -> Quat
Sourcepub fn try_inverse(self) -> Option<Quat>
pub fn try_inverse(self) -> Option<Quat>
Algebraic inverse, also correct for finite non-unit quaternions.
pub fn inverse(self) -> Quat
Sourcepub fn mul_vec3(self, v: Vec3) -> Vec3
pub fn mul_vec3(self, v: Vec3) -> Vec3
Applies a unit quaternion rotation. Non-unit quaternions must be normalized first.
pub fn mul_quat(self, rhs: Quat) -> Quat
pub fn lerp(self, rhs: Quat, t: f32) -> Quat
Sourcepub fn slerp(self, rhs: Quat, t: f32) -> Quat
pub fn slerp(self, rhs: Quat, t: f32) -> Quat
Spherical interpolation follows the shortest rotation and normalizes endpoints.
pub fn angle_between(self, rhs: Quat) -> f32
pub fn abs_diff_eq(self, rhs: Quat, tolerance: f32) -> bool
pub fn rotate_towards(self, rhs: Quat, max_angle: f32) -> Quat
Trait Implementations§
Source§impl MulAssign for Quat
impl MulAssign for Quat
Source§fn mul_assign(&mut self, rhs: Quat)
fn mul_assign(&mut self, rhs: Quat)
Performs the
*= operation. Read moreimpl 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§
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