[][src]Struct cgmath::Quaternion

#[repr(C)]
pub struct Quaternion<S> {
    pub s: S,
    pub v: Vector3<S>,
}

A quaternion in scalar/vector form.

This type is marked as #[repr(C)].

Fields

s: S

The scalar part of the quaternion.

v: Vector3<S>

The vector part of the quaternion.

Methods

impl<S> Quaternion<S>[src]

pub const fn new(w: S, xi: S, yj: S, zk: S) -> Quaternion<S>[src]

Construct a new quaternion from one scalar component and three imaginary components.

pub const fn from_sv(s: S, v: Vector3<S>) -> Quaternion<S>[src]

Construct a new quaternion from a scalar and a vector.

impl<S: BaseFloat> Quaternion<S>[src]

pub fn from_arc(
    src: Vector3<S>,
    dst: Vector3<S>,
    fallback: Option<Vector3<S>>
) -> Quaternion<S>
[src]

Construct a new quaternion as a closest arc between two vectors

Return the closest rotation that turns src vector into dst.

  • [Related StackOverflow question] (http://stackoverflow.com/questions/1171849/finding-quaternion-representing-the-rotation-from-one-vector-to-another)
  • [Ogre implementation for normalized vectors] (https://bitbucket.org/sinbad/ogre/src/9db75e3ba05c/OgreMain/include/OgreVector3.h?fileviewer=file-view-default#cl-651)

pub fn conjugate(self) -> Quaternion<S>[src]

The conjugate of the quaternion.

pub fn nlerp(self, other: Quaternion<S>, amount: S) -> Quaternion<S>[src]

Do a normalized linear interpolation with other, by amount.

pub fn slerp(self, other: Quaternion<S>, amount: S) -> Quaternion<S>[src]

Spherical Linear Interpolation

Return the spherical linear interpolation between the quaternion and other. Both quaternions should be normalized first.

Performance notes

The acos operation used in slerp is an expensive operation, so unless your quaternions are far away from each other it's generally more advisable to use nlerp when you know your rotations are going to be small.

  • [Understanding Slerp, Then Not Using It] (http://number-none.com/product/Understanding%20Slerp,%20Then%20Not%20Using%20It/)
  • [Arcsynthesis OpenGL tutorial] (http://www.arcsynthesis.org/gltut/Positioning/Tut08%20Interpolation.html)

pub fn is_finite(&self) -> bool[src]

impl<S: NumCast + Copy> Quaternion<S>[src]

pub fn cast<T: BaseFloat>(&self) -> Option<Quaternion<T>>[src]

Component-wise casting to another type.

Trait Implementations

impl<S: BaseFloat> VectorSpace for Quaternion<S>[src]

type Scalar = S

The associated scalar.

impl<S: BaseFloat> MetricSpace for Quaternion<S>[src]

type Metric = S

The metric to be returned by the distance function.

impl<S: BaseFloat> InnerSpace for Quaternion<S>[src]

impl<S: BaseFloat> Rotation<Point3<S>> for Quaternion<S>[src]

impl<S: BaseFloat> Rotation3<S> for Quaternion<S>[src]

impl<S: BaseFloat> Into<[S; 4]> for Quaternion<S>[src]

impl<S: BaseFloat> Into<(S, S, S, S)> for Quaternion<S>[src]

impl<S: BaseFloat> AsMut<[S; 4]> for Quaternion<S>[src]

impl<S: BaseFloat> AsMut<(S, S, S, S)> for Quaternion<S>[src]

impl<S: Clone> Clone for Quaternion<S>[src]

impl<S: BaseFloat> AsRef<[S; 4]> for Quaternion<S>[src]

impl<S: BaseFloat> AsRef<(S, S, S, S)> for Quaternion<S>[src]

impl<S: PartialEq> PartialEq<Quaternion<S>> for Quaternion<S>[src]

impl<S: BaseFloat> From<Matrix3<S>> for Quaternion<S>[src]

fn from(mat: Matrix3<S>) -> Quaternion<S>[src]

Convert the matrix to a quaternion

impl<A> From<Euler<A>> for Quaternion<A::Unitless> where
    A: Angle + Into<Rad<<A as Angle>::Unitless>>, 
[src]

impl<S: BaseFloat> From<Quaternion<S>> for Matrix3<S>[src]

fn from(quat: Quaternion<S>) -> Matrix3<S>[src]

Convert the quaternion to a 3 x 3 rotation matrix.

impl<S: BaseFloat> From<Quaternion<S>> for Matrix4<S>[src]

fn from(quat: Quaternion<S>) -> Matrix4<S>[src]

Convert the quaternion to a 4 x 4 rotation matrix.

impl<S: BaseFloat> From<Quaternion<S>> for Basis3<S>[src]

impl<S: BaseFloat> From<[S; 4]> for Quaternion<S>[src]

impl<'a, S: BaseFloat> From<&'a [S; 4]> for &'a Quaternion<S>[src]

impl<'a, S: BaseFloat> From<&'a mut [S; 4]> for &'a mut Quaternion<S>[src]

impl<S: BaseFloat> From<(S, S, S, S)> for Quaternion<S>[src]

impl<'a, S: BaseFloat> From<&'a (S, S, S, S)> for &'a Quaternion<S>[src]

impl<'a, S: BaseFloat> From<&'a mut (S, S, S, S)> for &'a mut Quaternion<S>[src]

impl<S: BaseFloat> From<Quaternion<S>> for Euler<Rad<S>>[src]

impl<S: BaseFloat> From<Basis3<S>> for Quaternion<S>[src]

impl<S: Copy> Copy for Quaternion<S>[src]

impl<S: BaseFloat> Add<Quaternion<S>> for Quaternion<S>[src]

type Output = Quaternion<S>

The resulting type after applying the + operator.

impl<'a, S: BaseFloat> Add<&'a Quaternion<S>> for Quaternion<S>[src]

type Output = Quaternion<S>

The resulting type after applying the + operator.

impl<'a, S: BaseFloat> Add<Quaternion<S>> for &'a Quaternion<S>[src]

type Output = Quaternion<S>

The resulting type after applying the + operator.

impl<'a, 'b, S: BaseFloat> Add<&'a Quaternion<S>> for &'b Quaternion<S>[src]

type Output = Quaternion<S>

The resulting type after applying the + operator.

impl<S: BaseFloat> Sub<Quaternion<S>> for Quaternion<S>[src]

type Output = Quaternion<S>

The resulting type after applying the - operator.

impl<'a, S: BaseFloat> Sub<&'a Quaternion<S>> for Quaternion<S>[src]

type Output = Quaternion<S>

The resulting type after applying the - operator.

impl<'a, S: BaseFloat> Sub<Quaternion<S>> for &'a Quaternion<S>[src]

type Output = Quaternion<S>

The resulting type after applying the - operator.

impl<'a, 'b, S: BaseFloat> Sub<&'a Quaternion<S>> for &'b Quaternion<S>[src]

type Output = Quaternion<S>

The resulting type after applying the - operator.

impl<S: BaseFloat> Mul<S> for Quaternion<S>[src]

type Output = Quaternion<S>

The resulting type after applying the * operator.

impl<'a, S: BaseFloat> Mul<S> for &'a Quaternion<S>[src]

type Output = Quaternion<S>

The resulting type after applying the * operator.

impl<S: BaseFloat> Mul<Vector3<S>> for Quaternion<S>[src]

type Output = Vector3<S>

The resulting type after applying the * operator.

impl<'a, S: BaseFloat> Mul<&'a Vector3<S>> for Quaternion<S>[src]

type Output = Vector3<S>

The resulting type after applying the * operator.

impl<'a, S: BaseFloat> Mul<Vector3<S>> for &'a Quaternion<S>[src]

type Output = Vector3<S>

The resulting type after applying the * operator.

impl<'a, 'b, S: BaseFloat> Mul<&'a Vector3<S>> for &'b Quaternion<S>[src]

type Output = Vector3<S>

The resulting type after applying the * operator.

impl<S: BaseFloat> Mul<Quaternion<S>> for Quaternion<S>[src]

type Output = Quaternion<S>

The resulting type after applying the * operator.

impl<'a, S: BaseFloat> Mul<&'a Quaternion<S>> for Quaternion<S>[src]

type Output = Quaternion<S>

The resulting type after applying the * operator.

impl<'a, S: BaseFloat> Mul<Quaternion<S>> for &'a Quaternion<S>[src]

type Output = Quaternion<S>

The resulting type after applying the * operator.

impl<'a, 'b, S: BaseFloat> Mul<&'a Quaternion<S>> for &'b Quaternion<S>[src]

type Output = Quaternion<S>

The resulting type after applying the * operator.

impl Mul<Quaternion<f32>> for f32[src]

type Output = Quaternion<f32>

The resulting type after applying the * operator.

impl<'a> Mul<&'a Quaternion<f32>> for f32[src]

type Output = Quaternion<f32>

The resulting type after applying the * operator.

impl Mul<Quaternion<f64>> for f64[src]

type Output = Quaternion<f64>

The resulting type after applying the * operator.

impl<'a> Mul<&'a Quaternion<f64>> for f64[src]

type Output = Quaternion<f64>

The resulting type after applying the * operator.

impl<S: BaseFloat> Div<S> for Quaternion<S>[src]

type Output = Quaternion<S>

The resulting type after applying the / operator.

impl<'a, S: BaseFloat> Div<S> for &'a Quaternion<S>[src]

type Output = Quaternion<S>

The resulting type after applying the / operator.

impl Div<Quaternion<f32>> for f32[src]

type Output = Quaternion<f32>

The resulting type after applying the / operator.

impl<'a> Div<&'a Quaternion<f32>> for f32[src]

type Output = Quaternion<f32>

The resulting type after applying the / operator.

impl Div<Quaternion<f64>> for f64[src]

type Output = Quaternion<f64>

The resulting type after applying the / operator.

impl<'a> Div<&'a Quaternion<f64>> for f64[src]

type Output = Quaternion<f64>

The resulting type after applying the / operator.

impl<S: BaseFloat> Rem<S> for Quaternion<S>[src]

type Output = Quaternion<S>

The resulting type after applying the % operator.

impl<'a, S: BaseFloat> Rem<S> for &'a Quaternion<S>[src]

type Output = Quaternion<S>

The resulting type after applying the % operator.

impl<S: BaseFloat> Neg for Quaternion<S>[src]

type Output = Quaternion<S>

The resulting type after applying the - operator.

impl<'a, S: BaseFloat> Neg for &'a Quaternion<S>[src]

type Output = Quaternion<S>

The resulting type after applying the - operator.

impl<S: BaseFloat + AddAssign<S>> AddAssign<Quaternion<S>> for Quaternion<S>[src]

impl<S: BaseFloat + SubAssign<S>> SubAssign<Quaternion<S>> for Quaternion<S>[src]

impl<S: BaseFloat + MulAssign<S>> MulAssign<S> for Quaternion<S>[src]

impl<S: BaseFloat + DivAssign<S>> DivAssign<S> for Quaternion<S>[src]

impl<S: BaseFloat + RemAssign<S>> RemAssign<S> for Quaternion<S>[src]

impl<S: BaseFloat> Index<usize> for Quaternion<S>[src]

type Output = S

The returned type after indexing.

impl<S: BaseFloat> Index<Range<usize>> for Quaternion<S>[src]

type Output = [S]

The returned type after indexing.

impl<S: BaseFloat> Index<RangeTo<usize>> for Quaternion<S>[src]

type Output = [S]

The returned type after indexing.

impl<S: BaseFloat> Index<RangeFrom<usize>> for Quaternion<S>[src]

type Output = [S]

The returned type after indexing.

impl<S: BaseFloat> Index<RangeFull> for Quaternion<S>[src]

type Output = [S]

The returned type after indexing.

impl<S: BaseFloat> IndexMut<usize> for Quaternion<S>[src]

impl<S: BaseFloat> IndexMut<Range<usize>> for Quaternion<S>[src]

impl<S: BaseFloat> IndexMut<RangeTo<usize>> for Quaternion<S>[src]

impl<S: BaseFloat> IndexMut<RangeFrom<usize>> for Quaternion<S>[src]

impl<S: BaseFloat> IndexMut<RangeFull> for Quaternion<S>[src]

impl<S: Debug> Debug for Quaternion<S>[src]

impl<S: BaseFloat> Product<Quaternion<S>> for Quaternion<S>[src]

impl<'a, S: 'a + BaseFloat> Product<&'a Quaternion<S>> for Quaternion<S>[src]

impl<S: BaseFloat> Sum<Quaternion<S>> for Quaternion<S>[src]

impl<'a, S: 'a + BaseFloat> Sum<&'a Quaternion<S>> for Quaternion<S>[src]

impl<S: BaseFloat> AbsDiffEq<Quaternion<S>> for Quaternion<S>[src]

type Epsilon = S::Epsilon

Used for specifying relative comparisons.

impl<S: BaseFloat> RelativeEq<Quaternion<S>> for Quaternion<S>[src]

impl<S: BaseFloat> UlpsEq<Quaternion<S>> for Quaternion<S>[src]

impl<S: BaseFloat> Zero for Quaternion<S>[src]

impl<S: BaseFloat> One for Quaternion<S>[src]

impl<S> Distribution<Quaternion<S>> for Standard where
    Standard: Distribution<S>,
    Standard: Distribution<Vector3<S>>,
    S: BaseFloat
[src]

Auto Trait Implementations

impl<S> Send for Quaternion<S> where
    S: Send

impl<S> Unpin for Quaternion<S> where
    S: Unpin

impl<S> Sync for Quaternion<S> where
    S: Sync

impl<S> UnwindSafe for Quaternion<S> where
    S: UnwindSafe

impl<S> RefUnwindSafe for Quaternion<S> where
    S: RefUnwindSafe

Blanket Implementations

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

type Owned = T

The resulting type after obtaining ownership.

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

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

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.

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

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

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

impl<T, Rhs, Output> NumOps<Rhs, Output> for T where
    T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>, 
[src]

impl<T, Rhs> NumAssignOps<Rhs> for T where
    T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>, 
[src]