Skip to main content

Quaternion

Struct Quaternion 

Source
pub struct Quaternion { /* private fields */ }
Expand description

A quaternion representing a 3D rotation with x, y, z, and w components.

Implementations§

Source§

impl Quaternion

Implements quaternion operations for Quaternion.

Source

pub fn identity() -> Quaternion

Returns the identity quaternion (0, 0, 0, 1) representing no rotation.

§Returns
  • Quaternion - The identity quaternion.
Source

pub fn from_axis_angle(axis: Vector3D, angle: f64) -> Quaternion

Creates a quaternion from a rotation around an axis.

§Arguments
  • Vector3D - The rotation axis (should be normalized).
  • f64 - The rotation angle in radians.
§Returns
  • Quaternion - The rotation quaternion.
Source

pub fn from_euler(yaw: f64, pitch: f64, roll: f64) -> Quaternion

Creates a quaternion from Euler angles (yaw, pitch, roll) in radians.

§Arguments
  • f64 - The yaw (rotation around y axis) in radians.
  • f64 - The pitch (rotation around x axis) in radians.
  • f64 - The roll (rotation around z axis) in radians.
§Returns
  • Quaternion - The rotation quaternion.
Source

pub fn magnitude(&self) -> f64

Returns the magnitude of the quaternion.

§Returns
  • f64 - The magnitude.
Source

pub fn normalized(&self) -> Quaternion

Returns a normalized copy of this quaternion.

§Returns
  • Quaternion - The normalized quaternion.
Source

pub fn conjugate(&self) -> Quaternion

Returns the conjugate of this quaternion.

§Returns
  • Quaternion - The conjugate quaternion.
Source

pub fn dot(&self, other: Quaternion) -> f64

Computes the dot product with another quaternion.

§Arguments
  • Quaternion - The other quaternion.
§Returns
  • f64 - The dot product.
Source

pub fn slerp(&self, other: Quaternion, t: f64) -> Quaternion

Performs spherical linear interpolation between this and another quaternion.

§Arguments
  • Quaternion - The target quaternion.
  • f64 - The interpolation factor in the range 0.0 to 1.0.
§Returns
  • Quaternion - The interpolated quaternion.
Source§

impl Quaternion

Source

pub fn get_x(&self) -> f64

Source

pub fn get_mut_x(&mut self) -> &mut f64

Source

pub fn set_x(&mut self, val: f64) -> &mut Self

Source

pub fn get_y(&self) -> f64

Source

pub fn get_mut_y(&mut self) -> &mut f64

Source

pub fn set_y(&mut self, val: f64) -> &mut Self

Source

pub fn get_z(&self) -> f64

Source

pub fn get_mut_z(&mut self) -> &mut f64

Source

pub fn set_z(&mut self, val: f64) -> &mut Self

Source

pub fn get_w(&self) -> f64

Source

pub fn get_mut_w(&mut self) -> &mut f64

Source

pub fn set_w(&mut self, val: f64) -> &mut Self

Source§

impl Quaternion

Source

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

Trait Implementations§

Source§

impl Clone for Quaternion

Source§

fn clone(&self) -> Quaternion

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 Quaternion

Source§

impl Debug for Quaternion

Source§

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

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

impl Default for Quaternion

Implements Default for Quaternion as the identity quaternion.

Source§

fn default() -> Quaternion

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

impl Mul for Quaternion

Implements quaternion multiplication.

Source§

type Output = Quaternion

The resulting type after applying the * operator.
Source§

fn mul(self, other: Quaternion) -> Quaternion

Performs the * operation. Read more
Source§

impl PartialEq for Quaternion

Source§

fn eq(&self, other: &Quaternion) -> 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 PartialOrd for Quaternion

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 StructuralPartialEq for Quaternion

Auto Trait Implementations§

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

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more