[][src]Struct duku::Quaternion

pub struct Quaternion {
    pub x: f32,
    pub y: f32,
    pub z: f32,
    pub w: f32,
}

Compact 3D rotation representation.

Used for rotating vectors

Example

This example is not tested
let vector = Vector3::UP;
let quat = Quaternion::euler_rotation(0.0, 0.0, 90.0);
assert_eq!(quat * vector, Vector3::RIGHT);

Fields

x: f32

the X component

y: f32

the Y component

z: f32

the Z component

w: f32

the W component

Implementations

impl Quaternion[src]

pub const fn new(x: f32, y: f32, z: f32, w: f32) -> Self[src]

Create quaternion

pub fn euler_rotation(x: f32, y: f32, z: f32) -> Self[src]

Create quaternion with euler angles

This rotation's yaw, pitch and roll are z, y and x

pub fn axis_rotation(axis: impl Into<Vector3>, angle: f32) -> Self[src]

Create quaternion around axis

This rotates vectors around axis by the angle

pub fn look_rotation(
    dir: impl Into<Vector3>,
    global_up: impl Into<Vector3>
) -> Self
[src]

Create quaternion to rotate towards direction

Note: global_up is used as a guide to try aligning to

pub fn inverse(self) -> Quaternion[src]

Calculate the inverse rotation

Trait Implementations

impl Clone for Quaternion[src]

impl Copy for Quaternion[src]

impl Debug for Quaternion[src]

impl Default for Quaternion[src]

impl From<Matrix4> for Quaternion[src]

impl From<Quaternion> for Matrix4[src]

impl Mul<Quaternion> for Quaternion[src]

type Output = Self

The resulting type after applying the * operator.

impl Mul<Vector3> for Quaternion[src]

type Output = Vector3

The resulting type after applying the * operator.

impl MulAssign<Quaternion> for Quaternion[src]

impl PartialEq<Quaternion> for Quaternion[src]

impl StructuralPartialEq for Quaternion[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.