Gel2D - The free/open source game creation suite

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

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

#include <gelMatrix.h>

List of all members.

Public Member Functions

 Gel3x3Matrix ()
 Default constructor.
 Gel3x3Matrix (const float matrix[16])
 Convenience constructor.
void loadNull ()
 Sets all matrix entries to zero.
void loadIdentity ()
 Resets the matrix to its identity.
void translate (Gel2dVec pos)
 Translates the matrix.
void rotate (float rot)
 Rotates the matrix.
void rotateRad (float rot)
 Rotates the matrix.
void scale (Gel2dVec scl)
 Scales the matrix.
void shear (float shx, float shy)
 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).
Gel3x3Matrix operator+ (const Gel3x3Matrix &m) const
Gel3x3Matrix operator- (const Gel3x3Matrix &m) const
Gel3x3Matrix operator* (const Gel3x3Matrix &m) const
Gel3x3Matrix operator= (const Gel3x3Matrix &m)
Gel3x3Matrix operator+= (const Gel3x3Matrix &m)
Gel3x3Matrix operator-= (const Gel3x3Matrix &m)
Gel3x3Matrix operator*= (const Gel3x3Matrix &m)
bool operator== (const Gel3x3Matrix &m) const
bool operator!= (const Gel3x3Matrix &m) const
Gel2dVec operator* (const Gel2dVec &v) const
 Transforms a vector by this matrix.

Public Attributes

union {
   float   m [3][3]
   struct {
      float   m11
      float   m12
      float   m13
      float   m21
      float   m22
      float   m23
      float   m31
      float   m32
      float   m33
   } 
}; 

Detailed Description

Square matrix for 2-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.


Constructor & Destructor Documentation

gel::Gel3x3Matrix::Gel3x3Matrix ( )

Default constructor.

Sets the matrix to its identity.

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

Convenience constructor.

Loads an OpenGL-style matrix.


Member Function Documentation

void gel::Gel3x3Matrix::loadNull ( )

Sets all matrix entries to zero.

void gel::Gel3x3Matrix::loadIdentity ( )

Resets the matrix to its identity.

void gel::Gel3x3Matrix::translate ( Gel2dVec  pos)

Translates the matrix.

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

Rotates the matrix.

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

Rotates the matrix.

Parameters:
rot: The amount of rotation in radians.
void gel::Gel3x3Matrix::scale ( Gel2dVec  scl)

Scales the matrix.

Parameters:
scl: The vector to scale the matrix by.
void gel::Gel3x3Matrix::shear ( float  shx,
float  shy 
)

Shears the matrix.

Parameters:
shx: The amount of shear along the X axis.
shy: The amount of shear along the Y axis.
bool gel::Gel3x3Matrix::isIdentity ( ) const

Determines whether or not this is an identity matrix.

Returns:
True if this is an identity matrix, else false.
bool gel::Gel3x3Matrix::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::Gel3x3Matrix::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::Gel3x3Matrix::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::Gel3x3Matrix::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::Gel3x3Matrix::toOGLMatrix ( float  matrix[16]) const

Converts the matrix to an OpenGL-style matrix.

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

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

Gel3x3Matrix gel::Gel3x3Matrix::operator+ ( const Gel3x3Matrix m) const
Gel3x3Matrix gel::Gel3x3Matrix::operator- ( const Gel3x3Matrix m) const
Gel3x3Matrix gel::Gel3x3Matrix::operator* ( const Gel3x3Matrix m) const
Gel3x3Matrix gel::Gel3x3Matrix::operator= ( const Gel3x3Matrix m)
Gel3x3Matrix gel::Gel3x3Matrix::operator+= ( const Gel3x3Matrix m)
Gel3x3Matrix gel::Gel3x3Matrix::operator-= ( const Gel3x3Matrix m)
Gel3x3Matrix gel::Gel3x3Matrix::operator*= ( const Gel3x3Matrix m)
bool gel::Gel3x3Matrix::operator== ( const Gel3x3Matrix m) const
bool gel::Gel3x3Matrix::operator!= ( const Gel3x3Matrix m) const
Gel2dVec gel::Gel3x3Matrix::operator* ( const Gel2dVec v) const

Transforms a vector by this matrix.


Member Data Documentation

float gel::Gel3x3Matrix::m[3][3]
union { ... }

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