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

Teddy::Maths::Matrix Class Reference

4x4 Matrix. More...

#include <Matrix.h>

Collaboration diagram for Teddy::Maths::Matrix:

Collaboration graph
[legend]
List of all members.

Public Methods

 Matrix ()
 Matrix (const float f)
 Matrix (const float *pf)
 Matrix (const Quaternion &q)
void zeroMatrix ()
 operator float * ()
float & operator() (const int i, const int j)
 operator const float * () const
float operator() (const int i, const int j) const
void operator= (const float k)
void operator= (const float *pf)
void operator= (const Quaternion &q)
Matrix operator- () const
Matrix operator * (const Matrix &mat) const
const Matrix & operator *= (const Matrix &mat)
Vector operator * (const Vector &vec) const
Vector4 operator * (const Vector4 &vec) const
Vector transformVector (const Vector &vec) const
Vector4 transformVector4 (const Vector4 &vec) const
Vector4 getRow (const int i) const
Vector4 getColumn (const int i) const
void setRow (const int i, const Vector4 &v)
void setColumn (const int i, const Vector4 &v)
Vector get3Row (const int i) const
Vector get3Column (const int i) const
void set3Row (const int i, const Vector &v)
void set3Column (const int i, const Vector &v)
Vector uniformTransformNormal (const Vector &vec) const
 
Warning:
Only works with uniform transformation matrices.
More...


void modelMatrix (const Quaternion &q, const Vector &vFrom)
void translateMatrix (const TVector< double > &v)
void translateMatrix (const Vector &v)
void translateMatrix (const float x, const float y, const float z)
void translate (const float x, const float y, const float z)
void translate (const float *pf)
void scaleMatrix (const float x, const float y, const float z)
void scaleMatrix (const float *pf)
void scale (const float x, const float y, const float z)
void scale (const float *pf)
void rotateXMatrix (const float radians)
void rotateX (const float radians)
void rotateYMatrix (const float radians)
void rotateY (const float radians)
void rotateZMatrix (const float radians)
void rotateZ (const float radians)
void rotateMatrix (const Vector &vec, const double radians)
void rotate (const Vector &vec, const double f)
void direction (const Vector &vec)
bool invert ()
void transpose ()

Public Attributes

float m [4][4]

Static Public Attributes

const Matrix IDENTITY
const Matrix SWAP_XY
const Matrix SWAP_XZ
const Matrix SWAP_YZ
const Matrix MIRROR_X
const Matrix MIRROR_Y
const Matrix MIRROR_Z

Detailed Description

4x4 Matrix.

Author:
Sean O'Neil

This class implements a 4x4 matrix. Several functions and operators are defined to make working with matrices easier. The values are kept in column- major order to make it easier to use with OpenGL. For performance reasons, most of the functions assume that all matrices are orthogonal, which means the bottom row is [ 0 0 0 1 ]. Since I plan to use the GL_PROJECTION matrix to handle the projection matrix, I should never need to use any other kind of matrix, and I get a decent performance boost by ignoring the bottom row.

Note: This class is not templatized because integral data types don't make sense and there's no need for double-precision.

Definition at line 69 of file Matrix.h.


Constructor & Destructor Documentation

Teddy::Maths::Matrix::Matrix   [inline]
 

Definition at line 86 of file Matrix.h.

Referenced by operator *, operator *=, operator-, and rotate.

Teddy::Maths::Matrix::Matrix const float    f [inline]
 

Definition at line 87 of file Matrix.h.

Teddy::Maths::Matrix::Matrix const float *    pf [inline]
 

Definition at line 88 of file Matrix.h.

Teddy::Maths::Matrix::Matrix const Quaternion   q [inline]
 

Definition at line 89 of file Matrix.h.


Member Function Documentation

void Teddy::Maths::Matrix::direction const Vector &    vec [inline]
 

Definition at line 428 of file Matrix.h.

References setRow, Vector, and Vector4.

Vector Teddy::Maths::Matrix::get3Column const int    i const [inline]
 

Definition at line 164 of file Matrix.h.

References m, and Vector.

Vector Teddy::Maths::Matrix::get3Row const int    i const [inline]
 

Definition at line 163 of file Matrix.h.

References m, and Vector.

Vector4 Teddy::Maths::Matrix::getColumn const int    i const [inline]
 

Definition at line 160 of file Matrix.h.

References m, and Vector4.

Referenced by invert.

Vector4 Teddy::Maths::Matrix::getRow const int    i const [inline]
 

Definition at line 159 of file Matrix.h.

References m, and Vector4.

bool Teddy::Maths::Matrix::invert   [inline]
 

Definition at line 449 of file Matrix.h.

References CrossVector4, getColumn, setRow, and Vector4.

void Teddy::Maths::Matrix::modelMatrix const Quaternion   q,
const Vector &    vFrom
[inline]
 

Definition at line 182 of file Matrix.h.

References m, and Vector.

Vector4 Teddy::Maths::Matrix::operator * const Vector4   vec const [inline]
 

Definition at line 136 of file Matrix.h.

References transformVector4, and Vector4.

Vector Teddy::Maths::Matrix::operator * const Vector &    vec const [inline]
 

Definition at line 135 of file Matrix.h.

References transformVector, and Vector.

Matrix Teddy::Maths::Matrix::operator * const Matrix &    mat const
 

Definition at line 116 of file Matrix.cpp.

References m, and Matrix.

const Matrix& Teddy::Maths::Matrix::operator *= const Matrix &    mat [inline]
 

Definition at line 134 of file Matrix.h.

References Matrix.

Teddy::Maths::Matrix::operator const float *   const [inline]
 

Definition at line 101 of file Matrix.h.

References m.

Teddy::Maths::Matrix::operator float *   [inline]
 

Definition at line 99 of file Matrix.h.

References m.

float Teddy::Maths::Matrix::operator() const int    i,
const int    j
const [inline]
 

Definition at line 102 of file Matrix.h.

References m.

float& Teddy::Maths::Matrix::operator() const int    i,
const int    j
[inline]
 

Definition at line 100 of file Matrix.h.

References m.

Matrix Teddy::Maths::Matrix::operator-   const [inline]
 

Definition at line 122 of file Matrix.h.

References m, and Matrix.

void Teddy::Maths::Matrix::operator= const Quaternion   q
 

Definition at line 97 of file Matrix.cpp.

References m.

void Teddy::Maths::Matrix::operator= const float *    pf [inline]
 

Definition at line 112 of file Matrix.h.

References m.

void Teddy::Maths::Matrix::operator= const float    k [inline]
 

Definition at line 104 of file Matrix.h.

References m.

void Teddy::Maths::Matrix::rotate const Vector &    vec,
const double    f
[inline]
 

Definition at line 421 of file Matrix.h.

References Matrix, and Vector.

void Teddy::Maths::Matrix::rotateMatrix const Vector &    vec,
const double    radians
[inline]
 

Definition at line 398 of file Matrix.h.

References m, and Vector.

void Teddy::Maths::Matrix::rotateX const float    radians [inline]
 

Definition at line 303 of file Matrix.h.

References cosf, m, and sinf.

void Teddy::Maths::Matrix::rotateXMatrix const float    radians [inline]
 

Definition at line 285 of file Matrix.h.

References cosf, m, and sinf.

void Teddy::Maths::Matrix::rotateY const float    radians [inline]
 

Definition at line 341 of file Matrix.h.

References cosf, m, and sinf.

void Teddy::Maths::Matrix::rotateYMatrix const float    radians [inline]
 

Definition at line 324 of file Matrix.h.

References cosf, m, and sinf.

void Teddy::Maths::Matrix::rotateZ const float    radians [inline]
 

Definition at line 378 of file Matrix.h.

References cosf, m, and sinf.

void Teddy::Maths::Matrix::rotateZMatrix const float    radians [inline]
 

Definition at line 360 of file Matrix.h.

References cosf, m, and sinf.

void Teddy::Maths::Matrix::scale const float *    pf [inline]
 

Definition at line 280 of file Matrix.h.

References scale.

void Teddy::Maths::Matrix::scale const float    x,
const float    y,
const float    z
[inline]
 

Definition at line 269 of file Matrix.h.

References m.

Referenced by scale.

void Teddy::Maths::Matrix::scaleMatrix const float *    pf [inline]
 

Definition at line 265 of file Matrix.h.

References scaleMatrix.

void Teddy::Maths::Matrix::scaleMatrix const float    x,
const float    y,
const float    z
[inline]
 

Definition at line 250 of file Matrix.h.

References m.

Referenced by scaleMatrix.

void Teddy::Maths::Matrix::set3Column const int    i,
const Vector &    v
[inline]
 

Definition at line 166 of file Matrix.h.

References m, and Vector.

void Teddy::Maths::Matrix::set3Row const int    i,
const Vector &    v
[inline]
 

Definition at line 165 of file Matrix.h.

References m, and Vector.

void Teddy::Maths::Matrix::setColumn const int    i,
const Vector4   v
[inline]
 

Definition at line 162 of file Matrix.h.

References m, and Vector4.

void Teddy::Maths::Matrix::setRow const int    i,
const Vector4   v
[inline]
 

Definition at line 161 of file Matrix.h.

References m, and Vector4.

Referenced by direction, and invert.

Vector Teddy::Maths::Matrix::transformVector const Vector &    vec const [inline]
 

Definition at line 138 of file Matrix.h.

References m, and Vector.

Referenced by operator *.

Vector4 Teddy::Maths::Matrix::transformVector4 const Vector4   vec const [inline]
 

Definition at line 150 of file Matrix.h.

References m, and Vector4.

Referenced by operator *.

void Teddy::Maths::Matrix::translate const float *    pf [inline]
 

Definition at line 245 of file Matrix.h.

References translate.

void Teddy::Maths::Matrix::translate const float    x,
const float    y,
const float    z
[inline]
 

Definition at line 234 of file Matrix.h.

References m.

Referenced by translate.

void Teddy::Maths::Matrix::translateMatrix const float    x,
const float    y,
const float    z
[inline]
 

Definition at line 218 of file Matrix.h.

References m.

void Teddy::Maths::Matrix::translateMatrix const Vector &    v [inline]
 

Definition at line 203 of file Matrix.h.

References m, and Vector.

void Teddy::Maths::Matrix::translateMatrix const TVector< double > &    v [inline]
 

Definition at line 189 of file Matrix.h.

References m.

void Teddy::Maths::Matrix::transpose   [inline]
 

Definition at line 480 of file Matrix.h.

References m.

Referenced by Teddy::Scenes::Camera::updatePlanes.

Vector Teddy::Maths::Matrix::uniformTransformNormal const Vector &    vec const [inline]
 

Warning:
Only works with uniform transformation matrices.

Definition at line 169 of file Matrix.h.

References m, and Vector.

void Teddy::Maths::Matrix::zeroMatrix   [inline]
 

Definition at line 92 of file Matrix.h.

References m.


Member Data Documentation

const Matrix Teddy::Maths::Matrix::IDENTITY [static]
 

float Teddy::Maths::Matrix::m[4][4]
 

Definition at line 84 of file Matrix.h.

Referenced by get3Column, get3Row, getColumn, getRow, modelMatrix, operator *, operator const float *, operator float *, operator(), operator-, operator=, rotateMatrix, rotateX, rotateXMatrix, rotateY, rotateYMatrix, rotateZ, rotateZMatrix, scale, scaleMatrix, set3Column, set3Row, setColumn, setRow, transformVector, transformVector4, translate, translateMatrix, transpose, uniformTransformNormal, and zeroMatrix.

const Matrix Teddy::Maths::Matrix::MIRROR_X [static]
 

const Matrix Teddy::Maths::Matrix::MIRROR_Y [static]
 

const Matrix Teddy::Maths::Matrix::MIRROR_Z [static]
 

const Matrix Teddy::Maths::Matrix::SWAP_XY [static]
 

const Matrix Teddy::Maths::Matrix::SWAP_XZ [static]
 

const Matrix Teddy::Maths::Matrix::SWAP_YZ [static]
 


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