Quat

Struct Quat 

Source
pub struct Quat<E>(pub Vector<E, 4>)
where
    E: MatEl;
Expand description

Represents a quaternion using a 4D vector for its components [x, y, z, w].

The w component is the scalar part, and (x, y, z) is the vector part.

Tuple Fields§

§0: Vector<E, 4>

Implementations§

Source§

impl<E> Quat<E>
where E: MatEl,

Source

pub fn x(&self) -> E

The x component of Quaternion

Source

pub fn y(&self) -> E

The y component of Quaternion

Source

pub fn z(&self) -> E

The z component of Quaternion

Source

pub fn w(&self) -> E

The w component of Quaternion

Source§

impl<E> Quat<E>
where E: MatEl + NdFloat,

Source

pub fn from_axis_angle<T>(axis: T, angle: E) -> Self
where T: VectorIter<E, 3>,

Creates a quaternion from a normalized axis and an angle in radians.

§Arguments
  • axis - The normalized 3D vector representing the axis of rotation.
  • angle - The angle of rotation in radians.
Source

pub fn normalize(self) -> Self

Normalizes the quaternion to have a magnitude of 1.

Source

pub fn to_array(&self) -> [E; 4]

Converts the quaternion’s components into a 4-element array [x, y, z, w].

Source

pub fn conjugate(self) -> Self

Computes the conjugate of the quaternion, inverting its vector part.

Source

pub fn mag2(&self) -> E

Calculates the squared magnitude (length) of the quaternion.

Source

pub fn mag(&self) -> E

Calculates the magnitude (length) of the quaternion.

Source

pub fn dot(&self, other: &Self) -> E

Computes the dot product of this quaternion with another.

Source

pub fn multiply(&self, other: &Self) -> Self

Multiplies this quaternion by another quaternion (self * other).

Source

pub fn multiply_mut(&mut self, other: &Self)

Multiplies this quaternion by another in-place.

Source

pub fn premultiply(&self, other: &Self) -> Self

Multiplies another quaternion by this one (other * self).

Source

pub fn premultiply_mut(&mut self, other: &Self)

Multiplies another quaternion by this one in-place.

Source

pub fn devide(&self, other: &Self) -> Self

Divides this quaternion by another (equivalent to self * other.invert()).

Source

pub fn device_mut(&mut self, other: &Self)

Divides this quaternion by another in-place.

Source

pub fn slerp(self, other: &Self, s: E) -> Self

Performs spherical linear interpolation (slerp) between two unit quaternions.

§Arguments
  • other - The target quaternion to interpolate towards.
  • s - The interpolation factor, a value between 0.0 and 1.0.
Source

pub fn slerp_mut(&mut self, other: &Self, s: E)

Performs spherical linear interpolation (slerp) in-place.

Source

pub fn invert(&self) -> Self

Inverts the unit-length quaternion, which is equivalent to its conjugate.

Source

pub fn to_matrix(&self) -> Mat3<E, DescriptorOrderColumnMajor>

Converts the quaternion into a column-major 3x3 rotation matrix.

Source

pub fn from_angle_x(x: E) -> Self

Creates a quaternion representing a rotation around the X-axis.

§Arguments
  • x - The rotation angle in radians.
Source

pub fn from_angle_y(y: E) -> Self

Creates a quaternion representing a rotation around the Y-axis.

§Arguments
  • y - The rotation angle in radians.
Source

pub fn from_angle_z(z: E) -> Self

Creates a quaternion representing a rotation around the Z-axis.

§Arguments
  • z - The rotation angle in radians.
Source

pub fn from_euler_xyz<T: VectorIter<E, 3>>(angles: T) -> Self

Creates a quaternion from Euler angles in XYZ order.

§Arguments
  • angles - A 3D vector containing the rotation angles (in radians) for the X, Y, and Z axes.

Trait Implementations§

Source§

impl<E> AbsDiffEq for Quat<E>
where E: AbsDiffEq + MatEl, E::Epsilon: Copy,

Source§

type Epsilon = <Vector<E, 4> as AbsDiffEq>::Epsilon

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<E> Add for &Quat<E>
where E: MatEl + NdFloat,

Source§

type Output = Quat<E>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<E> Add for Quat<E>
where E: MatEl + NdFloat,

Source§

type Output = Quat<E>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<E> AddAssign<E> for Quat<E>
where E: MatEl + NdFloat,

Source§

fn add_assign(&mut self, rhs: E)

Performs the += operation. Read more
Source§

impl<E> AddAssign for Quat<E>
where E: MatEl + NdFloat,

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl<E> Clone for Quat<E>
where E: MatEl + Clone,

Source§

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

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<E> Debug for Quat<E>
where E: MatEl + Debug,

Source§

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

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

impl<E> Default for Quat<E>
where E: MatEl + Default,

Source§

fn default() -> Quat<E>

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

impl<E> Div<E> for Quat<E>
where E: MatEl + NdFloat,

Source§

type Output = Quat<E>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: E) -> Self::Output

Performs the / operation. Read more
Source§

impl<E> Div for Quat<E>
where E: MatEl + NdFloat,

Source§

type Output = Quat<E>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<E> DivAssign<E> for Quat<E>
where E: MatEl + NdFloat,

Source§

fn div_assign(&mut self, rhs: E)

Performs the /= operation. Read more
Source§

impl<E> DivAssign for Quat<E>
where E: MatEl + NdFloat,

Source§

fn div_assign(&mut self, rhs: Self)

Performs the /= operation. Read more
Source§

impl<E: MatEl> From<&[E]> for Quat<E>

Source§

fn from(value: &[E]) -> Self

Converts to this type from the input type.
Source§

impl<E: MatEl> From<[E; 4]> for Quat<E>

Source§

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

Converts to this type from the input type.
Source§

impl<E: MatEl> From<(E, E, E, E)> for Quat<E>

Source§

fn from(value: (E, E, E, E)) -> Self

Converts to this type from the input type.
Source§

impl<E> Index<usize> for Quat<E>
where E: MatEl,

Source§

type Output = E

The returned type after indexing.
Source§

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

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

impl<E> IndexMut<usize> for Quat<E>
where E: MatEl,

Source§

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

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

impl<E> Mul<E> for Quat<E>
where E: MatEl + NdFloat,

Source§

type Output = Quat<E>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<E> Mul for Quat<E>
where E: MatEl + NdFloat,

Source§

type Output = Quat<E>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<E> MulAssign<E> for Quat<E>
where E: MatEl + NdFloat,

Source§

fn mul_assign(&mut self, rhs: E)

Performs the *= operation. Read more
Source§

impl<E> MulAssign for Quat<E>
where E: MatEl + NdFloat,

Source§

fn mul_assign(&mut self, rhs: Quat<E>)

Performs the *= operation. Read more
Source§

impl<E> PartialEq for Quat<E>
where E: MatEl + PartialEq,

Source§

fn eq(&self, other: &Quat<E>) -> 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<E> PartialOrd for Quat<E>
where E: MatEl + PartialOrd,

Source§

fn partial_cmp(&self, other: &Quat<E>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<E> RelativeEq for Quat<E>
where E: RelativeEq + MatEl, E::Epsilon: Copy,

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<E> Sub<E> for Quat<E>
where E: MatEl + NdFloat,

Source§

type Output = Quat<E>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<E> Sub for &Quat<E>
where E: MatEl + NdFloat,

Source§

type Output = Quat<E>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<E> Sub for Quat<E>
where E: MatEl + NdFloat,

Source§

type Output = Quat<E>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<E> SubAssign for Quat<E>
where E: MatEl + NdFloat,

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl<E> UlpsEq for Quat<E>
where E: UlpsEq + MatEl, E::Epsilon: Copy,

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

impl<E> Copy for Quat<E>
where E: MatEl + Copy,

Source§

impl<E> StructuralPartialEq for Quat<E>
where E: MatEl,

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<E> UnwindSafe for Quat<E>
where E: 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> CloneDyn for T
where T: Clone,

Source§

fn __clone_dyn(&self, _: DontCallMe) -> *mut ()

Source§

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

Source§

fn __clone_dyn(&self, _: DontCallMe) -> *mut ()

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<All> From1<()> for All
where All: Default,

Source§

fn from1(_a: ()) -> All

Constructor with a single arguments.
Source§

impl<T, All> From1<(T,)> for All
where All: From1<T>,

Source§

fn from1(arg: (T,)) -> All

Constructor with a single arguments.
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<All, F> Into1<F> for All
where F: From1<All>,

Source§

fn to(self) -> F

Converts this type into the (usually inferred) input type.
Source§

impl<T> IntoResult<T> for T

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> ToRef<T> for T
where T: ?Sized,

Source§

fn to_ref(&self) -> &T

Converts the implementing type to an immutable reference. Read more
Source§

impl<T> ToValue<T> for T

Source§

fn to_value(self) -> T

Obtains the value from the implementing type. 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.
Source§

impl<T> MatEl for T
where T: Copy + Default,