Main Page   Namespace List   Class Hierarchy   Compound List   Namespace Members   Compound Members   Related Pages  

VrmlMatrix Class Reference

A class for all matrix operations. More...

List of all members.


Public Methods

 VrmlMatrix () throw ()
 Default constructor.

 VrmlMatrix (float f11, float f12, float f13, float f14, float f21, float f22, float f23, float f24, float f31, float f32, float f33, float f34, float f41, float f42, float f43, float f44) throw ()
 Construct VrmlMatrix with given 16 elements in row-major order.

 VrmlMatrix (const float m[4][4]) throw ()
 Construct from an array.

 float (&operator[](size_t index) throw())[4]
const float (&operator[](size_t index) const throw())[4]
const float (&get() const throw())[4][4]
void setRotate (const float axisAngle[4]) throw ()
 Sets matrix to rotate by given rotation Graphics Gems p466.

void setRotate (const SFRotation &axisAngle) throw ()
 Sets matrix to rotate by given rotation Graphics Gems p466.

void setScale (float s) throw ()
 Sets matrix to scale by given uniform factor.

void setScale (const float s[3]) throw ()
 Sets matrix to scale by given vector in array[X Y Z].

void setScale (const SFVec3f &s) throw ()
 Sets matrix to scale by given SFVec3f object.

void setTranslate (const float t[3]) throw ()
 Sets matrix to translate by given vector in array[X Y Z].

void setTranslate (const SFVec3f &t) throw ()
 Sets matrix to translate by given SFVec3f object.

void setTransform (const SFVec3f &translation, const SFRotation &rotation, const SFVec3f &scale, const SFRotation &scaleOrientation, const SFVec3f &center) throw ()
 Set the matrix from translation, rotation, scale, scaleOrientation, and center.

void getTransform (SFVec3f &translation, SFRotation &rotation, SFVec3f &scale) const throw ()
 Get the translation, rotation and scale from the orthogonal transformation matrix.

void getTransform (SFVec3f &translation, SFRotation &rotation, SFVec3f &scale, SFVec3f &shear) const throw ()
 Get the translation, rotation, scale and shear from affine transformation matrix.

const VrmlMatrix affine_inverse () const throw ()
 Get the inverse of an affine matrix.

const VrmlMatrix transpose () const throw ()
 Get the transposition of the matrix.

const VrmlMatrix multLeft (const VrmlMatrix &mat) const throw ()
 Premultiplies matrix by given matrix on the left.

const VrmlMatrix multRight (const VrmlMatrix &mat) const throw ()
 Postmultiplies matrix by given matrix on the right.

void multMatrixVec (const SFVec3f &src, SFVec3f &dst) const throw ()
 Postmultiplies matrix by a column vector on the right.

void multMatrixVec (const float src[3], float dst[3]) const throw ()
void multVecMatrix (const SFVec3f &src, SFVec3f &dst) const throw ()
 Premultiplies matrix by given row vector on left.

void multVecMatrix (const float src[3], float dst[3]) const throw ()
float det3 (int r1, int r2, int r3, int c1, int c2, int c3) const throw ()
 Return determinant of 3x3 submatrix by given row and column indices.

float det4 () const throw ()
 Return determinant of entire matrix.


Private Attributes

float matrix [4][4]

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &out, const VrmlMatrix &mat)
 Stream output.

bool operator== (const VrmlMatrix &lhs, const VrmlMatrix &rhs) throw()
 Equality comparison operator.


Detailed Description

A class for all matrix operations.

Matrices are stored in row-major order. Some parts are taken from MathUtils (thanks to Chris Morley) but format is not same.


Constructor & Destructor Documentation

VrmlMatrix   throw ()
 

Default constructor.

Matrix is initialized to the identity matrix.

VrmlMatrix float    f11,
float    f12,
float    f13,
float    f14,
float    f21,
float    f22,
float    f23,
float    f24,
float    f31,
float    f32,
float    f33,
float    f34,
float    f41,
float    f42,
float    f43,
float    f44
throw ()
 

Construct VrmlMatrix with given 16 elements in row-major order.

Parameters:
f11 
f12 
f13 
f14 
f21 
f22 
f23 
f24 
f31 
f32 
f33 
f34 
f41 
f42 
f43 
f44 

VrmlMatrix const float    m[4][4] throw () [explicit]
 

Construct from an array.

Parameters:
m a 4x4 array of elements in row-major order.

Member Function Documentation

const VrmlMatrix affine_inverse   const throw ()
 

Get the inverse of an affine matrix.

Returns:
the inverse of the matrix.
Precondition:
the current matrix must be affine.

float det3 int    r1,
int    r2,
int    r3,
int    c1,
int    c2,
int    c3
const throw ()
 

Return determinant of 3x3 submatrix by given row and column indices.

Parameters:
r1 row index.
r2 row index.
r3 row index.
c1 column index.
c2 column index.
c3 column index.
Returns:
the determinant.

float det4   const throw ()
 

Return determinant of entire matrix.

Returns:
the determinant.

void getTransform SFVec3f   translation,
SFRotation   rotation,
SFVec3f   scale,
SFVec3f   shear
const throw ()
 

Get the translation, rotation, scale and shear from affine transformation matrix.

Here any projection information in matrix is ignored. As VRML allows non-uniform scaling, it is safe to call this routine. The caller is responsible for assuring that the transformation is in fact affine, otherwise the results are undefined.

Some portions are taken from Graphics Gems 2.

Parameters:
translation output translation.
rotation output rotation.
scale output scale.
shear output shear.

void getTransform SFVec3f   translation,
SFRotation   rotation,
SFVec3f   scale
const throw ()
 

Get the translation, rotation and scale from the orthogonal transformation matrix.

Here any projection or shear information in the matrix is ignored. The caller is responsible for assuring that the transformation is in fact orthogonal, otherwise the results are undefined.

Some portions are taken from Graphics Gems 2.

Parameters:
translation output translation.
rotation output rotation.
scale output scale.

const VrmlMatrix multLeft const VrmlMatrix &    mat const throw ()
 

Premultiplies matrix by given matrix on the left.

Parameters:
mat a matrix.
Returns:
the result matrix.

void multMatrixVec const SFVec3f   src,
SFVec3f   dst
const throw ()
 

Postmultiplies matrix by a column vector on the right.

Parameters:
src a column vector.
Return values:
dst the result vector.

const VrmlMatrix multRight const VrmlMatrix &    mat const throw ()
 

Postmultiplies matrix by given matrix on the right.

Parameters:
mat a matrix.
Returns:
the result matrix.

void multVecMatrix const SFVec3f   src,
SFVec3f   dst
const throw ()
 

Premultiplies matrix by given row vector on left.

Parameters:
src a row vector.
Return values:
dst the result vector.

void setRotate const SFRotation   axisAngle throw ()
 

Sets matrix to rotate by given rotation Graphics Gems p466.

Parameters:
axisAngle the SFRotation object.

void setRotate const float    axisAngle[4] throw ()
 

Sets matrix to rotate by given rotation Graphics Gems p466.

Parameters:
axisAngle [X Y Z angle] should be in normalized form

void setScale const SFVec3f   s throw ()
 

Sets matrix to scale by given SFVec3f object.

Parameters:
s a vector

void setScale const float    s[3] throw ()
 

Sets matrix to scale by given vector in array[X Y Z].

Parameters:
s a vector.

void setScale float    s throw ()
 

Sets matrix to scale by given uniform factor.

Parameters:
s scale factor.

void setTransform const SFVec3f   translation,
const SFRotation   rotation,
const SFVec3f   scale,
const SFRotation   scaleOrientation,
const SFVec3f   center
throw ()
 

Set the matrix from translation, rotation, scale, scaleOrientation, and center.

Parameters:
translation the translation.
rotation the rotation.
scale the scale.
scaleOrientation the scale orientation.
center the center.

void setTranslate const SFVec3f   t throw ()
 

Sets matrix to translate by given SFVec3f object.

Parameters:
t is a given vector object

void setTranslate const float    t[3] throw ()
 

Sets matrix to translate by given vector in array[X Y Z].

Parameters:
t a translation vector.

const VrmlMatrix transpose   const throw ()
 

Get the transposition of the matrix.

Returns:
a transposed copy of the matrix.

Friends And Related Function Documentation

std::ostream & operator<< std::ostream &    out,
const VrmlMatrix &    mat
[related]
 

Stream output.

Parameters:
out an output stream.
mat a matrix.
Returns:
out.

bool operator== const VrmlMatrix &    lhs,
const VrmlMatrix &    rhs
throw() [related]
 

Equality comparison operator.

All componenents must match exactly.

Parameters:
lhs a matrix.
rhs a matrix.