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

Ogre::Matrix4 Class Reference

Class encapsulating a standard 4x4 homogenous matrix. More...

#include <OgreMatrix4.h>

List of all members.

Public Methods

 Matrix4 ()
 Default constructor. More...

 Matrix4 (Real m00, Real m01, Real m02, Real m03, Real m10, Real m11, Real m12, Real m13, Real m20, Real m21, Real m22, Real m23, Real m30, Real m31, Real m32, Real m33)
Realoperator[] (unsigned iRow)
const Real *const operator[] (unsigned iRow) const
Matrix4 concatenate (const Matrix4 &m2)
Matrix4 operator * (const Matrix4 &m2)
 Matrix concatenation using '*'. More...

Vector3 operator * (const Vector3 &v) const
 Vector transformation using '*'. More...

Matrix4 operator+ (const Matrix4 &m2) const
 Matrix addition. More...

Matrix4 operator- (const Matrix4 &m2)
 Matrix subtraction. More...

bool operator== (const Matrix4 &m2) const
 Tests 2 matrices for equality. More...

bool operator!= (Matrix4 &m2) const
 Tests 2 matrices for inequality. More...

void operator= (const Matrix3 &mat3)
 Assignment from 3x3 matrix. More...

Matrix4 transpose (void)
void setTrans (const Vector3 &v)
 Sets the translation transformation part of the matrix. More...

void makeTrans (const Vector3 &v)
 Builds a translation matrix. More...

void makeTrans (Real tx, Real ty, Real tz)
void setScale (const Vector3 &v)
 Sets the scale part of the matrix. More...

void extract3x3Matrix (Matrix3 &m3x3)
 Extracts the rotation / scaling part of the Matrix as a 3x3 matrix. More...


Static Public Methods

Matrix4 getTrans (const Vector3 &v)
 Gets a translation matrix. More...

Matrix4 getTrans (Real t_x, Real t_y, Real t_z)
 Gets a translation matrix - variation for not using a vector. More...

Matrix4 getScale (const Vector3 &v)
 Gets a scale matrix. More...

Matrix4 getScale (Real s_x, Real s_y, Real s_z)
 Gets a scale matrix - variation for not using a vector. More...


Static Public Attributes

const Matrix4 ZERO
const Matrix4 IDENTITY

Friends

_OgreExport friend std::ostream & operator<< (std::ostream &o, const Matrix4 &m)
 Function for writing to a stream. More...


Detailed Description

Class encapsulating a standard 4x4 homogenous matrix.

Remarks:
OGRE uses column vectors when applying matrix multiplications, This means a vector is represented as a single column, 4-row matrix. This has the effect that the tranformations implemented by the matrices happens right-to-left e.g. if vector V is to be transformed by M1 then M2 then M3, the calculation would be M3 * M2 * M1 * V. The order that matrices are concatenated is vital since matrix multiplication is not cummatative, i.e. you can get a different result if you concatenate in the wrong order.

The use of column vectors and right-to-left ordering is the standard in most mathematical texts, and id the same as used in OpenGL. It is, however, the opposite of Direct3D, which has inexplicably chosen to differ from the accepted standard and uses row vectors and left-to-right matrix multiplication.

OGRE deals with the differences between D3D and OpenGL etc. internally when operating through different render systems. OGRE users only need to conform to standard maths conventions, i.e. right-to-left matrix multiplication, (OGRE transposes matrices it passes to D3D to compensate).

The generic form M * V which shows the layout of the matrix entries is shown below:

                [ m[0][0]  m[0][1]  m[0][2]  m[0][3] ]   {x}
                | m[1][0]  m[1][1]  m[1][2]  m[1][3] | * {y}
                | m[2][0]  m[2][1]  m[2][2]  m[2][3] |   {z}
                [ m[3][0]  m[3][1]  m[3][2]  m[3][3] ]   {1}
            


Constructor & Destructor Documentation

Ogre::Matrix4::Matrix4   [inline]
 

Default constructor.

Note:
It does NOT initialize the matrix for efficiency.

Ogre::Matrix4::Matrix4 Real    m00,
Real    m01,
Real    m02,
Real    m03,
Real    m10,
Real    m11,
Real    m12,
Real    m13,
Real    m20,
Real    m21,
Real    m22,
Real    m23,
Real    m30,
Real    m31,
Real    m32,
Real    m33
[inline]
 


Member Function Documentation

Matrix4 Ogre::Matrix4::concatenate const Matrix4 &    m2 [inline]
 

void Ogre::Matrix4::extract3x3Matrix Matrix3   m3x3 [inline]
 

Extracts the rotation / scaling part of the Matrix as a 3x3 matrix.

Parameters:
m3x3  Destination Matrix3

Matrix4 Ogre::Matrix4::getScale Real    s_x,
Real    s_y,
Real    s_z
[inline, static]
 

Gets a scale matrix - variation for not using a vector.

Matrix4 Ogre::Matrix4::getScale const Vector3   v [inline, static]
 

Gets a scale matrix.

Matrix4 Ogre::Matrix4::getTrans Real    t_x,
Real    t_y,
Real    t_z
[inline, static]
 

Gets a translation matrix - variation for not using a vector.

Matrix4 Ogre::Matrix4::getTrans const Vector3   v [inline, static]
 

Gets a translation matrix.

void Ogre::Matrix4::makeTrans Real    tx,
Real    ty,
Real    tz
[inline]
 

void Ogre::Matrix4::makeTrans const Vector3   v [inline]
 

Builds a translation matrix.

Vector3 Ogre::Matrix4::operator * const Vector3   v const [inline]
 

Vector transformation using '*'.

Remarks:
Transforms the given 3-D vector by the matrix, projecting the result back into w = 1.
Note:
This means that the initial w is considered to be 1.0, and then all the tree elements of the resulting 3-D vector are divided by the resulting w.

Matrix4 Ogre::Matrix4::operator * const Matrix4 &    m2 [inline]
 

Matrix concatenation using '*'.

bool Ogre::Matrix4::operator!= Matrix4 &    m2 const [inline]
 

Tests 2 matrices for inequality.

Matrix4 Ogre::Matrix4::operator+ const Matrix4 &    m2 const [inline]
 

Matrix addition.

Matrix4 Ogre::Matrix4::operator- const Matrix4 &    m2 [inline]
 

Matrix subtraction.

void Ogre::Matrix4::operator= const Matrix3   mat3 [inline]
 

Assignment from 3x3 matrix.

bool Ogre::Matrix4::operator== const Matrix4 &    m2 const [inline]
 

Tests 2 matrices for equality.

const Real* const Ogre::Matrix4::operator[] unsigned    iRow const [inline]
 

Real* Ogre::Matrix4::operator[] unsigned    iRow [inline]
 

void Ogre::Matrix4::setScale const Vector3   v [inline]
 

Sets the scale part of the matrix.

void Ogre::Matrix4::setTrans const Vector3   v [inline]
 

Sets the translation transformation part of the matrix.

Matrix4 Ogre::Matrix4::transpose void    [inline]
 


Friends And Related Function Documentation

_OgreExport friend std::ostream& operator<< std::ostream &    o,
const Matrix4 &    m
[friend]
 

Function for writing to a stream.


Member Data Documentation

Real Ogre::Matrix4::_m[16] [protected]
 

const Matrix4 Ogre::Matrix4::IDENTITY [static]
 

Real Ogre::Matrix4::m[4][4] [protected]
 

const Matrix4 Ogre::Matrix4::ZERO [static]
 

Copyright © 2002 by The OGRE Team