Skip to main content

Quat

Struct Quat 

Source
#[repr(C)]
pub struct Quat<T: QuatScalar> { pub x: T, pub y: T, pub z: T, pub w: T, }
Expand description

A quaternion type, representing a rotation in 3D space.

Fields§

§x: T

The x component of the quaternion.

§y: T

The y component of the quaternion.

§z: T

The z component of the quaternion.

§w: T

The w component of the quaternion.

Implementations§

Source§

impl<T: QuatScalar> Quat<T>

Source

pub const IDENTITY: Self

The identity quaternion, representing no rotation.

Source

pub const fn new(x: T, y: T, z: T, w: T) -> Self

Creates a new quaternion with the given components.

Source§

impl<T> Quat<T>
where T: QuatScalar,

Source

pub const fn splat(scalar: T) -> Self

Creates a new instance of the tuple type with all elements set to the given scalar value.

Source

pub const fn as_ptr(&self) -> *const T

Returns a raw pointer to the first element of the tuple.

Source

pub const fn as_mut_ptr(&mut self) -> *mut T

Returns a mutable raw pointer to the first element of the tuple.

Source

pub const fn as_slice(&self) -> &[T]

Returns a slice containing all elements of the tuple.

Source

pub const fn as_mut_slice(&mut self) -> &mut [T]

Returns a mutable slice containing all elements of the tuple.

Source

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

Converts the tuple into an array of its scalar elements.

Source

pub const fn from_array(a: [T; 4]) -> Self

Creates a new instance of the tuple type from an array of scalar elements.

Source§

impl<T> Quat<T>
where T: QuatScalar,

Source

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

Trait Implementations§

Source§

impl<T> AbsDiffEq for Quat<T>
where T: QuatScalar + AbsDiffEq<Epsilon = T>,

Source§

type Epsilon = T

Used for specifying relative comparisons.
Source§

fn default_epsilon() -> Self::Epsilon

The default tolerance to use when testing values that are close together. Read more
Source§

fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool

A test for equality that uses the absolute difference to compute the approximate equality of two numbers.
Source§

fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool

The inverse of AbsDiffEq::abs_diff_eq.
Source§

impl<T> AsMut<[T]> for Quat<T>
where T: QuatScalar,

Source§

fn as_mut(&mut self) -> &mut [T]

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<T> AsRef<[T]> for Quat<T>
where T: QuatScalar,

Source§

fn as_ref(&self) -> &[T]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T: Clone + QuatScalar> Clone for Quat<T>

Source§

fn clone(&self) -> Quat<T>

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<T: Copy + QuatScalar> Copy for Quat<T>

Source§

impl<T: Debug + QuatScalar> Debug for Quat<T>

Source§

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

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

impl<T> Default for Quat<T>
where T: QuatScalar,

Source§

fn default() -> Self

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

impl<T> DotProduct for Quat<T>
where T: QuatScalar,

Source§

type Output = T

Source§

fn dot(self, rhs: Self) -> Self::Output

Computes the dot product of two values.
Source§

impl<T> From<Quat<T>> for [T; 4]
where T: QuatScalar,

Source§

fn from(t: Quat<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<[T; 4]> for Quat<T>
where T: QuatScalar,

Source§

fn from(a: [T; 4]) -> Self

Converts to this type from the input type.
Source§

impl<T> HasScalar for Quat<T>
where T: QuatScalar,

Source§

type Scalar = T

The associated scalar type for the implementing type.
Source§

impl<T> Index<usize> for Quat<T>
where T: QuatScalar,

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T> IndexMut<usize> for Quat<T>
where T: QuatScalar,

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<T> Neg for Quat<T>
where T: QuatScalar,

Source§

type Output = Quat<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<T> Negate for Quat<T>
where T: QuatScalar,

Source§

fn negate(self) -> Self

Returns the additive inverse of the value.
Source§

impl<T: PartialEq + QuatScalar> PartialEq for Quat<T>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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<T> Quaternion for Quat<T>
where T: QuatScalar,

Source§

impl<T> RelativeEq for Quat<T>
where T: QuatScalar + RelativeEq<Epsilon = T>,

Source§

fn default_max_relative() -> Self::Epsilon

The default relative tolerance for testing values that are far-apart. Read more
Source§

fn relative_eq( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool

A test for equality that uses a relative comparison if the values are far apart.
Source§

fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool

The inverse of RelativeEq::relative_eq.
Source§

impl<T> ScalarTuple for Quat<T>
where T: QuatScalar,

Source§

const LEN: usize = 4

The number of scalar elements in the tuple.
Source§

type Array = [T; 4]

The array type corresponding to the tuple, containing the same number of scalar elements.
Source§

fn splat(scalar: Self::Scalar) -> Self

Creates a new instance of the tuple type with all elements set to the given scalar value.
Source§

fn as_ptr(&self) -> *const Self::Scalar

Returns a raw pointer to the first element of the tuple.
Source§

fn as_mut_ptr(&mut self) -> *mut Self::Scalar

Returns a mutable raw pointer to the first element of the tuple.
Source§

fn as_slice(&self) -> &[Self::Scalar]

Returns a slice containing all elements of the tuple.
Source§

fn as_mut_slice(&mut self) -> &mut [Self::Scalar]

Returns a mutable slice containing all elements of the tuple.
Source§

fn to_array(self) -> Self::Array

Converts the tuple into an array of its scalar elements.
Source§

fn from_array(a: Self::Array) -> Self

Creates a new instance of the tuple type from an array of scalar elements.
Source§

impl<T: PartialEq + QuatScalar> StructuralPartialEq for Quat<T>

Source§

impl<T> UlpsEq for Quat<T>
where T: QuatScalar + UlpsEq<Epsilon = T>,

Source§

fn default_max_ulps() -> u32

The default ULPs to tolerate when testing values that are far-apart. Read more
Source§

fn ulps_eq(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool

A test for equality that uses units in the last place (ULP) if the values are far apart.
Source§

fn ulps_ne(&self, other: &Rhs, epsilon: Self::Epsilon, max_ulps: u32) -> bool

The inverse of UlpsEq::ulps_eq.

Auto Trait Implementations§

§

impl<T> Freeze for Quat<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Quat<T>
where T: RefUnwindSafe,

§

impl<T> Send for Quat<T>
where T: Send,

§

impl<T> Sync for Quat<T>
where T: Sync,

§

impl<T> Unpin for Quat<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Quat<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Quat<T>
where T: UnwindSafe,

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.