Matrix< T > Class Template Reference

A 3x3 matrix class suited for 2D graphics. More...

#include <Math/Matrix.h>

List of all members.

Public Member Functions

void MakeZero ()
 Sets all of the matrix fields to 0.
void MakeIdentity ()
 Sets the matrix to the identity matrix.
void MakeTranslation (T x, T y)
 Turns the matrix into a translation matrix.
void MakeScale (T x, T y)
 Turns the matrix into a scale matrix.
void MakeRotation (T angle)
 Turns the matrix into a rotation matrix about the z-axis (suitable for 2D graphics).
Det () const
 Computes the determinent of the matrix.
bool Invert ()
 Inverts the matrix if possible.
Point2< T > Transform (const Point2< T > &p) const
 Transforms the given 2D point by the matrix taking the z commpont of the point to be 1.
Vector2< T > Transform (const Vector2< T > &v) const
 Transforms the given 2D vector by the matrix taking the z commpont of the point to be 0.
Matrix operator+ (const Matrix &b) const
 Overloaded matrix addition operator.
Matrix operator* (const Matrix &b) const
 Overloaded matrix multiplicatioin operator.
Matrix operator* (T k) const
 Overloaded matrix-constant multiplication operator.
void GetOpenGLMatrix (T m[16]) const
 Converts the matrix to a form suitible for OpenGL.

Public Attributes

union {
}; 

Friends

Matrix operator* (T k, const Matrix &a)
 Overloaded constant-matrix multiplication operator.

Detailed Description

template<class T>
class Matrix< T >

A 3x3 matrix class suited for 2D graphics.

All Matrix methods and operations are assumed to be using a left-handed coordinate system unless otherwise noted.

Template Parameters:
T the data type of the matrix data. Usually float or double.

Member Function Documentation

template<class T>
T Matrix< T >::Det (  )  const [inline]

Computes the determinent of the matrix.

Returns:
The determinent.
template<class T>
void Matrix< T >::GetOpenGLMatrix ( m[16]  )  const [inline]

Converts the matrix to a form suitible for OpenGL.

Parameters:
[in] m a 16 element array in the form OpenGL expects.
template<class T>
bool Matrix< T >::Invert (  )  [inline]

Inverts the matrix if possible.

Returns:
True if the inverise exists. False is the inverse doesn't exits, in which case the matrix was not changed.
template<class T>
void Matrix< T >::MakeRotation ( angle  )  [inline]

Turns the matrix into a rotation matrix about the z-axis (suitable for 2D graphics).

Parameters:
[in] angle the angle to rotate by in radians.
template<class T>
void Matrix< T >::MakeScale ( x,
y 
) [inline]

Turns the matrix into a scale matrix.

Parameters:
[in] x the amount to scale by in the x direction.
[in] y the amount to scale by in the y direction.
template<class T>
void Matrix< T >::MakeTranslation ( x,
y 
) [inline]

Turns the matrix into a translation matrix.

Parameters:
[in] x the x position to translate to.
[in] y the y position to translate to.
template<class T>
Matrix Matrix< T >::operator* ( k  )  const [inline]

Overloaded matrix-constant multiplication operator.

Parameters:
[in] k the constaant to multiply by.
Returns:
The matrix result of multiplying this matrix by k.
template<class T>
Matrix Matrix< T >::operator* ( const Matrix< T > &  b  )  const [inline]

Overloaded matrix multiplicatioin operator.

Parameters:
[in] b the matrix to multiply by.
Returns:
The matrix result of multiply this matrix by b.
template<class T>
Matrix Matrix< T >::operator+ ( const Matrix< T > &  b  )  const [inline]

Overloaded matrix addition operator.

Parameters:
[in] b the matrix to add to.
Returns:
The result of adding b to this matrix.
template<class T>
Vector2<T> Matrix< T >::Transform ( const Vector2< T > &  v  )  const [inline]

Transforms the given 2D vector by the matrix taking the z commpont of the point to be 0.

Parameters:
[in] v the vector to transform.
Returns:
The transformed vector.
template<class T>
Point2<T> Matrix< T >::Transform ( const Point2< T > &  p  )  const [inline]

Transforms the given 2D point by the matrix taking the z commpont of the point to be 1.

Parameters:
[in] p the point to transform.
Returns:
The transformed point.

Friends And Related Function Documentation

template<class T>
Matrix operator* ( k,
const Matrix< T > &  a 
) [friend]

Overloaded constant-matrix multiplication operator.

Parameters:
[in] k the constant to multiply by.
[in] a the matrix to multiply by.
Returns:
The matrix result of multiplying k by a.

Member Data Documentation

union { ... }

Data can be accessed either by name as _RC where R and C are in the range [1,3], or by array access as m[R][C] where R and C are in the range [0,2].


The documentation for this class was generated from the following file:
Generated on Mon Apr 5 19:08:06 2010 for BrickOut |ReDuX| by  doxygen 1.6.3