Files Class List
UnitQuaternion< T > Class Template Reference

Detailed Description

template<typename T>
class cy::UnitQuaternion< T >

A unit-length quaternion class. The methods of this class guarantee that the quaternion remains unit length.

#include <cyQuaternion.h>

+ Inheritance diagram for UnitQuaternion< T >:

Public Member Functions

Constructors
 UnitQuaternion (T const &x, T const &y, T const &z, T const &_s)
 
 UnitQuaternion (Vec3< T > const &_v, T _s=0)
 
 UnitQuaternion (Vec4< T > const &q)
 
 UnitQuaternion (Quaternion< T > const &q)
 
 UnitQuaternion (Vec3< T > const &from, Vec3< T > const &to)
 
Set & Get value functions
void SetRotation (Vec3< T > const &axis, T angle)
 Sets a rotation around the given axis.
 
void SetRotation (Matrix3< T > const &rotation)
 Sets the quaternion using a rotation matrix. This method only works for rotation matrices.
 
void SetRotation (Vec3< T > const &from, Vec3< T > const &to)
 Sets the quaternion as a rotation from one direction to another. The resulting quaternion is not normalized.
 
void SetHalfRotation ()
 Reduces the rotation of the quaternion by half.
 
Vec3< T > const & GetVector () const
 Sets a rotation around the given axis.
 
T const & GetScalar () const
 Sets a rotation around the given axis.
 
GetRotationAngle () const
 Returns rotation angle in radians.
 
Conversion functions
Matrix3< T > GetMatrix3 () const
 Returns a matrix representing the rotation of the quaternion.
 
Matrix4< T > GetMatrix4 () const
 Returns a matrix representing the rotation of the quaternion.
 
 operator Matrix3< T > () const
 Returns a matrix representing the rotation of the quaternion.
 
 operator Matrix4< T > () const
 Returns a matrix representing the rotation of the quaternion.
 
 operator Quaternion< T > () const
 Returns a generic quaternion representation of the unit quaternion.
 
Unary and Binary operators
UnitQuaternion operator* (UnitQuaternion const &q) const
 Rotates the given vector using the quaternion. If multiple vectors will be rotated, converting the quaternion to a matrix would be more efficient.
 
Vec3< T > operator* (Vec3< T > const &p) const
 Rotates the given vector using the quaternion. If multiple vectors will be rotated, converting the quaternion to a matrix would be more efficient.
 
Matrix3< T > operator* (Matrix3< T > const &m) const
 Rotates the given vector using the quaternion. If multiple vectors will be rotated, converting the quaternion to a matrix would be more efficient.
 
Assignment operators
UnitQuaternionoperator*= (UnitQuaternion const &q)
 

Static Public Member Functions

Slerp (Spherical Linear Interpolation)
static UnitQuaternion< T > Slerp (UnitQuaternion< T > const &q0, UnitQuaternion< T > const &q1, T t)
 ! Interpolates two quaternions using parameter t in [0,1].
 
static UnitQuaternion< T > Slerp (UnitQuaternion< T > const &q0, UnitQuaternion< T > const &q1, UnitQuaternion< T > const &q2, Vec3< T > const &bary)
 ! Interpolates three quaternions using the given barycentric coordinates
 

Private Member Functions

Binary operators
Quaternion operator* (Quaternion const &q) const
 
Quaternion operator* (T const &f) const
 
Assignment operators
Quaternionoperator*= (Quaternion const &q)
 
Quaternionoperator*= (T const &f)
 

Friends

Quaternion< T > operator* (T const &f, const UnitQuaternion &q)
 
Matrix3< T > operator* (Matrix3< T > const &m, const UnitQuaternion &q)
 
UnitQuaternion Inverse (UnitQuaternion const &q)
 return the inverse of the quaternion