Main Page | Namespace List | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

PS2Math::Matrix44 Class Reference

Class to handle square 4x4 matrix This class is build not to handle a general 4x4 matrix but to work with linear function in omogeneous space. More...

#include <PS2Math.h>

List of all members.

Public Member Functions

 Matrix44 (bool Identity=false)
 Constructor 1, if Identity is true then an identity 4x4 matrix is created.

 Matrix44 (float Angle, MainAxis Axis)
 To build directly a RotationMatrix.

void Reset ()
 Reset function set all values of the matrix to 0.0f.

Matrix44AddRotation (float Angle, MainAxis Axis)
 Add a rotation to the current matrix.

Matrix44ViewLH (const Vector4 &Eye, const Vector4 &At, const Vector4 &Up)
 Set this instance of the matrix to a Left Handed View Matrix.

Matrix44ViewRH (const Vector4 &Eye, const Vector4 &At, const Vector4 &Up)
 Set this instance of the matrix to a Rigth Handed View Matrix.

Matrix44PerspectiveLH (float Width, float Height, float zNear, float zFar)
 Set this instance of the matrix to a Left Handed Projection Matrix.

Matrix44PerspectiveRH (float Width, float Height, float zNear, float zFar)
 Set this instance of the matrix to a Rigth Handed Projection Matrix.

Matrix44MapToViewPort (float xMin, float xMax, float yMin, float yMax, float zMin, float zMax)
 Map a projection matrix to a ViewPort, it is used to buld final projection matrix.

float *const  operator[] (int Index)
 Operator [] used to access row as array of float.

const float * operator[] (int Index) const
 Operator [] used to access row as array of float. (Const version).

Rotations member functions.
These functions are used to set or add a particular kind of rotation to the instance of the matrix.

Matrix44SetRotationX (float Angle)
 Set a rotation of desidered angle about X axis.

Matrix44SetRotationY (float Angle)
 Set a rotation of desidered angle about Y axis.

Matrix44SetRotationZ (float Angle)
 Set a rotation of desidered angle about Z axis.

Matrix44AddRotationX (float Angle)
 Add a rotation of desidered angle about X axis.

Matrix44AddRotationY (float Angle)
 Add a rotation of desidered angle about Y axis.

Matrix44AddRotationZ (float Angle)
 Add a rotation of desidered angle about Z axis.


Public Attributes

float elem [4][4]
 Array that contains the element of the matrix.


Detailed Description

Class Matrix44 has special member function to use rotation, translation and to set particular type of transformation as View transform, Projection transform of Viewport mapping transform. The use of operator overloading make simple and efficient the use of this class, all code is not optimized because this class has to be use as suppor for a tutorial and has to be simpliest as possible.

Definition at line 40 of file PS2Math.h.


Constructor & Destructor Documentation

Matrix44::Matrix44 bool  IdentityMatrix = false  ) 
 

Build a Matrix44 Object, an optional bool parameter is used to requests an identity matrix. If you want to set a View or Projection matrix you do not need to have an identity matrix so some time can be saved because elements of the matrix are not to be initialized.

Parameters:
IdentityMatrix Bool parameters used to ask the creation of Identity Matrix, if the parameter is false or if it's omitted, than the element of the matrix will have random values after the creation.

Definition at line 24 of file Matrix44.cpp.

Matrix44::Matrix44 float  Angle,
MainAxis  Axis
 

Sometimes there is the need to obtain immediatly a matrix that represent a rotation transform, this constructor is used to build directly a rotation matrix about one of the main three axixs.

Parameters:
Angle Angle of desidered rotation expressed in radiant.
Axis Member of MainAxis enum, does specify the axix of rotation.

Definition at line 43 of file Matrix44.cpp.


Member Function Documentation

Matrix44 & Matrix44::AddRotation float  Angle,
MainAxis  Axis
 

This member function is used to add a rotation about one of main axis to current transform expressed by the matrix. Code is simple, a temporary Matrix44 representing desidered rotation is created and then it is composed with current matrix. Remember that since column vector notation is used, to add a transformation to an existing matrix, it has to be premultiplicated by new transform. For this reason the Matrix44MultiplyR is used.

Parameters:
Angle The angle of rotation
MainAxis the axis of rotation
Returns:
A reference to the new matrix.

Definition at line 180 of file Matrix44.cpp.

Matrix44 & Matrix44::AddRotationX float  Angle  ) 
 

This member function is used to add a rotation about X axis to current transform expressed by the matrix. Code is simple, a temporary Matrix44 representing desidered rotation is created and then it is composed with current matrix. Remember that since column vector notation is used, to add a transformation to an existing matrix, it has to be premultiplicated by new transform. For this reason the Matrix44MultiplyR is used.

Parameters:
Angle The angle of rotation about X axis to add to current transform
Returns:
A reference to the new matrix.

Definition at line 128 of file Matrix44.cpp.

Matrix44 & Matrix44::AddRotationY float  Angle  ) 
 

This member function is used to add a rotation about Y axis to current transform expressed by the matrix. Code is simple, a temporary Matrix44 representing desidered rotation is created and then it is composed with current matrix. Remember that since column vector notation is used, to add a transformation to an existing matrix, it has to be premultiplicated by new transform. For this reason the Matrix44MultiplyR is used.

Parameters:
Angle The angle of rotation about Y axis to add to current transform
Returns:
A reference to the new matrix.

Definition at line 145 of file Matrix44.cpp.

Matrix44 & Matrix44::AddRotationZ float  Angle  ) 
 

This member function is used to add a rotation about Z axis to current transform expressed by the matrix. Code is simple, a temporary Matrix44 representing desidered rotation is created and then it is composed with current matrix. Remember that since column vector notation is used, to add a transformation to an existing matrix, it has to be premultiplicated by new transform. For this reason the Matrix44MultiplyR is used.

Parameters:
Angle The angle of rotation about Z axis to add to current transform
Returns:
A reference to the new matrix.

Definition at line 162 of file Matrix44.cpp.

Matrix44 & Matrix44::MapToViewPort float  xMin,
float  xMax,
float  yMin,
float  yMax,
float  zMin,
float  zMax
 

This method does a simple mapping to a given viewport. To know why the MapMatrix has this particular form, consult Appendix A of the tutorial in witch there is a full explanation on how to build a Projection Matrix.

Definition at line 302 of file Matrix44.cpp.

Matrix44 & Matrix44::PerspectiveLH float  Width,
float  Height,
float  zNear,
float  zFar
 

Build a perspective matrix left handed Consult appendix A of the tutorial to have furter details on how this matrix is build.

Parameters:
Width Width of the viewing frustum
Height Height of the viewing frustum
zNear Distance of the viewing frustum
zFar Far clipping plane of the viewing frustum

Definition at line 256 of file Matrix44.cpp.

Matrix44 & Matrix44::PerspectiveRH float  Width,
float  Height,
float  zNear,
float  zFar
 

Buld a Perspective Projection Matrix Rigth handed with the near plane of Viewing Frustum centered on direction of view. To have a complete explanation on how to build such a matrix, consult appendix A of the tutorial.

Parameters:
Width Width of near plane of viewing frustum
Height Height of near plane of viewing frustum
zNear Z-Value of near plane of viewing frustum
zFar Z-Value of far plane of viewing frustum
Returns:
A reference to current function, remember that this matrix has to mapped to viewport to obtain the full Projection matrix used to transform coordinates from 3D to 2D

Definition at line 280 of file Matrix44.cpp.

Matrix44 & Matrix44::SetRotationX float  Angle  ) 
 

If this member function is called then the matrix become a Rotation matrix about X axis, all preceeding content is deleted, and there is no prerequisites about values contained before this function is called, because element of the matrix are resetted as the first operation.

Parameters:
Angle Angle of desidered rotation expressed in radiant.
Returns:
A reference to the same matrix object, this is usually done to permit chain operation such as MyMatrix.SetRotationX(...).AddRotationY(...)

Definition at line 70 of file Matrix44.cpp.

Matrix44 & Matrix44::SetRotationY float  Angle  ) 
 

If this member function is called then the matrix become a Rotation matrix about Y axis, all preceeding content is deleted, and there is no prerequisites about values contained before this function is called, because element of the matrix are resetted as the first operation.

Parameters:
Angle Angle of desidered rotation expressed in radiant.
Returns:
A reference to the same matrix object, this is usually done to permit chain operation such as MyMatrix.SetRotationY(...).AddRotationX(...)

Definition at line 89 of file Matrix44.cpp.

Matrix44 & Matrix44::SetRotationZ float  Angle  ) 
 

If this member function is called then the matrix become a Rotation matrix about Z axis, all preceeding content is deleted, and there is no prerequisites about values contained before this function is called, because element of the matrix are resetted as the first operation.

Parameters:
Angle Angle of desidered rotation expressed in radiant.
Returns:
A reference to the same matrix object, this is usually done to permit chain operation such as MyMatrix.SetRotationZ(...).AddRotationX(...)

Definition at line 108 of file Matrix44.cpp.

Matrix44 & Matrix44::ViewLH const Vector4 Eye,
const Vector4 At,
const Vector4 Up
 

Build a Left Handed View Matrix used to translate geomety from World Coordinate System to Camera (View) Coordinate System. The

Parameters:
Eye A vector4 Object specifying the position of the eye of the camera.
At A vector4 Object specifying the point to look at
Up A vector4 Object specifying a general up direction for the matrix
Returns:
A reference to the current matrix.

Definition at line 207 of file Matrix44.cpp.


The documentation for this class was generated from the following files:
Generated on Wed Jan 7 19:12:21 2004 for PS2 Tutorial by doxygen 1.3.4