Struct Quat

Source
#[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: f32

Implementations§

Source§

impl Quat

Source

pub const IDENTITY: Self

Source

pub const NAN: Self

Source

pub const fn from_xyzw(x: f32, y: f32, z: f32, w: f32) -> Self

Source

pub const fn from_array(v: [f32; 4]) -> Self

Source

pub const fn to_array(self) -> [f32; 4]

Source

pub const fn from_vec4(v: Vec4) -> Self

Source

pub const fn to_vec4(self) -> Vec4

Source

pub const fn xyz(self) -> Vec3

Source

pub fn from_axis_angle(axis: Vec3, angle: f32) -> Self

Finite nonzero axes are normalized. A zero axis returns NaNs.

Source

pub fn from_rotation_x(angle: f32) -> Self

Source

pub fn from_rotation_y(angle: f32) -> Self

Source

pub fn from_rotation_z(angle: f32) -> Self

Source

pub fn from_euler(order: EulerRot, a: f32, b: f32, c: f32) -> Self

Source

pub fn from_scaled_axis(axis: Vec3) -> Self

Source

pub fn from_rotation_arc(from: Vec3, to: Vec3) -> Self

Shortest rotation between two finite nonzero directions.

Source

pub fn to_axis_angle(self) -> (Vec3, f32)

Source

pub fn to_scaled_axis(self) -> Vec3

Source

pub fn dot(self, rhs: Self) -> f32

Source

pub fn length_squared(self) -> f32

Source

pub fn length(self) -> f32

Source

pub fn is_finite(self) -> bool

Source

pub fn is_nan(self) -> bool

Source

pub fn is_normalized(self) -> bool

Source

pub fn try_normalize(self) -> Option<Self>

Source

pub fn normalize(self) -> Self

Source

pub const fn conjugate(self) -> Self

Source

pub fn try_inverse(self) -> Option<Self>

Algebraic inverse, also correct for finite non-unit quaternions.

Source

pub fn inverse(self) -> Self

Source

pub fn mul_vec3(self, v: Vec3) -> Vec3

Applies a unit quaternion rotation. Non-unit quaternions must be normalized first.

Source

pub fn mul_quat(self, rhs: Self) -> Self

Source

pub fn lerp(self, rhs: Self, t: f32) -> Self

Source

pub fn slerp(self, rhs: Self, t: f32) -> Self

Spherical interpolation follows the shortest rotation and normalizes endpoints.

Source

pub fn angle_between(self, rhs: Self) -> f32

Source

pub fn abs_diff_eq(self, rhs: Self, tolerance: f32) -> bool

Source

pub fn rotate_towards(self, rhs: Self, max_angle: f32) -> Self

Trait Implementations§

Source§

impl Add for Quat

Source§

type Output = Quat

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self

Performs the + operation. Read more
Source§

impl Clone for Quat

Source§

fn clone(&self) -> Quat

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Quat

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Quat

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Div<f32> for Quat

Source§

type Output = Quat

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f32) -> Self

Performs the / operation. Read more
Source§

impl From<[f32; 4]> for Quat

Source§

fn from(v: [f32; 4]) -> Self

Converts to this type from the input type.
Source§

impl From<Quat> for [f32; 4]

Source§

fn from(v: Quat) -> Self

Converts to this type from the input type.
Source§

impl From<Quat> for Vec4

Source§

fn from(v: Quat) -> Self

Converts to this type from the input type.
Source§

impl Mul<Quat> for f32

Source§

type Output = Quat

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Quat) -> Quat

Performs the * operation. Read more
Source§

impl Mul<Vec3> for Quat

Source§

type Output = Vec3

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Vec3) -> Vec3

Performs the * operation. Read more
Source§

impl Mul<f32> for Quat

Source§

type Output = Quat

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f32) -> Self

Performs the * operation. Read more
Source§

impl Mul for Quat

Source§

type Output = Quat

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self

Performs the * operation. Read more
Source§

impl MulAssign for Quat

Source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
Source§

impl Neg for Quat

Source§

type Output = Quat

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl PartialEq for Quat

Source§

fn eq(&self, other: &Quat) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Sub for Quat

Source§

type Output = Quat

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self

Performs the - operation. Read more
Source§

impl Copy for Quat

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.