Struct Quaternion

Source
pub struct Quaternion<T> { /* private fields */ }

Implementations§

Source§

impl<T> Quaternion<T>
where T: Float,

Source

pub fn new(a: T, b: T, c: T, d: T) -> Self

Source

pub fn scalar_part(&self) -> T

Source

pub fn vector_part(&self) -> (T, T, T)

Source

pub fn conjugate(&self) -> Self

Source

pub fn dot(&self, o: &Quaternion<T>) -> T

Source

pub fn len(&self) -> T

Source

pub fn norm(&self) -> T

Source

pub fn inverse(&self) -> Self

Source

pub fn normalize(&self) -> Self

Make it a unit quaternion

Source

pub fn qm(&self, o: &Quaternion<T>) -> Self

Quaternion multiplication

Source

pub fn rotation_around_axis(axis: (T, T, T), theta: T) -> Self

Create a quaternion ready to apply to vector for rotation.

Source

pub fn rotate_around_x(theta: T) -> Self

Source

pub fn rotate_around_y(theta: T) -> Self

Source

pub fn rotate_around_z(theta: T) -> Self

Source

pub fn apply_rotation(&self, v: (T, T, T)) -> (T, T, T)

Apply unit quaternion to 3d vector for rotation.

Source

pub fn rotate_around_axis(axis: (T, T, T), theta: T, v: (T, T, T)) -> (T, T, T)

Source

pub fn unit_exp(&self, t: T) -> Self

Source

pub fn slerp(p: &Self, q: &Self, t: T) -> Self

Trait Implementations§

Source§

impl<T: Debug> Debug for Quaternion<T>

Source§

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

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

impl<T> Default for Quaternion<T>
where T: Float,

Source§

fn default() -> Self

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

impl<T> Div<T> for Quaternion<T>
where T: Float,

Source§

type Output = Quaternion<T>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<T: PartialEq> PartialEq for Quaternion<T>

Source§

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

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<T> UnwindSafe for Quaternion<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> 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, 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V