Visit Cem Yuksel's web site

Files

Class List

Class Members

Class Hierarchy

cyMatrix4f Class Reference

#include <cyMatrix4.h>

List of all members.


Detailed Description

4x4 matrix class.

Its data stores 16-value array of column-major matrix elements. I chose column-major format to be compatible with OpenGL You can use cyMatrix4f with cyPoint3f and cyPoint4f to transform 3D and 4D points. Both post-multiplication and pre-multiplication are supported.


Other Public Methods

void SetTranspose ()
 Transpose this matrix.
cyMatrix4f Transpose () const
 return Transpose of this matrix
void Invert ()
 Invert this matrix.
void GetInverse (cyMatrix4f &inverse)
 Get the inverse of this matrix.
cyMatrix4f GetInverse ()
 Get the inverse of this matrix.

Public Member Functions

Constructors
 cyMatrix4f ()
 Default constructor.
 cyMatrix4f (const cyMatrix4f &matrix)
 Copy constructor.
Set & Get Methods
void Zero ()
 Set all the values as zero.
void Set (const float *array)
 Set Matrix using an array of 16 values.
void Set (const cyPoint3f &x, const cyPoint3f &y, const cyPoint3f &z, const cyPoint3f &pos)
 Set Matrix using x,y,z vectors and coordinate center.
void Set (const cyPoint4f &x, const cyPoint4f &y, const cyPoint4f &z, const cyPoint4f &w)
 Set Matrix using x,y,z,w vectors.
void Set (const cyPoint3f &pos, const cyPoint3f &normal, cyPoint3f &dir)
 Set Matrix using position, normal, and approximate x direction.
void SetIdentity ()
 Converts the matrix to an identity matrix.
void SetView (const cyPoint3f &pos, const cyPoint3f &target, cyPoint3f &up)
 Set View Matrix using position, target and approximate up vector.
void SetNormal (const cyPoint3f &normal, cyPoint3f &dir)
 Set Matrix using normal, and approximate x direction.
void SetRotationX (float theta)
 Set as rotation matrix around x axis.
void SetRotationY (float theta)
 Set as rotation matrix around y axis.
void SetRotationZ (float theta)
 Set as rotation matrix around z axis.
void SetRotation (cyPoint3f axis, float theta)
 Set a rotation matrix about the given axis by angle theta.
void SetRotation (cyPoint3f axis, float cosTheta, float sinTheta)
 Set a rotation matrix about the given axis by cos and sin of angle theta.
void SetRotation (cyPoint3f from, cyPoint3f to)
 Set a rotation matrix that sets <from> unit vector to <to> unit vector.
void SetTrans (cyPoint3f move)
 Set translation matrix.
cyPoint4f GetRow (int row) const
 Set all the values as zero.
void GetRow (int row, cyPoint4f &p) const
 Set all the values as zero.
void GetRow (int row, float *array) const
 Set all the values as zero.
cyPoint4f GetColumn (int col) const
 Set all the values as zero.
void GetColumn (int col, cyPoint4f &p) const
 Set all the values as zero.
void GetColumn (int col, float *array) const
 Set all the values as zero.
Overloaded Operators
const cyMatrix4foperator= (const cyMatrix4f &)
 assign matrix
bool operator== (const cyMatrix4f &) const
 compare equal
bool operator!= (const cyMatrix4f &right) const
 compare not equal
float & operator() (int row, int column)
 subscript operator
float & operator[] (int i)
 subscript operator
const float & operator() (int row, int column) const
 constant subscript operator
const float & operator[] (int i) const
 constant subscript operator
cyMatrix4f operator- () const
 negative matrix
cyMatrix4f operator+ (const cyMatrix4f &) const
 add two Matrices
cyMatrix4f operator- (const cyMatrix4f &) const
 subtract one cyMatrix4f from an other
cyMatrix4f operator * (const cyMatrix4f &) const
 multiply a matrix with an other
cyMatrix4f operator+ (const float) const
 add a value to a matrix
cyMatrix4f operator- (const float) const
 subtract a value from a matrix
cyMatrix4f operator * (const float) const
 multiple matrix by a value
cyMatrix4f operator/ (const float) const
 divide matrix by a value;
cyPoint3f operator * (const cyPoint3f &p) const
 assign matrix
cyPoint4f operator * (const cyPoint4f &p) const
 assign matrix
void operator+= (const cyMatrix4f &)
 add two Matrices modify this
void operator-= (const cyMatrix4f &)
 subtract one cyMatrix4f from an other modify this matrix
void operator *= (const cyMatrix4f &)
 multiply a matrix with an other modify this matrix
void operator+= (const float)
 add a value to a matrix modify this
void operator-= (const float)
 subtract a value from a matrix modify this matrix
void operator *= (const float)
 multiply a matrix with a value modify this matrix
void operator/= (const float)
 divide the matrix by a value modify the this matrix

Public Attributes

float data [16]
 elements of the matrix are column-major as in OpenGL

Friends

cyMatrix4f operator+ (const float, const cyMatrix4f &)
 add a value to a matrix
cyMatrix4f operator- (const float, const cyMatrix4f &)
 subtract the matrix from a value
cyMatrix4f operator * (const float, const cyMatrix4f &)
 multiple matrix by a value
cyMatrix4f Inverse (cyMatrix4f &m)
 return the inverse of the matrix
cyPoint3f operator * (const cyPoint3f &, const cyMatrix4f &)
 pre-multiply with a 3D point
cyPoint4f operator * (const cyPoint4f &, const cyMatrix4f &)
 pre-multiply with a 4D point

Visit Cem Yuksel's website!