class RED::Quaternion
Quaternion for graphical operations. More...
#include <REDQuaternion.h>
Inherits: Object.
Public functions:
Quaternion ( const double data[4] ) | |
Quaternion ( ) | |
Quaternion ( double iX, double iY, double iZ, double iW ) | |
Quaternion ( const float data[4] ) | |
virtual | ~Quaternion ( ) |
virtual void * | As ( const RED::CID & iCID ) |
virtual const void * | As ( const RED::CID & iCID ) const |
template< class T_As > const T_As * | As ( ) const |
template< class T_As > T_As * | As ( ) |
void | Conjugate ( ) |
double | Dot ( const RED::Quaternion & iQ ) const |
void | Exp ( const RED::Vector3 & iValue ) |
void | GetAxisAngle ( RED::Vector3 & oAxis, double & oAngle ) const |
double | GetLength ( ) const |
double | GetLength2 ( ) const |
void | GetRotationMatrix ( RED::Matrix & oRotationMatrix ) const |
void | InnerQuadrangle ( const RED::Quaternion & iQuatBefore, const RED::Quaternion & iQuat, const RED::Quaternion & iQuatAfter ) |
void | Invert ( ) |
void | Log ( RED::Vector3 & oLog ) const |
double | Normalize ( ) |
bool | operator!= ( const RED::Quaternion & iOther ) const |
RED::Quaternion | operator* ( double iScalar ) const |
RED::Quaternion | operator* ( const RED::Quaternion & iRight ) const |
void | operator*= ( double iScalar ) |
void | operator*= ( const RED::Quaternion & iRight ) |
RED::Quaternion | operator+ ( const RED::Quaternion & iSource ) const |
void | operator+= ( const RED::Quaternion & iSource ) |
RED::Quaternion | operator- ( const RED::Quaternion & iRight ) const |
RED::Quaternion | operator- ( ) const |
void | operator-= ( const RED::Quaternion & iSource ) |
RED::Quaternion | operator/ ( double iScalar ) const |
void | operator/= ( double iScalar ) |
bool | operator== ( const RED::Quaternion & iOther ) const |
double | operator[] ( unsigned int iIndex ) const |
double & | operator[] ( unsigned int iIndex ) |
void | Set ( double iX, double iY, double iZ, double iW ) |
void | SetAxisAngle ( const RED::Vector3 & iAxis, double iAngle ) |
void | SetRotationMatrix ( const RED::Matrix & iRotationMatrix ) |
void | Slerp ( const RED::Quaternion & iQuatFrom, const RED::Quaternion & iQuatTo, double iWeight ) |
void | Squad ( const RED::Quaternion & iQuatFrom, const RED::Quaternion & iQuatTo, const RED::Quaternion & iInnerQuadrangleFrom, const RED::Quaternion & iInnerQuadrangleTo, double iWeight ) |
double | W ( ) const |
double | X ( ) const |
double | Y ( ) const |
double | Z ( ) const |
Public static functions:
static RED::CID | GetClassID ( ) |
Public variables:
double | _w |
double | _x |
double | _y |
double | _z |
Public static variables:
static const RED::Quaternion | IDENTITY |
static const RED::Quaternion | ZERO |
Detailed description:
Quaternion for graphical operations.
The quaternion is of the form q = x*i + y*j + z*k + w.
Functions documentation
public RED::Quaternion::Quaternion | ( | const double | data[4] | ) |
construction for a four double array.
Parameters:
data: | array containing the four double precision floating-point vector values. |
public RED::Quaternion::Quaternion | ( | ) |
Quaternion construction method.
Builds a unit quaternion ( 0, 0, 0, 1 ).
public RED::Quaternion::Quaternion | ( | double | iX, |
double | iY, | ||
double | iZ, | ||
double | iW | ||
) |
Constructor.
Parameters:
iX: | X dimension of the quaternion. |
iY: | Y dimension of the quaternion. |
iZ: | Z dimension of the quaternion. |
iW: | W dimension of the quaternion. |
public RED::Quaternion::Quaternion | ( | const float | data[4] | ) |
construction for a four floats array.
Parameters:
data: | array containing the four floating-point vector values. |
public virtual RED::Quaternion::~Quaternion | ( | ) |
Destructor.
public static RED::CID RED::Quaternion::GetClassID | ( | ) |
Reimplements: RED::Object::GetClassID.
public virtual void * RED::Quaternion::As | ( | const RED::CID & | iCID | ) |
Converts the object to an instance of the given type.
Parameters:
iCID: | Requested class. |
Returns:
Reimplements: RED::Object::As.
public virtual const void * RED::Quaternion::As | ( | const RED::CID & | iCID | ) const |
Converts the object to an instance of the given type.
Parameters:
iCID: | Requested class. |
Returns:
Reimplements: RED::Object::As.
template< class T_As > public const T_As * RED::Quaternion::As | ( | ) const |
Template version of the as const method.
Simply set T to be the class you want to retrieve an interface to.
Returns:
Reimplements: RED::Object::As.
template< class T_As > public T_As * RED::Quaternion::As | ( | ) |
Template version of the as method.
Simply set T to be the class you want to retrieve an interface to.
Returns:
Reimplements: RED::Object::As.
public void RED::Quaternion::Conjugate | ( | ) |
'In-place' conjugate of 'this'.
Computes the conjugate of this, replacing the previous quaternion contents.
public double RED::Quaternion::Dot | ( | const RED::Quaternion & | iQ | ) const |
Dot product of two quaternions.
Parameters:
iQ: | Right operand of the dot product. |
Returns:
public void RED::Quaternion::Exp | ( | const RED::Vector3 & | iValue | ) |
Exponential quaternion function.
Parameters:
iValue: | Value to compute the exponential. |
public void RED::Quaternion::GetAxisAngle | ( | RED::Vector3 & | oAxis, |
double & | oAngle | ||
) | const |
Gets the axis angle rotation from this quaternion.
Parameters:
oAxis: | Returned rotation axis. |
oAngle: | Returned rotation angle. |
public double RED::Quaternion::GetLength | ( | ) const |
Gets the length of the quaternion.
Returns:
public double RED::Quaternion::GetLength2 | ( | ) const |
Gets the squared length of the quaternion.
Returns:
public void RED::Quaternion::GetRotationMatrix | ( | RED::Matrix & | oRotationMatrix | ) const |
Gets the rotation matrix from this quaternion.
Parameters:
oRotationMatrix: | Returned rotation matrix. |
public void RED::Quaternion::InnerQuadrangle | ( | const RED::Quaternion & | iQuatBefore, |
const RED::Quaternion & | iQuat, | ||
const RED::Quaternion & | iQuatAfter | ||
) |
Computes the inner quadrangle of a quaternion based on the two surrounding quaternions.
Parameters:
iQuatBefore: | The quaternion before. |
iQuat: | The quaternion for which to compute the inner quadrangle. |
iQuatAfter: | The quaternion after. |
public void RED::Quaternion::Invert | ( | ) |
'In-place' inversion of 'this'.
Computes the inverse of this, replacing the previous quaternion contents.
public void RED::Quaternion::Log | ( | RED::Vector3 & | oLog | ) const |
Logarithmic quaternion function.
Parameters:
oLog: | Returned log of the quaternion. |
public double RED::Quaternion::Normalize | ( | ) |
Normalizes the quaternion.
Calculates the length of the quaternion( x*x + y*y + z*z + w*w ) and divides the components by this length.
Returns:
public bool RED::Quaternion::operator!= | ( | const RED::Quaternion & | iOther | ) const |
Returns the result of a difference test between two quaternions.
Parameters:
iOther: | Reference to the quaternion to test with. |
Returns:
public RED::Quaternion RED::Quaternion::operator* | ( | double | iScalar | ) const |
Multiplies the components of a quaternion with a scalar.
Parameters:
iScalar: | Number to multiply the quaternion with. |
Returns:
public RED::Quaternion RED::Quaternion::operator* | ( | const RED::Quaternion & | iRight | ) const |
Multiplication of two vectors.
Parameters:
iRight: | Quaternion to multiply to this. |
Returns:
public void RED::Quaternion::operator*= | ( | double | iScalar | ) |
Multiplies the components of the quaternion with a scalar.
Parameters:
iScalar: | Number to multiply the quaternion with. |
public void RED::Quaternion::operator*= | ( | const RED::Quaternion & | iRight | ) |
Multiplication of two quaternions.
Store in this the result of the product of this with iRight.
Parameters:
iRight: | Quaternion to multiply to this. |
public RED::Quaternion RED::Quaternion::operator+ | ( | const RED::Quaternion & | iSource | ) const |
Addition operation.
Builds a new quaternion by the addition of two others.
Returns:
public void RED::Quaternion::operator+= | ( | const RED::Quaternion & | iSource | ) |
Increment operation.
Adds the iSource quaternion to this.
Parameters:
iSource: | Added term. |
public RED::Quaternion RED::Quaternion::operator- | ( | const RED::Quaternion & | iRight | ) const |
Subtraction operation.
Builds a new quaternion by the subtraction of two others.
Parameters:
iRight: | Right operand of the subtraction |
Returns:
public RED::Quaternion RED::Quaternion::operator- | ( | ) const |
Returns the opposite of the quaternion.
Returns:
public void RED::Quaternion::operator-= | ( | const RED::Quaternion & | iSource | ) |
Decrement operation.
Subtracts the iSource quaternion to this.
Parameters:
iSource: | Subtracted term. |
public RED::Quaternion RED::Quaternion::operator/ | ( | double | iScalar | ) const |
Divides the components of a quaternion by a scalar.
Parameters:
iScalar: | Number to divide the quaternion by. |
Returns:
public void RED::Quaternion::operator/= | ( | double | iScalar | ) |
Divides the components of the quaternion by a scalar.
Parameters:
iScalar: | Number to divide the quaternion by. |
public bool RED::Quaternion::operator== | ( | const RED::Quaternion & | iOther | ) const |
Returns the result of an equality test between two quaternions.
Parameters:
iOther: | Reference to the quaternion to test with. |
Returns:
public double RED::Quaternion::operator[] | ( | unsigned int | iIndex | ) const |
Gets the n-th component of a quaternion.
Returns:
public double & RED::Quaternion::operator[] | ( | unsigned int | iIndex | ) |
Gets the n-th component of a quaternion in read-write mode.
Returns:
public void RED::Quaternion::Set | ( | double | iX, |
double | iY, | ||
double | iZ, | ||
double | iW | ||
) |
Sets the four component of a quaternion.
Parameters:
iX: | First component. |
iY: | Second component. |
iZ: | Third component. |
iW: | Fourth component. |
public void RED::Quaternion::SetAxisAngle | ( | const RED::Vector3 & | iAxis, |
double | iAngle | ||
) |
Sets the quaternion from an axis angle rotation .
Parameters:
iAxis: | The rotation axis. |
iAngle: | The rotation angle. |
public void RED::Quaternion::SetRotationMatrix | ( | const RED::Matrix & | iRotationMatrix | ) |
Sets the quaternion from a rotation matrix.
Parameters:
iRotationMatrix: | Rotation matrix to set the quaternion from. |
public void RED::Quaternion::Slerp | ( | const RED::Quaternion & | iQuatFrom, |
const RED::Quaternion & | iQuatTo, | ||
double | iWeight | ||
) |
Computes the Spherical Linear Interpolation between two quaternions.
Parameters:
iQuatFrom: | Starting quaternion. |
iQuatTo: | Ending quaternion. |
iWeight: | weight value between 0 and 1. |
public void RED::Quaternion::Squad | ( | const RED::Quaternion & | iQuatFrom, |
const RED::Quaternion & | iQuatTo, | ||
const RED::Quaternion & | iInnerQuadrangleFrom, | ||
const RED::Quaternion & | iInnerQuadrangleTo, | ||
double | iWeight | ||
) |
Computes the Spherical Quadrangle Interpolation between two quaternions.
The inner quadrangles can be computed with RED::Quaternion::InnerQuadrangle.
For 2 quaternions ( i ) and ( i + 1 ) on a curve, the code is:
s1.InnerQuadrangle( q[ i - 1 ], q[ i ], q[ i + 1 ] );
s2.InnerQuadrangle( q[ i ], q[ i + 1 ], q[ i + 2 ] );
r.Squad( q[ i ], q[ i + 1 ], s1, s2, t );
Special case of the curve starting point 0:
s.InnerQuadrangle( q[ 0 ], q[ 1 ], q[ 2 ] );
r.Squad( q[ 0 ], q[ 1 ], q[ 0 ], s, t );
Special case of the curve ending point n:
s.InnerQuadrangle( q[ n - 2 ], q[ n - 1 ], q[ n ] );
r.Squad( q[ n - 1 ], q[ n ], s, q[ n ], t );
Parameters:
iQuatFrom: | Starting quaternion. |
iQuatTo: | Ending quaternion. |
iInnerQuadrangleFrom: | Inner quadrangle for the starting quaternion. |
iInnerQuadrangleTo: | Inner quadrangle for the ending quaternion. |
iWeight: | weight value between 0 and 1. |
public double RED::Quaternion::W | ( | ) const |
Returns:
public double RED::Quaternion::X | ( | ) const |
Returns:
public double RED::Quaternion::Y | ( | ) const |
Returns:
public double RED::Quaternion::Z | ( | ) const |
Returns:
Variables documentation
W dimension of the vector.
X dimension of the vector.
Y dimension of the vector.
Z dimension of the vector.
Identity quaternion.
Zero quaternion.