Gel2D - The free/open source game creation suite

Public Member Functions | Public Attributes
gel::Gel4x4Matrix Class Reference

Square matrix for 3-dimensional transformations. More...

#include <gelMatrix.h>

List of all members.

Public Member Functions

 Gel4x4Matrix ()
 Default constructor.
 Gel4x4Matrix (const float matrix[16])
 Convenience constructor.
void loadNull ()
 Sets all matrix entries to zero.
void loadIdentity ()
 Resets the matrix to its identity.
void translate (Gel3dVec pos)
 Translates the matrix.
void rotateX (float rot)
 Rotates the matrix around the X axis.
void rotateY (float rot)
 Rotates the matrix around the Y axis.
void rotateZ (float rot)
 Rotates the matrix around the Z axis.
void scale (Gel3dVec scl)
 Scales the matrix.
void shear (Gel2dVec shx, Gel2dVec shy, Gel2dVec shz)
 Shears the matrix.
bool isIdentity () const
 Determines whether or not this is an identity matrix.
bool isTranslation () const
 Determines whether or not this is a pure translation matrix.
bool isRotation () const
 Determines whether or not this is a pure rotation matrix.
bool isScaling () const
 Determines whether or not this is a pure scaling matrix.
bool isShearing () const
 Determines whether or not this is a pure shearing matrix.
void toOGLMatrix (float matrix[16]) const
 Converts the matrix to an OpenGL-style matrix.
void dump () const
 Writes the matrix's elements to the standard output (stdout).
Gel4x4Matrix operator+ (const Gel4x4Matrix &m) const
Gel4x4Matrix operator- (const Gel4x4Matrix &m) const
Gel4x4Matrix operator* (const Gel4x4Matrix &m) const
Gel4x4Matrix operator= (const Gel4x4Matrix &m)
Gel4x4Matrix operator+= (const Gel4x4Matrix &m)
Gel4x4Matrix operator-= (const Gel4x4Matrix &m)
Gel4x4Matrix operator*= (const Gel4x4Matrix &m)
bool operator== (const Gel4x4Matrix &m) const
bool operator!= (const Gel4x4Matrix &m) const
Gel3dVec operator* (const Gel3dVec &v) const
 Transforms a vector by this matrix.

Public Attributes

union {
   float   m [4][4]
   float   ms [16]
   struct {
      float   m11
      float   m12
      float   m13
      float   m14
      float   m21
      float   m22
      float   m23
      float   m24
      float   m31
      float   m32
      float   m33
      float   m34
      float   m41
      float   m42
      float   m43
      float   m44
   } 
}; 

Detailed Description

Square matrix for 3-dimensional transformations.

Although this class is fully functional, it has not been specifically optimized in any way. OpenGL's matrix multiplication is probably much faster than this.
This class exists solely for possible future needs. It currently has no applicable purposes in a 2D environment, at least as far as I can tell.


Constructor & Destructor Documentation

gel::Gel4x4Matrix::Gel4x4Matrix ( )

Default constructor.

Sets the matrix to its identity.

gel::Gel4x4Matrix::Gel4x4Matrix ( const float  matrix[16])

Convenience constructor.

Loads an OpenGL-style matrix.


Member Function Documentation

void gel::Gel4x4Matrix::loadNull ( )

Sets all matrix entries to zero.

void gel::Gel4x4Matrix::loadIdentity ( )

Resets the matrix to its identity.

void gel::Gel4x4Matrix::translate ( Gel3dVec  pos)

Translates the matrix.

Parameters:
pos: The vector to translate the matrix by.
void gel::Gel4x4Matrix::rotateX ( float  rot)

Rotates the matrix around the X axis.

Parameters:
rot: The number of degrees to rotate the matrix.
void gel::Gel4x4Matrix::rotateY ( float  rot)

Rotates the matrix around the Y axis.

Parameters:
rot: The number of degrees to rotate the matrix.
void gel::Gel4x4Matrix::rotateZ ( float  rot)

Rotates the matrix around the Z axis.

Parameters:
rot: The number of degrees to rotate the matrix.
void gel::Gel4x4Matrix::scale ( Gel3dVec  scl)

Scales the matrix.

Parameters:
scl: The vector to scale the matrix by.
void gel::Gel4x4Matrix::shear ( Gel2dVec  shx,
Gel2dVec  shy,
Gel2dVec  shz 
)

Shears the matrix.

Parameters:
shx: Shears X by Y and Z.
shy: Shears Y by X and Z.
shz: Shears Z by X and Y.
bool gel::Gel4x4Matrix::isIdentity ( ) const

Determines whether or not this is an identity matrix.

Returns:
True if this is an identity matrix, else false.
bool gel::Gel4x4Matrix::isTranslation ( ) const

Determines whether or not this is a pure translation matrix.

Returns:
True if this is a pure translation matrix, else false.
bool gel::Gel4x4Matrix::isRotation ( ) const

Determines whether or not this is a pure rotation matrix.

Returns:
True if this is a pure rotation matrix, else false.
bool gel::Gel4x4Matrix::isScaling ( ) const

Determines whether or not this is a pure scaling matrix.

Returns:
True if this is a pure scaling matrix, else false.
bool gel::Gel4x4Matrix::isShearing ( ) const

Determines whether or not this is a pure shearing matrix.

Returns:
True if this is a pure shearing matrix, else false.
void gel::Gel4x4Matrix::toOGLMatrix ( float  matrix[16]) const

Converts the matrix to an OpenGL-style matrix.

Parameters:
matrix: An array of 16 floats.
void gel::Gel4x4Matrix::dump ( ) const

Writes the matrix's elements to the standard output (stdout).

Gel4x4Matrix gel::Gel4x4Matrix::operator+ ( const Gel4x4Matrix m) const
Gel4x4Matrix gel::Gel4x4Matrix::operator- ( const Gel4x4Matrix m) const
Gel4x4Matrix gel::Gel4x4Matrix::operator* ( const Gel4x4Matrix m) const
Gel4x4Matrix gel::Gel4x4Matrix::operator= ( const Gel4x4Matrix m)
Gel4x4Matrix gel::Gel4x4Matrix::operator+= ( const Gel4x4Matrix m)
Gel4x4Matrix gel::Gel4x4Matrix::operator-= ( const Gel4x4Matrix m)
Gel4x4Matrix gel::Gel4x4Matrix::operator*= ( const Gel4x4Matrix m)
bool gel::Gel4x4Matrix::operator== ( const Gel4x4Matrix m) const
bool gel::Gel4x4Matrix::operator!= ( const Gel4x4Matrix m) const
Gel3dVec gel::Gel4x4Matrix::operator* ( const Gel3dVec v) const

Transforms a vector by this matrix.


Member Data Documentation

float gel::Gel4x4Matrix::m[4][4]
union { ... }

The documentation for this class was generated from the following file: