Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes

sp::dim::matrix4< T > Class Template Reference

#include <spDimensionMatrix4.hpp>

List of all members.

Public Member Functions

 matrix4 ()
 matrix4 (const T(&Other)[16])
 matrix4 (const matrix4< T > &Other)
 matrix4 (const matrix3< T > &Other)
 matrix4 (const obbox3d< T > &Box)
 matrix4 (T m1n1, T m2n1, T m3n1, T m4n1, T m1n2, T m2n2, T m3n2, T m4n2, T m1n3, T m2n3, T m3n3, T m4n3, T m1n4, T m2n4, T m3n4, T m4n4)
 matrix4 (const vector4d< T > &XDirection, const vector4d< T > &YDirection, const vector4d< T > &ZDirection, const vector4d< T > &Position)
 ~matrix4 ()
const T operator() (u32 row, u32 col) const
T & operator() (u32 row, u32 col)
const T operator[] (u32 i) const
 Returns the matrix component value at the specified offset (or rather index) 'i'.
T & operator[] (u32 i)
bool operator== (const matrix4< T > &Other)
bool operator!= (const matrix4< T > &Other)
matrix4< T > & operator= (const T(&Other)[16])
matrix4< T > & operator= (const matrix4< T > &Other)
matrix4< T > & operator= (T Scalar)
matrix4< T > operator+ (const matrix4< T > &mltMatrix) const
matrix4< T > & operator+= (const matrix4< T > &mltMatrix)
matrix4< T > operator- (const matrix4< T > &mltMatrix) const
matrix4< T > & operator-= (const matrix4< T > &mltMatrix)
matrix4< T > operator* (const matrix4< T > &mltMatrix) const
matrix4< T > operator* (T Scalar) const
matrix4< T > & operator*= (const matrix4< T > &mltMatrix)
matrix4< T > & operator*= (T Scalar)
vector3d< T > operator* (const vector3d< T > &Vector) const
point2d< T > operator* (const point2d< T > &Vector) const
triangle3d< T > operator* (const triangle3d< T > &Triangle) const
triangle3d< T > operator* (const triangle3d< T, vector3d< T > * > &Triangle) const
plane3d< T > operator* (const plane3d< T > &Plane) const
obbox3d< T > operator* (const obbox3d< T > &Box) const
line3d< T > operator* (const line3d< T > &Line) const
point2d< T > vecRotate (const point2d< T > &Vector) const
 Returns the rotated specified vector. i.e. the vector will be multiplied with the 2x2 matrix.
point2d< T > vecRotateInverse (const point2d< T > &Vector) const
 Returns the rotated specified vector. i.e. the vector will be multiplied with the inversed 2x2 matrix.
vector3d< T > vecRotate (const vector3d< T > &Vector) const
 Returns the rotated specified vector. i.e. the vector will be multiplied with the 3x3 matrix.
vector3d< T > vecRotateInverse (const vector3d< T > &Vector) const
 Returns the inverse rotated specified vector. i.e. the vector will be multiplied with the inversed 3x3 matrix.
void clear ()
 Clear the matrix. i.e. each component is set to 0.
matrix4< T > & reset ()
matrix4< T > & reset (const vector3d< T > &InitPosition, const vector3d< T > &InitScale=T(1))
void multiplySingleMatrix (const T(&Other)[4])
 Multiplies this matrix with a 1x4 matrix.
void matrixLookAt (const vector3d< T > &Position, const vector3d< T > &LookAt, const vector3d< T > &upVector)
bool getInverse (matrix4< T > &InverseMat) const
bool setInverse ()
matrix4< T > getInverse () const
matrix4< T > & translate (const vector3d< T > &Vector)
matrix4< T > & scale (const vector3d< T > &Vector)
matrix4< T > & rotate (const T Angle, vector3d< T > Rotation)
matrix4< T > & rotateX (const T Angle)
matrix4< T > & rotateY (const T Angle)
matrix4< T > & rotateZ (const T Angle)
void rotateYXZ (const vector3df &Rotation)
void rotateZXY (const vector3df &Rotation)
void setRotation (vector3d< T > Rotation, bool UseDegrees=true)
void setInverseRotation (vector3df Rotation, bool UseDegrees=true)
void setTextureRotation (const T &Degree)
void setPerspectiveLH (T FieldOfView, T Aspect, T Near, T Far)
void setPerspectiveRH (T FieldOfView, T Aspect, T Near, T Far)
void setOrthoLH (T Left, T Right, T Top, T Bottom, T Near, T Far)
void setOrthoRH (T Left, T Right, T Top, T Bottom, T Near, T Far)
void make2Dimensional (s32 Width, s32 Height, s32 ScreenWidth, s32 ScreenHeight)
void makeViewport (const rect2di &Viewport, const f32 DepthScale=1.0f)
vector4d< T > getRow (s32 Position) const
void setRow (s32 Position, const vector4d< T > &Vec)
vector4d< T > getColumn (s32 Position) const
void setColumn (s32 Position, const vector4d< T > &Vec)
void setPosition (const vector3d< T > &Position)
vector3d< T > getPosition () const
void setScale (const vector3d< T > &Scale)
vector3d< T > getScale () const
 Returns the matrix scaling vector.
vector3d< T > getRotation () const
matrix4< T > getRotationMatrix () const
matrix4< T > getPositionMatrix () const
matrix4< T > getPositionScaleMatrix () const
matrix4< T > getPositionRotationMatrix () const
matrix4< T > getTransposed () const
void getTransposed (matrix4< T > &Other) const
matrix4< T > getTextureMatrix () const
matrix4< T > interpolate (const matrix4< T > &Other, f32 seek) const
bool isIdentity () const
bool equal (const matrix4< T > &Other) const
const T * getArray () const
T * getArray ()
matrix3< T > get3x3 () const
matrix2< T > get2x2 () const
template<typename B >
matrix4< B > cast () const

Static Public Member Functions

static vector3d< T > getProjection (const vector3d< T > ObjectPosition, const rect2di &Viewport, const matrix4< T > &ProjectionMatrix, const matrix4< T > &ModelviewMatrix)

Public Attributes

M [16]
 The matrix memory buffer.

Static Public Attributes

static const matrix4< T > IDENTITY
 Identity 4x4 matrix.

Detailed Description

template<typename T>
class sp::dim::matrix4< T >

This is the 4x4 matrix class. The engine uses left-handed coordinate systems and the matrix data is stored in the following form:

//      Vectors:
//   x   y   z   w
// / 0   4   8  12 \
// | 1   5   9  13 |
// | 2   6  10  14 |
// \ 3   7  11  15 /

A matrix has by default its identity where the member 0, 5, 10 and 15 have a value of 1.0 and all the others 0.0.


Constructor & Destructor Documentation

template<typename T>
sp::dim::matrix4< T >::matrix4 (  )  [inline]
template<typename T>
sp::dim::matrix4< T >::matrix4 ( const T(&)  Other[16]  )  [inline]
template<typename T>
sp::dim::matrix4< T >::matrix4 ( const matrix4< T > &  Other  )  [inline]
template<typename T>
sp::dim::matrix4< T >::matrix4 ( const matrix3< T > &  Other  ) 
template<typename T>
sp::dim::matrix4< T >::matrix4 ( const obbox3d< T > &  Box  )  [inline]
template<typename T>
sp::dim::matrix4< T >::matrix4 ( m1n1,
m2n1,
m3n1,
m4n1,
m1n2,
m2n2,
m3n2,
m4n2,
m1n3,
m2n3,
m3n3,
m4n3,
m1n4,
m2n4,
m3n4,
m4n4 
) [inline]
template<typename T>
sp::dim::matrix4< T >::matrix4 ( const vector4d< T > &  XDirection,
const vector4d< T > &  YDirection,
const vector4d< T > &  ZDirection,
const vector4d< T > &  Position 
) [inline]
template<typename T>
sp::dim::matrix4< T >::~matrix4 (  )  [inline]

Member Function Documentation

template<typename T>
template<typename B >
matrix4<B> sp::dim::matrix4< T >::cast (  )  const [inline]
template<typename T>
void sp::dim::matrix4< T >::clear (  )  [inline]

Clear the matrix. i.e. each component is set to 0.

template<typename T>
bool sp::dim::matrix4< T >::equal ( const matrix4< T > &  Other  )  const [inline]
template<typename T>
matrix2<T> sp::dim::matrix4< T >::get2x2 (  )  const [inline]
template<typename T>
matrix3<T> sp::dim::matrix4< T >::get3x3 (  )  const [inline]
template<typename T>
T* sp::dim::matrix4< T >::getArray (  )  [inline]
template<typename T>
const T* sp::dim::matrix4< T >::getArray (  )  const [inline]
template<typename T>
vector4d<T> sp::dim::matrix4< T >::getColumn ( s32  Position  )  const [inline]
template<typename T>
bool sp::dim::matrix4< T >::getInverse ( matrix4< T > &  InverseMat  )  const [inline]
template<typename T>
matrix4<T> sp::dim::matrix4< T >::getInverse (  )  const [inline]
template<typename T>
vector3d<T> sp::dim::matrix4< T >::getPosition (  )  const [inline]
template<typename T>
matrix4<T> sp::dim::matrix4< T >::getPositionMatrix (  )  const [inline]
template<typename T>
matrix4<T> sp::dim::matrix4< T >::getPositionRotationMatrix (  )  const [inline]
template<typename T>
matrix4<T> sp::dim::matrix4< T >::getPositionScaleMatrix (  )  const [inline]
template<typename T>
static vector3d<T> sp::dim::matrix4< T >::getProjection ( const vector3d< T >  ObjectPosition,
const rect2di Viewport,
const matrix4< T > &  ProjectionMatrix,
const matrix4< T > &  ModelviewMatrix 
) [inline, static]
template<typename T>
vector3d<T> sp::dim::matrix4< T >::getRotation (  )  const [inline]
template<typename T>
matrix4<T> sp::dim::matrix4< T >::getRotationMatrix (  )  const [inline]
template<typename T>
vector4d<T> sp::dim::matrix4< T >::getRow ( s32  Position  )  const [inline]
template<typename T>
vector3d<T> sp::dim::matrix4< T >::getScale (  )  const [inline]

Returns the matrix scaling vector.

template<typename T>
matrix4<T> sp::dim::matrix4< T >::getTextureMatrix (  )  const [inline]
template<typename T>
matrix4<T> sp::dim::matrix4< T >::getTransposed (  )  const [inline]
template<typename T>
void sp::dim::matrix4< T >::getTransposed ( matrix4< T > &  Other  )  const [inline]
template<typename T>
matrix4<T> sp::dim::matrix4< T >::interpolate ( const matrix4< T > &  Other,
f32  seek 
) const [inline]
template<typename T>
bool sp::dim::matrix4< T >::isIdentity (  )  const [inline]
template<typename T>
void sp::dim::matrix4< T >::make2Dimensional ( s32  Width,
s32  Height,
s32  ScreenWidth,
s32  ScreenHeight 
) [inline]
template<typename T>
void sp::dim::matrix4< T >::makeViewport ( const rect2di Viewport,
const f32  DepthScale = 1.0f 
) [inline]
template<typename T>
void sp::dim::matrix4< T >::matrixLookAt ( const vector3d< T > &  Position,
const vector3d< T > &  LookAt,
const vector3d< T > &  upVector 
) [inline]
template<typename T>
void sp::dim::matrix4< T >::multiplySingleMatrix ( const T(&)  Other[4]  )  [inline]

Multiplies this matrix with a 1x4 matrix.

template<typename T>
bool sp::dim::matrix4< T >::operator!= ( const matrix4< T > &  Other  )  [inline]
template<typename T>
const T sp::dim::matrix4< T >::operator() ( u32  row,
u32  col 
) const [inline]
Parameters:
row,: Row of the wanted component in the range [0 .. 3].
col,: Column of the wanted component in the range [0 .. 3].
Returns:
the matrix component value at the specified location
template<typename T>
T& sp::dim::matrix4< T >::operator() ( u32  row,
u32  col 
) [inline]
template<typename T>
vector3d<T> sp::dim::matrix4< T >::operator* ( const vector3d< T > &  Vector  )  const [inline]
template<typename T>
point2d<T> sp::dim::matrix4< T >::operator* ( const point2d< T > &  Vector  )  const [inline]
template<typename T>
triangle3d<T> sp::dim::matrix4< T >::operator* ( const triangle3d< T > &  Triangle  )  const [inline]
template<typename T>
triangle3d<T> sp::dim::matrix4< T >::operator* ( const triangle3d< T, vector3d< T > * > &  Triangle  )  const [inline]
template<typename T>
plane3d<T> sp::dim::matrix4< T >::operator* ( const plane3d< T > &  Plane  )  const [inline]
template<typename T>
obbox3d<T> sp::dim::matrix4< T >::operator* ( const obbox3d< T > &  Box  )  const [inline]
template<typename T>
line3d<T> sp::dim::matrix4< T >::operator* ( const line3d< T > &  Line  )  const [inline]
template<typename T>
matrix4<T> sp::dim::matrix4< T >::operator* ( const matrix4< T > &  mltMatrix  )  const [inline]
template<typename T>
matrix4<T> sp::dim::matrix4< T >::operator* ( Scalar  )  const [inline]
template<typename T>
matrix4<T>& sp::dim::matrix4< T >::operator*= ( Scalar  )  [inline]
template<typename T>
matrix4<T>& sp::dim::matrix4< T >::operator*= ( const matrix4< T > &  mltMatrix  )  [inline]
template<typename T>
matrix4<T> sp::dim::matrix4< T >::operator+ ( const matrix4< T > &  mltMatrix  )  const [inline]
template<typename T>
matrix4<T>& sp::dim::matrix4< T >::operator+= ( const matrix4< T > &  mltMatrix  )  [inline]
template<typename T>
matrix4<T> sp::dim::matrix4< T >::operator- ( const matrix4< T > &  mltMatrix  )  const [inline]
template<typename T>
matrix4<T>& sp::dim::matrix4< T >::operator-= ( const matrix4< T > &  mltMatrix  )  [inline]
template<typename T>
matrix4<T>& sp::dim::matrix4< T >::operator= ( const matrix4< T > &  Other  )  [inline]
template<typename T>
matrix4<T>& sp::dim::matrix4< T >::operator= ( const T(&)  Other[16]  )  [inline]
template<typename T>
matrix4<T>& sp::dim::matrix4< T >::operator= ( Scalar  )  [inline]
template<typename T>
bool sp::dim::matrix4< T >::operator== ( const matrix4< T > &  Other  )  [inline]
template<typename T>
T& sp::dim::matrix4< T >::operator[] ( u32  i  )  [inline]
template<typename T>
const T sp::dim::matrix4< T >::operator[] ( u32  i  )  const [inline]

Returns the matrix component value at the specified offset (or rather index) 'i'.

template<typename T>
matrix4<T>& sp::dim::matrix4< T >::reset (  )  [inline]

Loads the matrix's identity.

        (  1  0  0  0  )
        |  0  1  0  0  |
        |  0  0  1  0  |
        (  0  0  0  1  )
template<typename T>
matrix4<T>& sp::dim::matrix4< T >::reset ( const vector3d< T > &  InitPosition,
const vector3d< T > &  InitScale = T(1) 
) [inline]

Loads the matrix's identity and sets an initial position (xyz) and scaling (whp).

        (  w  0  0  x  )
        |  0  h  0  y  |
        |  0  0  d  z  |
        (  0  0  0  1  )
template<typename T>
matrix4<T>& sp::dim::matrix4< T >::rotate ( const T  Angle,
vector3d< T >  Rotation 
) [inline]
template<typename T>
matrix4<T>& sp::dim::matrix4< T >::rotateX ( const T  Angle  )  [inline]
template<typename T>
matrix4<T>& sp::dim::matrix4< T >::rotateY ( const T  Angle  )  [inline]
template<typename T>
void sp::dim::matrix4< T >::rotateYXZ ( const vector3df Rotation  )  [inline]
template<typename T>
matrix4<T>& sp::dim::matrix4< T >::rotateZ ( const T  Angle  )  [inline]
template<typename T>
void sp::dim::matrix4< T >::rotateZXY ( const vector3df Rotation  )  [inline]
template<typename T>
matrix4<T>& sp::dim::matrix4< T >::scale ( const vector3d< T > &  Vector  )  [inline]
template<typename T>
void sp::dim::matrix4< T >::setColumn ( s32  Position,
const vector4d< T > &  Vec 
) [inline]
template<typename T>
bool sp::dim::matrix4< T >::setInverse (  )  [inline]
template<typename T>
void sp::dim::matrix4< T >::setInverseRotation ( vector3df  Rotation,
bool  UseDegrees = true 
) [inline]
template<typename T>
void sp::dim::matrix4< T >::setOrthoLH ( Left,
Right,
Top,
Bottom,
Near,
Far 
) [inline]
template<typename T>
void sp::dim::matrix4< T >::setOrthoRH ( Left,
Right,
Top,
Bottom,
Near,
Far 
) [inline]
template<typename T>
void sp::dim::matrix4< T >::setPerspectiveLH ( FieldOfView,
Aspect,
Near,
Far 
) [inline]
template<typename T>
void sp::dim::matrix4< T >::setPerspectiveRH ( FieldOfView,
Aspect,
Near,
Far 
) [inline]
template<typename T>
void sp::dim::matrix4< T >::setPosition ( const vector3d< T > &  Position  )  [inline]
template<typename T>
void sp::dim::matrix4< T >::setRotation ( vector3d< T >  Rotation,
bool  UseDegrees = true 
) [inline]
template<typename T>
void sp::dim::matrix4< T >::setRow ( s32  Position,
const vector4d< T > &  Vec 
) [inline]
template<typename T>
void sp::dim::matrix4< T >::setScale ( const vector3d< T > &  Scale  )  [inline]
template<typename T>
void sp::dim::matrix4< T >::setTextureRotation ( const T &  Degree  )  [inline]
template<typename T>
matrix4<T>& sp::dim::matrix4< T >::translate ( const vector3d< T > &  Vector  )  [inline]
template<typename T>
point2d<T> sp::dim::matrix4< T >::vecRotate ( const point2d< T > &  Vector  )  const [inline]

Returns the rotated specified vector. i.e. the vector will be multiplied with the 2x2 matrix.

template<typename T>
vector3d<T> sp::dim::matrix4< T >::vecRotate ( const vector3d< T > &  Vector  )  const [inline]

Returns the rotated specified vector. i.e. the vector will be multiplied with the 3x3 matrix.

template<typename T>
point2d<T> sp::dim::matrix4< T >::vecRotateInverse ( const point2d< T > &  Vector  )  const [inline]

Returns the rotated specified vector. i.e. the vector will be multiplied with the inversed 2x2 matrix.

template<typename T>
vector3d<T> sp::dim::matrix4< T >::vecRotateInverse ( const vector3d< T > &  Vector  )  const [inline]

Returns the inverse rotated specified vector. i.e. the vector will be multiplied with the inversed 3x3 matrix.


Member Data Documentation

template<typename T>
const matrix4< T > sp::dim::matrix4< T >::IDENTITY [static]

Identity 4x4 matrix.

template<typename T>
T sp::dim::matrix4< T >::M[16]

The matrix memory buffer.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines