sgQuaternion Class Reference

#include <sgQuaternion.h>

List of all members.

Public Member Functions

 sgQuaternion (const sgQuaternion &quat)
 sgQuaternion (float x_=0.0f, float y_=0.0f, float z_=0.0f, float w_=1.0f)
 sgQuaternion (const sgVector3 &rot)
 sgQuaternion (const sgVector4 &rot)
bool operator== (sgQuaternion &other)
bool operator!= (sgQuaternion &other)
sgQuaternionoperator= (const sgQuaternion &other)
sgQuaternionoperator= (const sgVector3 &other)
sgQuaternionoperator= (const sgVector4 &other)
sgQuaternionoperator+= (const sgQuaternion &other)
sgQuaternionoperator-= (const sgQuaternion &other)
sgQuaternionoperator*= (const sgQuaternion &other)
sgQuaternionoperator/= (const sgQuaternion &other)
sgQuaternion operator+ (const sgQuaternion &other)
sgQuaternion operator- (const sgQuaternion &other)
sgQuaternion operator* (const sgQuaternion &other)
sgQuaternion operator/ (const sgQuaternion &other)
sgQuaternionoperator+= (const sgVector3 &other)
sgQuaternionoperator-= (const sgVector3 &other)
sgQuaternion operator+ (const sgVector3 &other)
sgQuaternion operator- (const sgVector3 &other)
sgQuaternionoperator*= (const float &other)
sgQuaternionoperator/= (const float &other)
sgQuaternion operator* (const float &other)
sgQuaternion operator/ (const float &other)
void makeIdentity ()
void makeEuler (const sgVector3 &rot)
void makeEuler (const sgVector4 &rot)
void makeAxisAngle (const sgVector3 &axis, float ang)
void makeAxisAngle (const sgVector4 &axis)
void makeLerpS (const sgQuaternion &quat1, const sgQuaternion &quat2, float fac)
void makeLerpN (const sgQuaternion &quat1, const sgQuaternion &quat2, float fac)
void makeLerpS (const sgQuaternion &other, float fac)
void makeLerpN (const sgQuaternion &other, float fac)
sgQuaternion lerpS (sgQuaternion &other, float fac)
sgQuaternion lerpN (sgQuaternion &other, float fac)
void normalize ()
void conjugate ()
float length ()
float dot (const sgQuaternion &other)
sgVector3 rotate (const sgVector3 &vec)
sgVector4 rotate (const sgVector4 &vec)
sgMatrix4x4 getMatrix ()
sgVector3 getEuler ()
sgVector4 getAxisAngle ()

Public Attributes

float x
float y
float z
float w

Detailed Description

Quaternion class. Stores a quaternion and provides functionality for it. All angles are in degrees!


Constructor & Destructor Documentation

sgQuaternion::sgQuaternion ( const sgQuaternion quat  ) 

Constructor. Initializes a new instance from the other quaternion.

Parameters:
quat the other quaternion to copy the values from
sgQuaternion::sgQuaternion ( float  x_ = 0.0f,
float  y_ = 0.0f,
float  z_ = 0.0f,
float  w_ = 1.0f 
)

Constructor. Initializes a new instance from the given values.

Parameters:
x_ the quaternions x value
y_ the quaternions y value
z_ the quaternions z value
w_ the quaternions w value
sgQuaternion::sgQuaternion ( const sgVector3 rot  ) 

Constructor. Initializes a new instance from the vector.

Parameters:
rot the rotation as euler angles to initialize the quaternion with
sgQuaternion::sgQuaternion ( const sgVector4 rot  ) 

Constructor. Initializes a new instance from the vector.

Parameters:
rot the rotation in axis angle format to initialize the quaternion with

Member Function Documentation

void sgQuaternion::conjugate (  ) 

Conjugate. Inverts the quaternions imaginary parts.

float sgQuaternion::dot ( const sgQuaternion other  ) 

Dot product. The dot product of the quaternion with the other one.

Parameters:
other another quaternion
Returns:
the resulting scalar
sgVector4 sgQuaternion::getAxisAngle (  ) 

Get axis angle. Returns the quaternions rotation in axis angle format.

Returns:
the rotation as axis and angle
sgVector3 sgQuaternion::getEuler (  ) 

Get euler. Returns the quaternions rotation as euler angles.

Returns:
the rotation as euler angles
sgMatrix4x4 sgQuaternion::getMatrix (  ) 

Get matrix. Returns a rotation matrix representing the same rotation as the quaternion.

Returns:
the rotation matrix
float sgQuaternion::length (  ) 

Length. Get the length of the quaternion.

Returns:
the quaternions length
sgQuaternion sgQuaternion::lerpN ( sgQuaternion other,
float  fac 
)

Linear interpolation. Interpolate linear between the instance and the first parameter.

Parameters:
other the second quaternion to interpolate from
fac the interpolation factor to interpolate with, ranging from 0 to 1
Returns:
resulting quaternion from the interpolation
sgQuaternion sgQuaternion::lerpS ( sgQuaternion other,
float  fac 
)

Spherical interpolation. Interpolate spherical between the instance and the first parameter.

Parameters:
other the second quaternion to interpolate from
fac the interpolation factor to interpolate with, ranging from 0 to 1
Returns:
resulting quaternion from the interpolation
void sgQuaternion::makeAxisAngle ( const sgVector4 axis  ) 

Make axis angle. Set the quaternion to the representation of the given rotation around the given axis.

Parameters:
axis vector containing the orientation of the axis to rotate around and the angle as fourth parameter
void sgQuaternion::makeAxisAngle ( const sgVector3 axis,
float  ang 
)

Make axis angle. Set the quaternion to the representation of the given rotation around the given axis.

Parameters:
axis vector containing the orientation of the axis to rotate around
ang rotation angle in degrees
void sgQuaternion::makeEuler ( const sgVector4 rot  ) 

Make euler. Set the quaternion to the representation of the given euler angles, by ignoring the vectors w component.

Parameters:
rot vector containing the rotation as euler angles
void sgQuaternion::makeEuler ( const sgVector3 rot  ) 

Make euler. Set the quaternion to the representation of the given euler angles.

Parameters:
rot vector containing the rotation as euler angles
void sgQuaternion::makeIdentity (  ) 

Make identity. Set the quaternion to the one representing no rotation.

void sgQuaternion::makeLerpN ( const sgQuaternion other,
float  fac 
)

Make linear interpolation. Set the quaternion to the result of the linear interpolation given by the instance and the parameters.

Parameters:
other the second quaternion to interpolate from
fac the interpolation factor to interpolate with, ranging from 0 to 1
void sgQuaternion::makeLerpN ( const sgQuaternion quat1,
const sgQuaternion quat2,
float  fac 
)

Make linear interpolation. Set the quaternion to the result of the linear interpolation given by the parameters.

Parameters:
quat1 the first quaternion to interpolate from
quat2 the second quaternion to interpolate from
fac the interpolation factor to interpolate with, ranging from 0 to 1
void sgQuaternion::makeLerpS ( const sgQuaternion other,
float  fac 
)

Make spherical interpolation. Set the quaternion to the result of the spherical interpolation given by the instance and the parameters.

Parameters:
other the second quaternion to interpolate from
fac the interpolation factor to interpolate with, ranging from 0 to 1
void sgQuaternion::makeLerpS ( const sgQuaternion quat1,
const sgQuaternion quat2,
float  fac 
)

Make spherical interpolation. Set the quaternion to the result of the spherical interpolation given by the parameters.

Parameters:
quat1 the first quaternion to interpolate from
quat2 the second quaternion to interpolate from
fac the interpolation factor to interpolate with ranging from 0 to 1
void sgQuaternion::normalize (  ) 

Normalize. Normalizes the quaternion.

bool sgQuaternion::operator!= ( sgQuaternion other  ) 

Not equal. Checks if two instances do not equal each other.

sgQuaternion sgQuaternion::operator* ( const float &  other  ) 

Multiply. Multiply the quaternions with a scalar.

sgQuaternion sgQuaternion::operator* ( const sgQuaternion other  ) 

Multiply. Multiply the two quaternions.

sgQuaternion & sgQuaternion::operator*= ( const float &  other  ) 

Multiply. Multiply the quaternions with a scalar.

sgQuaternion & sgQuaternion::operator*= ( const sgQuaternion other  ) 

Multiply. Multiply the two quaternions.

sgQuaternion sgQuaternion::operator+ ( const sgVector3 other  ) 

Add. Add the euler angles in the vector to the rotation of the quaternion.

sgQuaternion sgQuaternion::operator+ ( const sgQuaternion other  ) 

Add. Add the two quaternions.

sgQuaternion & sgQuaternion::operator+= ( const sgVector3 other  ) 

Add. Add the euler angles in the vector to the rotation of the quaternion.

sgQuaternion & sgQuaternion::operator+= ( const sgQuaternion other  ) 

Add. Add the two quaternions.

sgQuaternion sgQuaternion::operator- ( const sgVector3 other  ) 

Substract. Substract the euler angles in the vector from the rotation of the quaternion.

sgQuaternion sgQuaternion::operator- ( const sgQuaternion other  ) 

Substract. Substract the two quaternions.

sgQuaternion & sgQuaternion::operator-= ( const sgVector3 other  ) 

Substract. Substract the euler angles in the vector from the rotation of the quaternion.

sgQuaternion & sgQuaternion::operator-= ( const sgQuaternion other  ) 

Substract. Substract the two quaternions.

sgQuaternion sgQuaternion::operator/ ( const float &  other  ) 

Divide. Divide the quaternions by a scalar.

sgQuaternion sgQuaternion::operator/ ( const sgQuaternion other  ) 

Divide. Divide the two quaternions.

sgQuaternion & sgQuaternion::operator/= ( const float &  other  ) 

Divide. Divide the quaternions by a scalar.

sgQuaternion & sgQuaternion::operator/= ( const sgQuaternion other  ) 

Divide. Divide the two quaternions.

sgQuaternion & sgQuaternion::operator= ( const sgVector4 other  ) 

Copy. Set the quaternion to the representation of the axis and angle given by the parameter.

sgQuaternion & sgQuaternion::operator= ( const sgVector3 other  ) 

Copy. Set the quaternion to the representation of the euler angles given by the parameter.

sgQuaternion & sgQuaternion::operator= ( const sgQuaternion other  ) 

Copy. Copy the values of one instance to the other.

bool sgQuaternion::operator== ( sgQuaternion other  ) 

Equal. Checks if two instances equal each other.

sgVector4 sgQuaternion::rotate ( const sgVector4 vec  ) 

Rotate vector. Applies the rotation represented by the quaternion to a vector.

Parameters:
vec the vector to rotate
Returns:
the rotated vector
sgVector3 sgQuaternion::rotate ( const sgVector3 vec  ) 

Rotate vector. Applies the rotation represented by the quaternion to a vector.

Parameters:
vec the vector to rotate
Returns:
the rotated vector

Member Data Documentation

W. The quaternions w component. The real part.

X. The quaternions x component.

Y. The quaternions y component.

Z. The quaternions z component.


The documentation for this class was generated from the following files:
Generated on Thu Jun 3 13:31:04 2010 for iSDGE by  doxygen 1.6.3