Voxelyze
Public Member Functions | Public Attributes
Quat3D< T > Class Template Reference

A generic 3D quaternion template. More...

#include <Quat3D.h>

List of all members.

Public Member Functions

 Quat3D (void)
 Constructor. Initialzes w, x, y, z to zero.
 Quat3D (const T dw, const T dx, const T dy, const T dz)
 Constructor with specified individual values.
 Quat3D (const Quat3D &QuatIn)
 Copy constructor.
 Quat3D (const Vec3D< T > &VecIn)
 Constructs this quaternion from rotation vector VecIn. See FromRotationVector().
 Quat3D (const T angle, const Vec3D< T > &axis)
 Constructs this quaternion from an angle in radians and a unit axis.
 Quat3D (const Vec3D< T > &RotateFrom, const Vec3D< T > &RotateTo)
 Constructs this quaternion to represent the rotation from two vectors. The vectors need not be normalized and are not modified.
template<typename U >
 Quat3D (const Quat3D< U > &QuatIn)
 Copy constructor from another template type.
template<typename U >
 Quat3D (const Vec3D< U > &VecIn)
 Copies x, y, z from the specified vector and sets w to zero.
template<typename U >
 operator Quat3D< U > () const
 overload conversion operator for different template types
template<typename U >
Quat3D< T > operator= (const Quat3D< U > &s)
 Equals operator for different template types.
template<typename U >
const Quat3D< T > operator+ (const Quat3D< U > &s)
 Addition operator for different template types.
template<typename U >
const Quat3D< T > operator* (const U &f) const
 Scalar multiplication operator for different template types.
template<typename U >
const Quat3D< T > operator* (const Quat3D< U > &f) const
 Quaternion multplication operator for different template types.
Quat3Doperator= (const Quat3D &s)
 overload equals
const Quat3D operator+ (const Quat3D &s) const
 overload additoon
const Quat3D operator- (const Quat3D &s) const
 overload subtraction
const Quat3D operator* (const T f) const
 overload scalar multiplication
const Quat3D friend operator* (const T f, const Quat3D v)
 overload scalar multiplication with number first.
const Quat3D operator* (const Quat3D &f) const
 overload quaternion multiplication.
bool operator== (const Quat3D &s) const
 overload is equal.
bool operator!= (const Quat3D &s) const
 overload is not equal.
const Quat3Doperator+= (const Quat3D &s)
 overload add and set
const Quat3Doperator-= (const Quat3D &s)
 overload subtract and set
const Vec3D< T > ToVec () const
 Explicit casting to a vector. Throws away w and copies x, y, z directly.
const T Length () const
 Returns the length (magnitude) of the quaternion.
const T Length2 () const
 Returns the length (magnitude) squared of the quaternion.
const T Normalize ()
 Normalizes this quaternion. Returns the previous magnitude of this quaternion before normalization. Note: function changes this quaternion.
void NormalizeFast ()
 Normalizes this quaternion slightly faster than Normalize() by not returning a value. Note: function changes this quaternion.
const Quat3D Inverse () const
 Returns a quaternion that is the inverse of this quaternion. This quaternion is not modified.
const Quat3D Conjugate () const
 Returns a quaternion that is the conjugate of this quaternion. This quaternion is not modified.
const T Angle () const
 Returns the angular rotation of this quaternion in radians.
const T AngleDegrees () const
 Returns the angular rotation of this quaternion in degrees.
bool IsNegligibleAngle () const
 Returns true if the angular rotation of this quaternion is likely to be considered negligible.
bool IsSmallAngle () const
 Returns true if the angular rotation of this quaternion is small enough to be a good candidate for small angle approximations.
Vec3D< T > Axis () const
 Returns the normalized axis of rotation of this quaternion.
Vec3D< T > AxisUnNormalized () const
 Returns the un0normalized axis of rotation of this quaternion.
void AngleAxis (T &angle, Vec3D< T > &axis) const
 Returns the angle and a normalize axis that represent this quaternion's rotation.
void AngleAxisUnNormalized (T &angle, Vec3D< T > &axis) const
 Returns the angle and an un-normalized axis that represent this quaternion's rotation.
const Vec3D< T > ToRotationVector () const
 Returns a rotation vector representing this quaternion rotation. Adapted from http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/.
void FromRotationVector (const Vec3D< T > &VecIn)
 Overwrites this quaternion with values from the specified rotation vector. Adapted from http://physicsforgames.blogspot.com/2010/02/quaternions.html. Note: function changes this quaternion.
void FromAngleToPosX (const Vec3D< T > &RotateFrom)
 Overwrites this quaternion with the calculated rotation that would transform the specified RotateFrom vector to point in the positve X direction. Note: function changes this quaternion.
const Vec3D< T > RotateVec3D (const Vec3D< T > &f) const
 Returns a vector representing the specified vector "f" rotated by this quaternion.
template<typename U >
const Vec3D< U > RotateVec3D (const Vec3D< U > &f) const
 Returns a vector representing the specified vector "f" rotated by this quaternion. Mixed template parameter version.
const Vec3D< T > RotateVec3DInv (const Vec3D< T > &f) const
 Returns a vector representing the specified vector "f" rotated by the inverse of this quaternion. This is the opposite of RotateVec3D.
template<typename U >
const Vec3D< U > RotateVec3DInv (const Vec3D< U > &f) const
 Returns a vector representing the specified vector "f" rotated by the inverse of this quaternion. This is the opposite of RotateVec3D. Mixed template parameter version.

Public Attributes

w
 The current W value.
x
 The current X value.
y
 The current Y value.
z
 The current Z value.

Detailed Description

template<typename T = double>
class Quat3D< T >

A generic 3D quaternion template.

The template parameter is assumed to be either float or double depending on the desired numerical resolution.


Constructor & Destructor Documentation

template<typename T = double>
Quat3D< T >::Quat3D ( const Vec3D< T > &  VecIn) [inline]

Constructs this quaternion from rotation vector VecIn. See FromRotationVector().

Parameters:
[in]VecInA rotation vector.
template<typename T = double>
Quat3D< T >::Quat3D ( const T  angle,
const Vec3D< T > &  axis 
) [inline]

Constructs this quaternion from an angle in radians and a unit axis.

Parameters:
[in]angleAn angle in radians
[in]axisA normalize rotation axis.
template<typename T = double>
Quat3D< T >::Quat3D ( const Vec3D< T > &  RotateFrom,
const Vec3D< T > &  RotateTo 
) [inline]

Constructs this quaternion to represent the rotation from two vectors. The vectors need not be normalized and are not modified.

Parameters:
[in]RotateFromA vector representing a pre-rotation orientation.
[in]RotateToA vector representing a post-rotation orientation.

Member Function Documentation

template<typename T = double>
void Quat3D< T >::AngleAxis ( T &  angle,
Vec3D< T > &  axis 
) const [inline]

Returns the angle and a normalize axis that represent this quaternion's rotation.

Parameters:
[out]angleThe rotation angle in radians.
[out]axisThe rotation axis in normalized vector form.
template<typename T = double>
void Quat3D< T >::AngleAxisUnNormalized ( T &  angle,
Vec3D< T > &  axis 
) const [inline]

Returns the angle and an un-normalized axis that represent this quaternion's rotation.

Parameters:
[out]angleThe rotation angle in radians.
[out]axisThe rotation axis in un-normalized vector form.
template<typename T = double>
void Quat3D< T >::FromAngleToPosX ( const Vec3D< T > &  RotateFrom) [inline]

Overwrites this quaternion with the calculated rotation that would transform the specified RotateFrom vector to point in the positve X direction. Note: function changes this quaternion.

Parameters:
[in]RotateFromAn arbitrary direction vector. Does not need to be normalized.
template<typename T = double>
void Quat3D< T >::FromRotationVector ( const Vec3D< T > &  VecIn) [inline]

Overwrites this quaternion with values from the specified rotation vector. Adapted from http://physicsforgames.blogspot.com/2010/02/quaternions.html. Note: function changes this quaternion.

Parameters:
[in]VecInA rotation vector to calculate this quaternion from.
template<typename T = double>
const Vec3D<T> Quat3D< T >::RotateVec3D ( const Vec3D< T > &  f) const [inline]

Returns a vector representing the specified vector "f" rotated by this quaternion.

Parameters:
[in]fThe vector to transform.
template<typename T = double>
template<typename U >
const Vec3D<U> Quat3D< T >::RotateVec3D ( const Vec3D< U > &  f) const [inline]

Returns a vector representing the specified vector "f" rotated by this quaternion. Mixed template parameter version.

Parameters:
[in]fThe vector to transform.
template<typename T = double>
const Vec3D<T> Quat3D< T >::RotateVec3DInv ( const Vec3D< T > &  f) const [inline]

Returns a vector representing the specified vector "f" rotated by the inverse of this quaternion. This is the opposite of RotateVec3D.

Parameters:
[in]fThe vector to transform.
template<typename T = double>
template<typename U >
const Vec3D<U> Quat3D< T >::RotateVec3DInv ( const Vec3D< U > &  f) const [inline]

Returns a vector representing the specified vector "f" rotated by the inverse of this quaternion. This is the opposite of RotateVec3D. Mixed template parameter version.

Parameters:
[in]fThe vector to transform.

The documentation for this class was generated from the following file:
 All Classes Functions Variables Enumerations Enumerator Friends