[][src]Struct nannou::math::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> where
    S: BaseFloat
[src]

pub 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 fn from_sv(s: S, v: Vector3<S>) -> Quaternion<S>[src]

Construct a new quaternion from a scalar and a vector.

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)

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

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

Component-wise casting to another type.

Trait Implementations

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

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

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

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

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

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

impl<S> Serialize for Quaternion<S> where
    S: Serialize
[src]

impl<'de, S> Deserialize<'de> for Quaternion<S> where
    S: Deserialize<'de>, 
[src]

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

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

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

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

type Output = Quaternion<S>

The resulting type after applying the % operator.

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

type Output = Quaternion<S>

The resulting type after applying the % operator.

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

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

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

type Output = Quaternion<S>

The resulting type after applying the + operator.

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

type Output = Quaternion<S>

The resulting type after applying the + operator.

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

type Output = Quaternion<S>

The resulting type after applying the + operator.

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

type Output = Quaternion<S>

The resulting type after applying the + operator.

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

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

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

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

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

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

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

type Metric = S

The metric to be returned by the distance function.

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

type Output = Quaternion<S>

The resulting type after applying the - operator.

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

type Output = Quaternion<S>

The resulting type after applying the - operator.

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

type Output = Quaternion<S>

The resulting type after applying the - operator.

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

type Output = Quaternion<S>

The resulting type after applying the - operator.

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

type Output = Quaternion<S>

The resulting type after applying the * operator.

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

type Output = Vector3<S>

The resulting type after applying the * operator.

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

type Output = Quaternion<S>

The resulting type after applying the * operator.

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

type Output = Quaternion<S>

The resulting type after applying the * operator.

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

type Output = Quaternion<S>

The resulting type after applying the * operator.

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

type Output = Quaternion<S>

The resulting type after applying the * operator.

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

type Output = Vector3<S>

The resulting type after applying the * operator.

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

type Output = Vector3<S>

The resulting type after applying the * operator.

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

type Output = Quaternion<S>

The resulting type after applying the * operator.

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

type Output = Vector3<S>

The resulting type after applying the * operator.

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

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

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

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

type Output = Quaternion<S>

The resulting type after applying the - operator.

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

type Output = Quaternion<S>

The resulting type after applying the - operator.

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

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

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

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

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

impl<S> ApproxEq for Quaternion<S> where
    S: BaseFloat
[src]

type Epsilon = <S as ApproxEq>::Epsilon

Used for specifying relative comparisons.

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

type Output = [S]

The returned type after indexing.

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

type Output = [S]

The returned type after indexing.

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

type Output = [S]

The returned type after indexing.

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

type Output = [S]

The returned type after indexing.

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

type Output = S

The returned type after indexing.

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

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

type Output = Quaternion<S>

The resulting type after applying the / operator.

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

type Output = Quaternion<S>

The resulting type after applying the / operator.

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

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

type Scalar = S

The associated scalar.

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

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

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

Convert the matrix to a quaternion

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

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

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

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

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

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

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

Convert the quaternion to a 3 x 3 rotation matrix.

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

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

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

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

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

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

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

Convert the quaternion to a 4 x 4 rotation matrix.

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

impl<S> AsMut<[S; 4]> for Quaternion<S> where
    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> NumAssignOps<Rhs> for T where
    T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>, 
[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> Style for T where
    T: Any + Debug + PartialEq<T>, 
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> Content for T[src]

impl<T> Zero for T where
    T: Zero

impl<T> One for T where
    T: One

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

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S where
    D: AdaptFrom<S, Swp, Dwp, T>,
    Dwp: WhitePoint,
    Swp: WhitePoint,
    T: Component + Float
[src]

impl<T> SetParameter for T

impl<T> SetParameter for T

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,