HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImathQuat.h File Reference
#include "ImathExport.h"
#include "ImathNamespace.h"
#include "ImathMatrix.h"
#include <iostream>
+ Include dependency graph for ImathQuat.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Quat< T >
 

Typedefs

typedef Quat< floatQuatf
 Quaternion of type float. More...
 
typedef Quat< double > Quatd
 Quaternion of type double. More...
 

Functions

template<class T >
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 Quat< T > 
slerp (const Quat< T > &q1, const Quat< T > &q2, T t) IMATH_NOEXCEPT
 
template<class T >
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 Quat< T > 
slerpShortestArc (const Quat< T > &q1, const Quat< T > &q2, T t) IMATH_NOEXCEPT
 
template<class T >
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 Quat< T > 
squad (const Quat< T > &q1, const Quat< T > &q2, const Quat< T > &qa, const Quat< T > &qb, T t) IMATH_NOEXCEPT
 
template<class T >
IMATH_HOSTDEVICE void intermediate (const Quat< T > &q0, const Quat< T > &q1, const Quat< T > &q2, const Quat< T > &q3, Quat< T > &qa, Quat< T > &qb) IMATH_NOEXCEPT
 
template<class T >
IMATH_HOSTDEVICE constexpr
Matrix33< T > 
operator* (const Matrix33< T > &M, const Quat< T > &q) IMATH_NOEXCEPT
 
template<class T >
IMATH_HOSTDEVICE constexpr
Matrix33< T > 
operator* (const Quat< T > &q, const Matrix33< T > &M) IMATH_NOEXCEPT
 
template<class T >
std::ostream & operator<< (std::ostream &o, const Quat< T > &q)
 Stream output as "(r x y z)". More...
 
template<class T >
IMATH_HOSTDEVICE constexpr
Quat< T > 
operator* (const Quat< T > &q1, const Quat< T > &q2) IMATH_NOEXCEPT
 Quaterion multiplication. More...
 
template<class T >
IMATH_HOSTDEVICE constexpr
Quat< T > 
operator/ (const Quat< T > &q1, const Quat< T > &q2) IMATH_NOEXCEPT
 Quaterion division. More...
 
template<class T >
IMATH_HOSTDEVICE constexpr
Quat< T > 
operator/ (const Quat< T > &q, T t) IMATH_NOEXCEPT
 Quaterion division. More...
 
template<class T >
IMATH_HOSTDEVICE constexpr
Quat< T > 
operator* (const Quat< T > &q, T t) IMATH_NOEXCEPT
 
template<class T >
IMATH_HOSTDEVICE constexpr
Quat< T > 
operator* (T t, const Quat< T > &q) IMATH_NOEXCEPT
 
template<class T >
IMATH_HOSTDEVICE constexpr
Quat< T > 
operator+ (const Quat< T > &q1, const Quat< T > &q2) IMATH_NOEXCEPT
 Quaterion addition. More...
 
template<class T >
IMATH_HOSTDEVICE constexpr
Quat< T > 
operator- (const Quat< T > &q1, const Quat< T > &q2) IMATH_NOEXCEPT
 Quaterion subtraction. More...
 
template<class T >
IMATH_HOSTDEVICE constexpr
Quat< T > 
operator~ (const Quat< T > &q) IMATH_NOEXCEPT
 Compute the conjugate. More...
 
template<class T >
IMATH_HOSTDEVICE constexpr
Quat< T > 
operator- (const Quat< T > &q) IMATH_NOEXCEPT
 Negate the quaterion. More...
 
template<class T >
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 Vec3< T > 
operator* (const Vec3< T > &v, const Quat< T > &q) IMATH_NOEXCEPT
 
template<class T >
IMATH_HOSTDEVICE constexpr T operator^ (const Quat< T > &q1, const Quat< T > &q2) IMATH_NOEXCEPT
 4D dot product More...
 
template<class T >
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 T 
angle4D (const Quat< T > &q1, const Quat< T > &q2) IMATH_NOEXCEPT
 
template<class T >
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 Quat< T > 
spline (const Quat< T > &q0, const Quat< T > &q1, const Quat< T > &q2, const Quat< T > &q3, T t) IMATH_NOEXCEPT
 
template<class T >
IMATH_HOSTDEVICE
IMATH_CONSTEXPR14 Quat< T > 
intermediate (const Quat< T > &q0, const Quat< T > &q1, const Quat< T > &q2) IMATH_NOEXCEPT
 

Typedef Documentation

typedef Quat<double> Quatd

Quaternion of type double.

Definition at line 265 of file ImathQuat.h.

typedef Quat<float> Quatf

Quaternion of type float.

Definition at line 262 of file ImathQuat.h.

Function Documentation

template<class T >
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 T angle4D ( const Quat< T > &  q1,
const Quat< T > &  q2 
)
inline

Compute the angle between two quaternions, interpreting the quaternions as 4D vectors.

Definition at line 501 of file ImathQuat.h.

template<class T >
IMATH_HOSTDEVICE void intermediate ( const Quat< T > &  q0,
const Quat< T > &  q1,
const Quat< T > &  q2,
const Quat< T > &  q3,
Quat< T > &  qa,
Quat< T > &  qb 
)

From advanced Animation and Rendering Techniques by Watt and Watt, Page 366:

computing the inner quadrangle points (qa and qb) to guarantee tangent continuity.

template<class T >
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Quat<T> intermediate ( const Quat< T > &  q0,
const Quat< T > &  q1,
const Quat< T > &  q2 
)
inline

Compute the intermediate point between three quaternions q0, q1, and q2.

Definition at line 607 of file ImathQuat.h.

template<class T >
IMATH_HOSTDEVICE constexpr Matrix33< T > operator* ( const Matrix33< T > &  M,
const Quat< T > &  q 
)
inline

Transform the quaternion by the matrix

Returns
M * q

Definition at line 838 of file ImathQuat.h.

template<class T >
IMATH_HOSTDEVICE constexpr Matrix33< T > operator* ( const Quat< T > &  q,
const Matrix33< T > &  M 
)
inline

Transform the matrix by the quaterion:

Returns
q * M

Definition at line 847 of file ImathQuat.h.

template<class T >
IMATH_HOSTDEVICE constexpr Quat< T > operator* ( const Quat< T > &  q1,
const Quat< T > &  q2 
)
inline

Quaterion multiplication.

Definition at line 863 of file ImathQuat.h.

template<class T >
IMATH_HOSTDEVICE constexpr Quat< T > operator* ( const Quat< T > &  q,
t 
)
inline

Quaterion*scalar multiplication

Returns
q * t

Definition at line 888 of file ImathQuat.h.

template<class T >
IMATH_HOSTDEVICE constexpr Quat< T > operator* ( t,
const Quat< T > &  q 
)
inline

Quaterion*scalar multiplication

Returns
q * t

Definition at line 897 of file ImathQuat.h.

template<class T >
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Vec3< T > operator* ( const Vec3< T > &  v,
const Quat< T > &  q 
)
inline

Quaterion*vector multiplcation

Returns
v * q

Definition at line 938 of file ImathQuat.h.

template<class T >
IMATH_HOSTDEVICE constexpr Quat< T > operator+ ( const Quat< T > &  q1,
const Quat< T > &  q2 
)
inline

Quaterion addition.

Definition at line 905 of file ImathQuat.h.

template<class T >
IMATH_HOSTDEVICE constexpr Quat< T > operator- ( const Quat< T > &  q1,
const Quat< T > &  q2 
)
inline

Quaterion subtraction.

Definition at line 913 of file ImathQuat.h.

template<class T >
IMATH_HOSTDEVICE constexpr Quat< T > operator- ( const Quat< T > &  q)
inline

Negate the quaterion.

Definition at line 929 of file ImathQuat.h.

template<class T >
IMATH_HOSTDEVICE constexpr Quat< T > operator/ ( const Quat< T > &  q1,
const Quat< T > &  q2 
)
inline

Quaterion division.

Definition at line 871 of file ImathQuat.h.

template<class T >
IMATH_HOSTDEVICE constexpr Quat< T > operator/ ( const Quat< T > &  q,
t 
)
inline

Quaterion division.

Definition at line 879 of file ImathQuat.h.

template<class T >
std::ostream & operator<< ( std::ostream &  o,
const Quat< T > &  q 
)

Stream output as "(r x y z)".

Definition at line 855 of file ImathQuat.h.

template<class T >
IMATH_HOSTDEVICE constexpr T operator^ ( const Quat< T > &  q1,
const Quat< T > &  q2 
)
inline

4D dot product

Definition at line 405 of file ImathQuat.h.

template<class T >
IMATH_HOSTDEVICE constexpr Quat< T > operator~ ( const Quat< T > &  q)
inline

Compute the conjugate.

Definition at line 921 of file ImathQuat.h.

template<class T >
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Quat< T > slerp ( const Quat< T > &  q1,
const Quat< T > &  q2,
t 
)
inline

Spherical linear interpolation. Assumes q1 and q2 are normalized and that q1 != -q2.

This method does not interpolate along the shortest arc between q1 and q2. If you desire interpolation along the shortest arc, and q1^q2 is negative, then consider calling slerpShortestArc(), below, or flipping the second quaternion explicitly.

The implementation of squad() depends on a slerp() that interpolates as is, without the automatic flipping.

Don Hatch explains the method we use here on his web page, The Right Way to Calculate Stuff, at http://www.plunk.org/~hatch/rightway.php

Definition at line 531 of file ImathQuat.h.

template<class T >
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Quat< T > slerpShortestArc ( const Quat< T > &  q1,
const Quat< T > &  q2,
t 
)
inline

Spherical linear interpolation along the shortest arc from q1 to either q2 or -q2, whichever is closer. Assumes q1 and q2 are unit quaternions.

Definition at line 548 of file ImathQuat.h.

template<class T >
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Quat<T> spline ( const Quat< T > &  q0,
const Quat< T > &  q1,
const Quat< T > &  q2,
const Quat< T > &  q3,
t 
)
inline

Spherical Cubic Spline Interpolation - from Advanced Animation and Rendering Techniques by Watt and Watt, Page 366:

A spherical curve is constructed using three spherical linear interpolations of a quadrangle of unit quaternions: q1, qa, qb, q2. Given a set of quaternion keys: q0, q1, q2, q3, this routine does the interpolation between q1 and q2 by constructing two intermediate quaternions: qa and qb. The qa and qb are computed by the intermediate function to guarantee the continuity of tangents across adjacent cubic segments. The qa represents in-tangent for q1 and the qb represents the out-tangent for q2.

The q1 q2 is the cubic segment being interpolated.

The q0 is from the previous adjacent segment and q3 is from the next adjacent segment. The q0 and q3 are used in computing qa and qb.

Definition at line 576 of file ImathQuat.h.

template<class T >
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Quat< T > squad ( const Quat< T > &  q1,
const Quat< T > &  qa,
const Quat< T > &  qb,
const Quat< T > &  q2,
t 
)
inline

Spherical Quadrangle Interpolation - from Advanced Animation and Rendering Techniques by Watt and Watt, Page 366:

It constructs a spherical cubic interpolation as a series of three spherical linear interpolations of a quadrangle of unit quaternions.

Definition at line 594 of file ImathQuat.h.