[][src]Struct hektor::Quat

#[repr(C)]
pub struct Quat { /* fields omitted */ }

A Quaternion: one scalar part (a) and three imaginary parts (b, c, and d).

This is a borderline magical mathematical construct. You can read about it on wikipedia, and 3blue1brown also did a video on them.

The basic idea is that, in similar to how you describe a standard complex number with one real part and one imaginary part, this thing is made up of a real part and three imaginary parts. Because there's three imaginary dimensions as well as a real one, it's kinda a four dimensional thing. This can be difficult to envision, because if you're reading this you're probably only three dimensional.

The practical application of it all is that you can store rotation and/or orientation information very well by using a quaternion.

Methods

impl Quat[src]

pub fn a(self) -> f32[src]

Gets the real coefficient of this quaternion.

pub fn b(self) -> f32[src]

Gets the i coefficient of this quaternion.

pub fn c(self) -> f32[src]

Gets the j coefficient of this quaternion.

pub fn d(self) -> f32[src]

Gets the k coefficient of this quaternion.

pub fn a_mut(&mut self) -> &mut f32[src]

&mut to the real coefficient of this quaternion.

pub fn b_mut(&mut self) -> &mut f32[src]

&mut to the i coefficient of this quaternion.

pub fn c_mut(&mut self) -> &mut f32[src]

&mut to the j coefficient of this quaternion.

pub fn d_mut(&mut self) -> &mut f32[src]

&mut to the k coefficient of this quaternion.

impl Quat[src]

pub fn new(a: f32, b: f32, c: f32, d: f32) -> Self[src]

Makes a new quaternion using the coefficients given.

pub fn splat(v: f32) -> Self[src]

Splats the given value across all coefficients.

pub fn length(self) -> f32[src]

The length / magnitude of the Quaternion.

  • sqrt(a^2 + b^2 + c^2 + d^2)

pub fn length2(self) -> f32[src]

The squared length / magnitude of the Quaternion.

  • a^2 + b^2 + c^2 + d^2

pub fn normalize(self) -> Self[src]

Generates a new quaternion where the length is 1.0

Or, well, as close as it can get. Floating point, and all that.

pub fn conjugate(self) -> Self[src]

The conjugate has the same length/magnitude, but the sign of the imaginary parts flipped.

This has various interesting properties which I don't at the moment fully understand the use of.

Trait Implementations

impl Display for Quat[src]

fn fmt(&self, f: &mut Formatter) -> Result[src]

Shows the quaternion in a standard a + bi + cj+ dk style.

Passes the formatter along to the fields, so you can use any normal f32 Display format arguments that you like.

impl Debug for Quat[src]

fn fmt(&self, f: &mut Formatter) -> Result[src]

Shows the fields with labels a, b, c, and d.

Passes the formatter along to the fields, so you can use any normal f32 Debug format arguments that you like.

impl UpperExp for Quat[src]

fn fmt(&self, f: &mut Formatter) -> Result[src]

UpperExp formats like Display, but with the upper exponent.

Passes the formatter along to the fields, so you can use any normal f32 UpperExp format arguments that you like.

impl LowerExp for Quat[src]

fn fmt(&self, f: &mut Formatter) -> Result[src]

LowerExp formats like Display, but with the lower exponent.

Passes the formatter along to the fields, so you can use any normal f32 LowerExp format arguments that you like.

impl PartialEq<Quat> for Quat[src]

impl Mul<f32> for Quat[src]

type Output = Self

The resulting type after applying the * operator.

impl Mul<Quat> for f32[src]

type Output = Quat

The resulting type after applying the * operator.

impl Mul<Quat> for Quat[src]

type Output = Self

The resulting type after applying the * operator.

impl MulAssign<f32> for Quat[src]

impl MulAssign<Quat> for Quat[src]

impl Index<usize> for Quat[src]

type Output = f32

The returned type after indexing.

impl IndexMut<usize> for Quat[src]

impl Copy for Quat[src]

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

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

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

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

impl Clone for Quat[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Default for Quat[src]

impl Pod for Quat[src]

impl Zeroable for Quat[src]

fn zeroed() -> Self[src]

Calls zeroed. Read more

Auto Trait Implementations

impl Unpin for Quat

impl Sync for Quat

impl Send for Quat

Blanket Implementations

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> Into<U> for T where
    U: From<T>, 
[src]

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

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.

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

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

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