OpenGLPrakt --> math

class cMatrix

A class for representing a 4x4 matrix. It supports matrix math too.

this really simplifies matrix math! :-) oh, not to forget: my matrix is built as follows: (due to OpenGL's convention to store matrices column-major - argh!)

  _             _
 |               |
 | x   y   z   0 |
 |  x   x   x    |
 |               |
 | x   y   z   0 |
 |  y   y   y    |
 |               |
 | x   y   z   0 |
 |  z   z   z    |
 |               |
 | p   p   p   1 |
 |  x   y   z    |
 |_             _|

(xx, xy, xz) is the x-axis

(yx, yy, yz) is the y-axis

(zx, zy, zz) is the z-axis

(px, py, pz) is the translation

Source:
../src/cMatrix.hh:48

Constructors Index

cMatrix
[public] default constructor (initializes to identity)


Variables Index

mMatrix
[public] Matrix data made public to allow direct access


Methods Index

Identity
[public] Initialize matrix to identity
Normalize
[public] "normalize" the matrix by normalizing the axis components
operator *
[public] an operator to multiply a vector with an matrix (which means transforming the vector by the matrix)
operator /
[public] an operator to inversely multiply a vector with an matrix (which means transforming the vector by the matrix's inverse)
operator GLfloat*
[public] operator to "convert" matrix to an pointer to GLfloat
Translate
[public] translate/move origin of matrix
Translate
[public] translate/move origin of matrix


Constructors

cMatrix

public cMatrix ( ) ;

default constructor (initializes to identity)


Variables

mMatrix

public GLfloat mMatrix [ 4 ] [ 4 ]

Matrix data made public to allow direct access

(operator[] doesnt work with 2-dimensional fields... :-( ) has anyone a better idea?


Methods

operator *

public inline cVertex operator * ( const cVertex & v ) ;

an operator to multiply a vector with an matrix (which means transforming the vector by the matrix)

Parameters:
m matrix to multiply with

Return:
reference to self

operator /

public inline cVertex operator / ( const cVertex & v ) ;

an operator to inversely multiply a vector with an matrix (which means transforming the vector by the matrix's inverse)

operator GLfloat*

public inline operator GLfloat * ( ) ;

operator to "convert" matrix to an pointer to GLfloat

Identity

public inline cMatrix & Identity ( ) ;

Initialize matrix to identity

Return:
reference to cMatrix object (for convenience)

Normalize

public inline cMatrix & Normalize ( ) ;

"normalize" the matrix by normalizing the axis components

This is a very special operation which is only sometimes useful to get orthonormal bases.

Return:
reference to cMatrix object

Translate

public inline void Translate ( const cVertex & v ) ;

translate/move origin of matrix

Parameters:
v amount to translate

Translate

public inline void Translate ( const GLfloat x ,
                               const GLfloat y ,
                               const GLfloat z ) ;

translate/move origin of matrix

Parameters:
x distance to translate
y distance to translate
z distance to translate

This documentation was generated automatically by the ccdoc tool (version 0.7a).
Click here to submit a bug report or feature request.

Click here to return to the top of the page.