ot::MathUtils Class Reference

#include <MathUtils.h>

List of all members.

Public Types

typedef double Matrix3x3 [3][3]
 3x3 double matrix type
typedef double Matrix4x4 [4][4]
 4x4 double matrix type
typedef double Vector3 [3]
 3 double vector
typedef double Quaternion [4]
 4 double vector used as quaternion
enum  EULER {
  XYX = 0 + 4 + 0, XYZ = 0 + 4 + 2, XZX = 0 + 8 + 0, XZY = 0 + 8 + 1,
  YXY = 16 + 0 + 1, YXZ = 16 + 0 + 2, YZX = 16 + 8 + 0, YZY = 16 + 8 + 1,
  ZXY = 32 + 0 + 1, ZXZ = 32 + 0 + 2, ZYX = 32 + 4 + 0, ZYZ = 32 + 4 + 2
}
 encodes all possible euler angle sequences More...

Public Member Functions

void translationQuaternionTo4x4Matrix (std::vector< float > &pos, std::vector< float > &quat, MathUtils::Matrix4x4 &mat)

Static Public Member Functions

static float * axisAngleToQuaternion (const float *axisa, float *qResult)
static std::vector< float > & axisAngleToQuaternion (const std::vector< float > &axisa, std::vector< float > &qResult)
static double * axisAngleToQuaternion (const double *axisa, Quaternion qResult)
static float * eulerToQuaternion (const float roll, const float pitch, const float yaw, float *qResult)
static std::vector< float > & eulerToQuaternion (const float roll, const float pitch, const float yaw, std::vector< float > &qResult)
static float * eulerToQuaternion (const double alpha, const double beta, const double gamma, const enum MathUtils::EULER sequence, float *qResult)
static float * invertQuaternion (const float *q, float *qResult)
static std::vector< float > & invertQuaternion (const std::vector< float > &q, std::vector< float > &qResult)
static float * matrixToQuaternion (const float matrix[3][3], float *qResult)
static std::vector< float > & matrixToQuaternion (const float matrix[3][3], std::vector< float > &qResult)
static float * multiplyQuaternion (const float *q1, const float *q2, float *qResult)
static std::vector< float > & multiplyQuaternion (const std::vector< float > &q1, const std::vector< float > &q2, std::vector< float > &qResult)
static double * multiplyQuaternion (const Quaternion q1, const Quaternion q2, Quaternion qResult)
static float * normalizeQuaternion (float *q)
static std::vector< float > & normalizeQuaternion (std::vector< float > &q)
static double * normalizeQuaternion (Quaternion q)
static float * rotateVector (const float *q, const float *v, float *vResult)
static std::vector< float > & rotateVector (const std::vector< float > &q, const std::vector< float > &v, std::vector< float > &vResult)
static float determinant (const float matrix[3][3])
static float * quaternionToAxisAngle (const float *q, float *axisa)
static void quaternionToAxisAngle (std::vector< float > &q, std::vector< float > &axisa)
static double angle (const float *v1, const float *v2, const int dim)
static double angle (const std::vector< float > &v1, const std::vector< float > &v2, const int dim)
static double dot (const float *v1, const float *v2, const int dim)
static double dot (const std::vector< float > &v1, const std::vector< float > &v2, const int dim)
static float * slerp (const float *q1, const float *q2, const float t, float *qResult)
static std::vector< float > & slerp (const std::vector< float > &q1, const std::vector< float > &q2, const float t, std::vector< float > &qResult)
static void quaternionToMatrix (Quaternion &q, Matrix4x4 &m)
static void matrixToQuaternion (Matrix4x4 &matrix, Quaternion &qResult)
static void matrixMultiply (const Matrix4x4 m1, const Matrix4x4 m2, Matrix4x4 &m)
static void matrixMultiply (const Matrix3x3 m1, const Matrix3x3 m2, Matrix3x3 &m)
static void MatrixToEuler (Vector3 angles, const Matrix4x4 colMatrix)

Static Public Attributes

static const Matrix4x4 matrix4x4_flipY
 mirror at the x-z-plane
static const Matrix4x4 matrix4x4_identity
 identity matrix
static const double Pi = 3.1415926535897932385
 the nice constant Pi
static const double E = 2.7182818284590452354
 the also nice constant e
static const double GradToRad = MathUtils::Pi / 180.0
 another nice constant to transform grad to radiants


Member Typedef Documentation

typedef double ot::MathUtils::Matrix3x3[3][3]
 

3x3 double matrix type

typedef double ot::MathUtils::Matrix4x4[4][4]
 

4x4 double matrix type

typedef double ot::MathUtils::Quaternion[4]
 

4 double vector used as quaternion

typedef double ot::MathUtils::Vector3[3]
 

3 double vector


Member Enumeration Documentation

enum ot::MathUtils::EULER
 

encodes all possible euler angle sequences

Enumerator:
XYX 
XYZ 
XZX 
XZY 
YXY 
YXZ 
YZX 
YZY 
ZXY 
ZXZ 
ZYX 
ZYZ 


Member Function Documentation

double ot::MathUtils::angle const std::vector< float > &  v1,
const std::vector< float > &  v2,
const int  dim
[static]
 

computes the angle between two n-dimensional vectors.

Parameters:
v1 vector<float> first vector
v2 vector<float> second vector
dim dimension n of the two vectors
Returns:
angle between the two vectors

double ot::MathUtils::angle const float *  v1,
const float *  v2,
const int  dim
[static]
 

computes the angle between two n-dimensional vectors.

Parameters:
v1 float[n] first vector
v2 float[n] second vector
dim dimension n of the two vectors
Returns:
angle between the two vectors

double * ot::MathUtils::axisAngleToQuaternion const double *  axisa,
Quaternion  qResult
[static]
 

converts an axis angle representation into a quaternion. This method operates directly on the arguments. Therefore using the same pointers for several arguments will produce wrong results !

Parameters:
axisa double[4] containing axis and angle in radiants
qResult double[4] where the result is stored
Returns:
pointer to result array

std::vector< float > & ot::MathUtils::axisAngleToQuaternion const std::vector< float > &  axisa,
std::vector< float > &  qResult
[static]
 

converts an axis angle representation into a quaternion. This method operates directly on the arguments. Therefore using the same pointers for several arguments will produce wrong results !

Parameters:
axisa vector<float> (assumes length 4) containing axis and angle in radiants
qResult vector<float> (assumes length 4) where the result is stored
Returns:
reference to result vector

float * ot::MathUtils::axisAngleToQuaternion const float *  axisa,
float *  qResult
[static]
 

converts an axis angle representation into a quaternion. This method operates directly on the arguments. Therefore using the same pointers for several arguments will produce wrong results !

Parameters:
axisa float[4] containing axis and angle in radiants
qResult float[4] where the result is stored
Returns:
pointer to result array

float ot::MathUtils::determinant const float  matrix[3][3]  )  [static]
 

computes the determinant of a 3x3 matrix.

Parameters:
matrix the 3x3 matrix to use
Returns:
determinant of the matrix

double ot::MathUtils::dot const std::vector< float > &  v1,
const std::vector< float > &  v2,
const int  dim
[static]
 

computes the dot product between two n-dimensional vectors.

Parameters:
v1 vector<float> first vector
v2 vector<float> second vector
dim dimension n of the two vectors
Returns:
dot product between the two vectors

double ot::MathUtils::dot const float *  v1,
const float *  v2,
const int  dim
[static]
 

computes the dot product between two n-dimensional vectors.

Parameters:
v1 float[n] first vector
v2 float[n] second vector
dim dimension n of the two vectors
Returns:
dot product between the two vectors

float * ot::MathUtils::eulerToQuaternion const double  alpha,
const double  beta,
const double  gamma,
const enum MathUtils::EULER  sequence,
float *  qResult
[static]
 

computes a quaternion from euler angles representing a rotation. This is the general method and supports all euler angle sequences. Use this instead of the old one for more control.

Parameters:
alpha first euler angle
beta second euler angle
gamma third euler angle
sequence enum defining the sequence to use
qResult pointer to the result quaternion
Returns:
returns the pointer to the result quaternion

std::vector< float > & ot::MathUtils::eulerToQuaternion const float  roll,
const float  pitch,
const float  yaw,
std::vector< float > &  qResult
[static]
 

computes a quaternion from euler angles representing a rotation.

Deprecated:
use the other overloaded variant instead.
Parameters:
roll rotation around looking axis
pitch rotation around up axis
yaw rotation around side axis
qResult vector<float> where the result is stored
Returns:
reference to result vector

float * ot::MathUtils::eulerToQuaternion const float  roll,
const float  pitch,
const float  yaw,
float *  qResult
[static]
 

computes a quaternion from euler angles representing a rotation.

Deprecated:
use the other overloaded variant instead.
Parameters:
roll rotation around looking axis
pitch rotation around up axis
yaw rotation around side axis
qResult float[4] where the result is stored
Returns:
pointer to result array

std::vector< float > & ot::MathUtils::invertQuaternion const std::vector< float > &  q,
std::vector< float > &  qResult
[static]
 

inverts a quaternion. This method operates directly on the arguments. Therefore using the same pointers for several arguments will produce wrong results !

Parameters:
q vector<float> (assumes length 4) storing the quaternion
qResult vector<float> where the result is stored
Returns:
reference to result vector

float * ot::MathUtils::invertQuaternion const float *  q,
float *  qResult
[static]
 

inverts a quaternion. This method operates directly on the arguments. Therefore using the same pointers for several arguments will produce wrong results !

Parameters:
q float[4] storing the quaternion
qResult float[4] where the result is stored
Returns:
pointer to result array

static void ot::MathUtils::matrixMultiply const Matrix3x3  m1,
const Matrix3x3  m2,
Matrix3x3 m
[static]
 

void ot::MathUtils::matrixMultiply const Matrix4x4  m1,
const Matrix4x4  m2,
Matrix4x4 m
[static]
 

void ot::MathUtils::MatrixToEuler Vector3  angles,
const Matrix4x4  colMatrix
[static]
 

void ot::MathUtils::matrixToQuaternion Matrix4x4 matrix,
Quaternion qResult
[static]
 

std::vector< float > & ot::MathUtils::matrixToQuaternion const float  matrix[3][3],
std::vector< float > &  qResult
[static]
 

converts a rotational matrix to a quaternion.

Parameters:
matrix float[3][3] storing the rotational matrix
qResult vector<float> where the result is stored
Returns:
reference to result vector

float * ot::MathUtils::matrixToQuaternion const float  matrix[3][3],
float *  qResult
[static]
 

converts a rotational matrix to a quaternion.

Parameters:
matrix float[3][3] storing the rotational matrix
qResult float[4] where the result is stored
Returns:
pointer to result array

static double* ot::MathUtils::multiplyQuaternion const Quaternion  q1,
const Quaternion  q2,
Quaternion  qResult
[static]
 

multiplies two quaternions and stores result in a third. This method operates directly on the arguments. Therefore using the same pointers for several arguments will produce wrong results !

Parameters:
q1 Quaternion storing first quaternion
q2 Quaternion storing second quaternion
qResult Quaternion where the result is stored
Returns:
pointer to result array

std::vector< float > & ot::MathUtils::multiplyQuaternion const std::vector< float > &  q1,
const std::vector< float > &  q2,
std::vector< float > &  qResult
[static]
 

multiplies two quaternions and stores result in a third. This method operates directly on the arguments. Therefore using the same pointers for several arguments will produce wrong results !

Parameters:
q1 vector<float> (assumes length 4) storing first quaternion
q2 vector<float> (assumes length 4) storing second quaternion
qResult vector<float> where the result is stored
Returns:
pointer to result vector

float * ot::MathUtils::multiplyQuaternion const float *  q1,
const float *  q2,
float *  qResult
[static]
 

multiplies two quaternions and stores result in a third. This method operates directly on the arguments. Therefore using the same pointers for several arguments will produce wrong results !

Parameters:
q1 float[4] storing first quaternion
q2 float[4] storing second quaternion
qResult float[4] where the result is stored
Returns:
pointer to result array

double * ot::MathUtils::normalizeQuaternion Quaternion  q  )  [static]
 

normalizes quaternion to unit length. Here the computation is done in place and the parameter is changed !

Parameters:
q Quaternion storing quaternion
Returns:
pointer to result array

std::vector< float > & ot::MathUtils::normalizeQuaternion std::vector< float > &  q  )  [static]
 

normalizes quaternion to unit length. Here the computation is done in place and the parameter is changed !

Parameters:
q vector<float> (assumes length 4) storing quaternion
Returns:
reference to result vector

float * ot::MathUtils::normalizeQuaternion float *  q  )  [static]
 

normalizes quaternion to unit length. Here the computation is done in place and the parameter is changed !

Parameters:
q float[4] storing quaternion
Returns:
pointer to result array

void ot::MathUtils::quaternionToAxisAngle std::vector< float > &  q,
std::vector< float > &  axisa
[static]
 

computes the vector and angle representation of a quaternion. This method operates directly on the arguments. Therefore using the same pointers for several arguments will produce wrong results !

Parameters:
q std::vector<float> storing the quaternion
axisa std::vector<float> storing the vector and angle of the given quaternion

static float* ot::MathUtils::quaternionToAxisAngle const float *  q,
float *  axisa
[static]
 

computes the vector and angle representation of a quaternion. This method operates directly on the arguments. Therefore using the same pointers for several arguments will produce wrong results !

Parameters:
q float[4] storing the quaternion
axisa float[4] storing the vector and angle of the given quaternion
Returns:
pointer to result array (axisa)

void ot::MathUtils::quaternionToMatrix Quaternion q,
Matrix4x4 m
[static]
 

std::vector< float > & ot::MathUtils::rotateVector const std::vector< float > &  q,
const std::vector< float > &  v,
std::vector< float > &  vResult
[static]
 

rotates a vector using a given unit quaternion. It does not normalize the quaternion or check for unit length ! This method operates directly on the arguments. Therefore using the same pointers for several arguments will produce wrong results !

Parameters:
q vector<float> (assumes length 4) storing quaternion
v vector<float> (assumes length 3) storing vector
vResult vector<float> where the result is stored
Returns:
pointer to result array

float * ot::MathUtils::rotateVector const float *  q,
const float *  v,
float *  vResult
[static]
 

rotates a vector using a given unit quaternion. It does not normalize the quaternion or check for unit length ! This method operates directly on the arguments. Therefore using the same pointers for several arguments will produce wrong results !

Parameters:
q float[4] storing quaternion
v float[3] storing vector
vResult float[3] where the result is stored
Returns:
pointer to result array

std::vector< float > & ot::MathUtils::slerp const std::vector< float > &  q1,
const std::vector< float > &  q2,
const float  t,
std::vector< float > &  qResult
[static]
 

computes the spherical linear interpolation between two quaternions. The formulas used are probably only stable for t in [0,1], but it can be used to calculate extrapolations as well. Moreover the slerp is always computed on the shorter path between the quaternions. This method operates directly on the arguments. Therefore using the same pointers for several arguments will produce wrong results !

Parameters:
q1 vector<float> (assumes length 4) first quaternion
q2 vector<float> (assumes length 4) second quaternion
t interpolation parameter
qResult vector<float> stores result
Returns:
reference to result = qResult

float * ot::MathUtils::slerp const float *  q1,
const float *  q2,
const float  t,
float *  qResult
[static]
 

computes the spherical linear interpolation between two quaternions. The formulas used are probably only stable for t in [0,1], but it can be used to calculate extrapolations as well. Moreover the slerp is always computed on the shorter path between the quaternions. This method operates directly on the arguments. Therefore using the same pointers for several arguments will produce wrong results !

Parameters:
q1 float[4] first quaternion
q2 float[4] second quaternion
t interpolation parameter
qResult float[4] stores result
Returns:
pointer to result = qResult

void ot::MathUtils::translationQuaternionTo4x4Matrix std::vector< float > &  pos,
std::vector< float > &  quat,
MathUtils::Matrix4x4 mat
 


Member Data Documentation

const double ot::MathUtils::E = 2.7182818284590452354 [static]
 

the also nice constant e

const double ot::MathUtils::GradToRad = MathUtils::Pi / 180.0 [static]
 

another nice constant to transform grad to radiants

const MathUtils::Matrix4x4 ot::MathUtils::matrix4x4_flipY [static]
 

Initial value:

 {{1, 0, 0, 0},
                                                             {0,-1, 0, 0},
                                                             {0, 0, 1, 0},
                                                             {0, 0, 0, 1}}
mirror at the x-z-plane

const MathUtils::Matrix4x4 ot::MathUtils::matrix4x4_identity [static]
 

Initial value:

 {{1, 0, 0, 0},
                                                                {0, 1, 0, 0},
                                                                {0, 0, 1, 0},
                                                                {0, 0, 0, 1}}
identity matrix

const double ot::MathUtils::Pi = 3.1415926535897932385 [static]
 

the nice constant Pi


The documentation for this class was generated from the following files:
Generated on Wed Feb 28 15:29:03 2007 for NaviTrack by  doxygen 1.4.6