All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Nimble::QuaternionT< T > Class Template Reference

A quaternion class. More...

#include <Nimble/Quaternion.hpp>

Public Types

typedef T type
 The quaternion type.
 

Public Member Functions

dotp (const QuaternionT &v) const
 Returns dot product between this quaternion and the argument quaternion.
 
void getAngleAxis (float &angle, Vector3T< T > &axis) const
 Converts this quaternion to angle/axis format.
 
void identity ()
 
lensq () const
 The squared length of this quaternion. More...
 
QuaternionTnormalize ()
 Normalizes the quaternion to length 1. More...
 
 operator Nimble::Matrix3T< T > () const
 Converts this quaternion into a 3x3 rotation matrix.
 
 operator Nimble::Matrix4T< T > () const
 Converts this quaternion into a 4x4 matrix. More...
 
template<typename Y >
Vector3T< Y > operator* (const Vector3T< Y > &v) const
 Transforms the argument vector this quaternion transformation.
 
QuaternionT operator* (const QuaternionT &b) const
 Multiplies two quaterions.
 
QuaternionToperator*= (T v)
 Multiply the quaternion components. More...
 
QuaternionToperator*= (const QuaternionT &v)
 Multiply this quaternion with another, and store the result into this quaternion.
 
QuaternionT operator+ (const QuaternionT &v) const
 Addition operator.
 
QuaternionToperator+= (const QuaternionT &v)
 Accumulation add operator.
 
QuaternionT operator- (const QuaternionT &v) const
 Subtraction operator.
 
const QuaternionT operator- () const
 Negate a quaternion. More...
 
QuaternionToperator-= (const QuaternionT &v)
 Accumulation minus operator.
 
QuaternionToperator= (const Matrix4T< T > &m)
 Extracts the rotation part of a 4x4 matrix, and calculates the quaternion values from that.
 
QuaternionToperator= (const Matrix3T< T > &m)
 Calculates quaternion values from a 3x3 rotation matrix. More...
 
QuaternionToperator^= (const QuaternionT &v)
 Multiply the components of this quaternion directly with the components of another quaternion.
 
const QuaternionT operator~ () const
 Negate the x, y, and z value of this quaternion. More...
 
 QuaternionT ()
 Constructs a quaternion object, with uninitialized values.
 
 QuaternionT (const QuaternionT< T > &o)
 Constructs a quaternion object, with values copied from another quaternion object. More...
 
 QuaternionT (const Vector3T< T > &v, T w_)
 Constructs a quaternion object, with values copied from a 3D vector and a float. More...
 
 QuaternionT (T x_, T y_, T z_, T w_)
 Constructs a quaternion with given values.
 
 QuaternionT (const Matrix3T< T > &m)
 Converts a rotation matrix to quaternion format.
 

Static Public Member Functions

static QuaternionT rotation (T angle, Vector3T< T > axis)
 Create a new quaternion based on rotation around an axis. More...
 
static QuaternionT slerp (const QuaternionT &q1, QuaternionT q2, T t)
 Performs slerp interpolation between two quaternions.
 

Public Attributes

w
 The quaternion w element value.
 
x
 The quaternion x element value.
 
y
 The quaternion y element value.
 
z
 The quaternion z element value.
 

Static Public Attributes

static const QuaternionT< T > IDENTITY
 

Detailed Description

template<typename T>
class Nimble::QuaternionT< T >

A quaternion class.

Quaternion are typically used to present 3D rotations in a way that can be easily interpolated, and which is not susceptible to the artifacts that plague the "pitch/roll/yaw" definition.

Constructor & Destructor Documentation

template<typename T >
Nimble::QuaternionT< T >::QuaternionT ( const QuaternionT< T > &  o)
inline

Constructs a quaternion object, with values copied from another quaternion object.

Parameters
oThe quaternion to copy
template<typename T >
Nimble::QuaternionT< T >::QuaternionT ( const Vector3T< T > &  v,
w_ 
)
inline

Constructs a quaternion object, with values copied from a 3D vector and a float.

Parameters
vThe 3D vector that defines the x, y, z value for this uaternion
w_The w value

Member Function Documentation

template<typename T >
T Nimble::QuaternionT< T >::lensq ( ) const
inline

The squared length of this quaternion.

Returns
x*x+y*y+z*z+w*w
template<typename T >
QuaternionT& Nimble::QuaternionT< T >::normalize ( )
inline

Normalizes the quaternion to length 1.

Returns
Reference to self
template<typename T >
Nimble::QuaternionT< T >::operator Nimble::Matrix4T< T > ( ) const
inline

Converts this quaternion into a 4x4 matrix.

Returns
The top-left 3x3 components of the matrix are set to a rotation matrix. The remaining components are from an identity matrix.
template<typename T >
QuaternionT& Nimble::QuaternionT< T >::operator*= ( v)
inline

Multiply the quaternion components.

Parameters
vThe multiplier
Returns
Reference to self
template<typename T >
const QuaternionT Nimble::QuaternionT< T >::operator- ( ) const
inline

Negate a quaternion.

Returns
Returns the values of this quaternion, multiplied with -1
template<typename T >
QuaternionT& Nimble::QuaternionT< T >::operator= ( const Matrix3T< T > &  m)
inline

Calculates quaternion values from a 3x3 rotation matrix.

Parameters
mThe matrix to be copied.
template<typename T >
const QuaternionT Nimble::QuaternionT< T >::operator~ ( ) const
inline

Negate the x, y, and z value of this quaternion.

Returns
Returns the x, y, z, values of this quaternion, multiplied with -1, and the w value as such.
template<typename T >
static QuaternionT Nimble::QuaternionT< T >::rotation ( angle,
Vector3T< T >  axis 
)
inlinestatic

Create a new quaternion based on rotation around an axis.

Parameters
angleThe rotation angle, in radians
axisThe axis, around which the rotation is performed
Returns
New quaternion