Skip to main content

Quat

Struct Quat 

Source
#[repr(C, align(16))]
pub struct Quat { pub x: f32, pub y: f32, pub z: f32, pub w: f32, }
Expand description

A SIMD-aligned quaternion stored as (x, y, z, w).

Fields§

§x: f32

X component.

§y: f32

Y component.

§z: f32

Z component.

§w: f32

Scalar component.

Implementations§

Source§

impl Quat

Source

pub const IDENTITY: Self

Identity rotation.

Source

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

Builds a quaternion.

Source

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

Builds from an array.

Source

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

Returns components.

Source

pub fn from_rotation_x(angle: f32) -> Self

Rotation around X.

Source

pub fn from_rotation_y(angle: f32) -> Self

Rotation around Y.

Source

pub fn from_rotation_z(angle: f32) -> Self

Rotation around Z.

Source

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

Rotation around a normalized axis.

Source

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

Shortest rotation between directions.

Source

pub fn from_mat3(matrix: &Mat3) -> Self

Builds from a rotation matrix.

Source

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

Spherical interpolation.

Source

pub fn is_finite(self) -> bool

Returns whether every component is finite.

Source

pub fn length_squared(self) -> f32

Squared quaternion length.

Source

pub fn normalize(self) -> Self

Returns a normalized quaternion.

Trait Implementations§

Source§

impl Clone for Quat

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Quat

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<'de> Deserialize<'de> for Quat

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<Quat> for [f32; 4]

Source§

fn from(value: Quat) -> Self

Converts to this type from the input type.
Source§

impl From<Quat> for Quat

Source§

fn from(value: Quat) -> Self

Converts to this type from the input type.
Source§

impl From<Quat> for Quat

Source§

fn from(value: Quat) -> Self

Converts to this type from the input type.
Source§

impl From<[f32; 4]> for Quat

Source§

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

Converts to this type from the input type.
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 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 PartialEq for Quat

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Pod for Quat

Source§

impl Serialize for Quat

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Quat

Source§

impl Zeroable for Quat

Source§

fn zeroed() -> Self

Auto Trait Implementations§

§

impl Freeze for Quat

§

impl RefUnwindSafe for Quat

§

impl Send for Quat

§

impl Sync for Quat

§

impl Unpin for Quat

§

impl UnsafeUnpin 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> AnyBitPattern for T
where T: Pod,

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> CheckedBitPattern for T
where T: AnyBitPattern,

Source§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
Source§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> NoUninit for T
where T: Pod,

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.