[][src]Struct duku::Quat

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

Compact 3D rotation representation.

Used for rotating vectors

Examples

let vector = Vec3::up();
let quat = Quat::euler_rotation(0.0, 0.0, 90.0);
let rotated = quat * vector;

Fields

x: f32

the X component

y: f32

the Y component

z: f32

the Z component

w: f32

the W component

Implementations

impl Quat[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<Vec3>, angle: f32) -> Self[src]

Create quaternion around axis

This rotates vectors around axis by the angle

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

Create quaternion to rotate towards direction

global_up is used as a guide to try aligning to

pub fn local_up(self) -> Vec3[src]

local up direction for transformation

pub fn local_forward(self) -> Vec3[src]

local forward direction for transformation

pub fn local_right(self) -> Vec3[src]

local right direction for transformation

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

Calculate the inverse rotation

Trait Implementations

impl Clone for Quat[src]

impl Copy for Quat[src]

impl Debug for Quat[src]

impl Default for Quat[src]

impl From<[f32; 4]> for Quat[src]

impl From<Mat4> for Quat[src]

impl From<Quat> for Mat4[src]

impl Mul<Quat> for Quat[src]

type Output = Self

The resulting type after applying the * operator.

impl Mul<Vec3> for Quat[src]

type Output = Vec3

The resulting type after applying the * operator.

impl MulAssign<Quat> for Quat[src]

impl PartialEq<Quat> for Quat[src]

impl StructuralPartialEq for Quat[src]

Auto Trait Implementations

impl RefUnwindSafe for Quat

impl Send for Quat

impl Sync for Quat

impl Unpin for Quat

impl UnwindSafe for Quat

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.