Files Class List
Matrix4< TYPE > Class Template Reference

Detailed Description

template<typename TYPE>
class cy::Matrix4< TYPE >

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 Matrix4 with Point3<TYPE> and Point4<TYPE> to transform 3D and 4D points.

#include <cyMatrix.h>

Public Member Functions

Constructors
 Matrix4 ()
 
 Matrix4 (const Matrix4 &matrix)
 
template<typename T >
 Matrix4 (const Matrix4< T > &matrix)
 
 Matrix4 (const TYPE *values)
 
 Matrix4 (const TYPE &v)
 
 Matrix4 (const Point3< TYPE > &x, const Point3< TYPE > &y, const Point3< TYPE > &z, const Point3< TYPE > &pos)
 
 Matrix4 (const Point4< TYPE > &x, const Point4< TYPE > &y, const Point4< TYPE > &z, const Point4< TYPE > &w)
 
 Matrix4 (const Point3< TYPE > &pos, const Point3< TYPE > &normal, const Point3< TYPE > &dir)
 
 Matrix4 (const Matrix34< TYPE > &m)
 
 Matrix4 (const Matrix3< TYPE > &m)
 
 Matrix4 (const Matrix2< TYPE > &m)
 
 Matrix4 (const TYPE &row0col0, const TYPE &row0col1, const TYPE &row0col2, const TYPE &row0col3, const TYPE &row1col0, const TYPE &row1col1, const TYPE &row1col2, const TYPE &row1col3, const TYPE &row2col0, const TYPE &row2col1, const TYPE &row2col2, const TYPE &row2col3, const TYPE &row3col0, const TYPE &row3col1, const TYPE &row3col2, const TYPE &row3col3)
 
Set & Get Methods
void Zero ()
 
bool IsZero () const
 
void Get (TYPE *values)
 
void Set (const TYPE *values)
 
void Set (const Point3< TYPE > &x, const Point3< TYPE > &y, const Point3< TYPE > &z, const Point3< TYPE > &pos)
 
void Set (const Point4< TYPE > &x, const Point4< TYPE > &y, const Point4< TYPE > &z, const Point4< TYPE > &w)
 
void Set (const Point3< TYPE > &pos, const Point3< TYPE > &normal, const Point3< TYPE > &dir)
 
void SetIdentity ()
 
void SetScaledIdentity (TYPE v)
 
void SetTensorProduct (const Point4< TYPE > &v0, const Point4< TYPE > &v1)
 
Affine transformations
void SetScale (const TYPE &uniformScale)
 
void SetScale (const TYPE &scaleX, const TYPE &scaleY, const TYPE &scaleZ, TYPE scaleW=1)
 
void SetScale (const Point3< TYPE > &scale)
 
void SetNoScale ()
 
void SetRotationX (TYPE angle)
 
void SetRotationX (TYPE sinAngle, TYPE cosAngle)
 
void SetRotationY (TYPE angle)
 
void SetRotationY (TYPE sinAngle, TYPE cosAngle)
 
void SetRotationZ (TYPE angle)
 
void SetRotationZ (TYPE sinAngle, TYPE cosAngle)
 
void SetRotationXYZ (TYPE angleX, TYPE angleY, TYPE angleZ)
 
void SetRotationZYX (TYPE angleX, TYPE angleY, TYPE angleZ)
 
void SetRotation (const Point3< TYPE > &axis, TYPE angle)
 
void SetRotation (const Point3< TYPE > &axis, TYPE sinAngle, TYPE cosAngle)
 
void SetRotation (const Point3< TYPE > &from, const Point3< TYPE > &to)
 
void SetTrans (const Point3< TYPE > &move)
 
void AddTrans (const Point3< TYPE > &move)
 
void SetTransComponent (const Point3< TYPE > &move)
 
void SetView (const Point3< TYPE > &pos, const Point3< TYPE > &target, const Point3< TYPE > &up)
 
void SetNormal (const Point3< TYPE > &normal, const Point3< TYPE > &dir)
 
void SetPerspective (TYPE fov, TYPE aspect, TYPE znear, TYPE zfar)
 
void SetPerspectiveTan (TYPE tan_fov_2, TYPE aspect, TYPE znear, TYPE zfar)
 
Set Row, Column, or Diagonal
void SetRow (int row, TYPE x, TYPE y, TYPE z, TYPE w)
 
void SetColumn (int column, TYPE x, TYPE y, TYPE z, TYPE w)
 
void SetDiagonal (const TYPE &xx, const TYPE &yy, const TYPE &zz, const TYPE &ww=1)
 
void SetDiagonal (const Point4< TYPE > &p)
 
void SetDiagonal (const Point3< TYPE > &p)
 
void SetDiagonal (const TYPE *values)
 
Get Row, Column, or Diagonal
Point4< TYPE > GetRow (int row) const
 
void GetRow (int row, Point4< TYPE > &p) const
 
void GetRow (int row, TYPE *values) const
 
Point4< TYPE > GetColumn (int col) const
 
void GetColumn (int col, Point4< TYPE > &p) const
 
void GetColumn (int col, TYPE *values) const
 
Point4< TYPE > GetDiagonal () const
 
void GetDiagonal (Point4< TYPE > &p) const
 
void GetDiagonal (TYPE *values) const
 
Get Sub-matrix data
void GetSubMatrix (Matrix34< TYPE > &m) const
 
void GetSubMatrix (Matrix3< TYPE > &m) const
 
void GetSubMatrix (Matrix2< TYPE > &m) const
 
Matrix34< TYPE > GetSubMatrix34 () const
 
void GetSubMatrix34 (Matrix34< TYPE > &m) const
 
void GetSubMatrix34 (TYPE *mdata) const
 
Matrix3< TYPE > GetSubMatrix3 () const
 
void GetSubMatrix3 (Matrix3< TYPE > &m) const
 
void GetSubMatrix3 (TYPE *mdata) const
 
Matrix2< TYPE > GetSubMatrix2 () const
 
void GetSubMatrix2 (Matrix2< TYPE > &m) const
 
void GetSubMatrix2 (TYPE *mdata) const
 
Point3< TYPE > GetTrans () const
 
void GetTrans (Point3< TYPE > &p) const
 
void GetTrans (TYPE *trans) const
 
Comparison Operators

Returns the translation component of the matrix

bool operator== (const Matrix4 &right) const
 
bool operator!= (const Matrix4 &right) const
 
Access Operators
TYPE & operator() (int row, int column)
 
const TYPE & operator() (int row, int column) const
 
TYPE & operator[] (int i)
 
const TYPE & operator[] (int i) const
 
Unary and Binary Operators
Matrix4 operator- () const
 
Matrix4 operator* (const TYPE &value) const
 
Matrix4 operator/ (const TYPE &value) const
 
Matrix4 operator+ (const Matrix4 &right) const
 
Matrix4 operator- (const Matrix4 &right) const
 
Matrix4 operator* (const Matrix4 &right) const
 
Matrix4 operator* (const Matrix34< TYPE > &right) const
 
Matrix4 operator* (const Matrix3< TYPE > &right) const
 
Point4< TYPE > operator* (const Point3< TYPE > &p) const
 
Point4< TYPE > operator* (const Point4< TYPE > &p) const
 
Assignment Operators
const Matrix4operator= (const Matrix4 &right)
 
const Matrix4operator+= (const Matrix4 &right)
 
const Matrix4operator-= (const Matrix4 &right)
 
const Matrix4operator*= (const Matrix4 &right)
 
const Matrix4operator*= (const Matrix34< TYPE > &right)
 
const Matrix4operator*= (const Matrix3< TYPE > &right)
 
const Matrix4operator*= (const TYPE &value)
 
const Matrix4operator/= (const TYPE &value)
 
Other Methods
void Transpose ()
 
void GetTranspose (Matrix4 &m) const
 
Matrix4 GetTranspose () const
 
Point4< TYPE > TransposeMult (const Point3< TYPE > &p) const
 
Point4< TYPE > TransposeMult (const Point4< TYPE > &p) const
 
TYPE GetDeterminant () const
 
void Invert ()
 
void GetInverse (Matrix4 &inverse) const
 
Matrix4 GetInverse () const
 
void OrthogonalizeX ()
 
void OrthogonalizeY ()
 
void OrthogonalizeZ ()
 
bool IsIdentity (TYPE tollerance=TYPE(0.001)) const
 
bool IsSymmetric (TYPE tollerance=TYPE(0.001)) const
 

Static Public Member Functions

Static Methods
static Matrix4 MatrixIdentity ()
 
static Matrix4 MatrixView (const Point3< TYPE > &pos, const Point3< TYPE > &target, Point3< TYPE > &up)
 
static Matrix4 MatrixNormal (const Point3< TYPE > &normal, Point3< TYPE > &dir)
 
static Matrix4 MatrixRotationX (TYPE angle)
 
static Matrix4 MatrixRotationY (TYPE angle)
 
static Matrix4 MatrixRotationZ (TYPE angle)
 
static Matrix4 MatrixRotation (const Point3< TYPE > &axis, TYPE angle)
 
static Matrix4 MatrixRotation (const Point3< TYPE > &from, const Point3< TYPE > &to)
 
static Matrix4 MatrixScale (const TYPE &uniformScale)
 
static Matrix4 MatrixScale (const TYPE &scaleX, const TYPE &scaleY, const TYPE &scaleZ)
 
static Matrix4 MatrixScale (const Point3< TYPE > &scale)
 
static Matrix4 MatrixTrans (const Point3< TYPE > &move)
 
static Matrix4 MatrixPerspective (TYPE fov, TYPE aspect, TYPE znear, TYPE zfar)
 
static Matrix4 MatrixPerspectiveTan (TYPE tan_fov_2, TYPE aspect, TYPE znear, TYPE zfar)
 

Public Attributes

TYPE data [16]
 

Friends

Matrix4 operator* (const TYPE value, const Matrix4 &right)
 
Matrix4 Inverse (const Matrix4 &m)
 
Matrix4 operator* (const Matrix34< TYPE > &left, const Matrix4 &right)
 

Constructor & Destructor Documentation

§ Matrix4() [1/12]

Matrix4 ( )

Default constructor.

§ Matrix4() [2/12]

Matrix4 ( const Matrix4< TYPE > &  matrix)

Copy constructor.

§ Matrix4() [3/12]

Matrix4 ( const Matrix4< T > &  matrix)
explicit

Copy constructor for different types.

§ Matrix4() [4/12]

Matrix4 ( const TYPE *  values)
explicit

Initialize the matrix using an array of 9 values.

§ Matrix4() [5/12]

Matrix4 ( const TYPE &  v)
explicit

Initialize the matrix as identity scaled by v.

§ Matrix4() [6/12]

Matrix4 ( const Point3< TYPE > &  x,
const Point3< TYPE > &  y,
const Point3< TYPE > &  z,
const Point3< TYPE > &  pos 
)
explicit

Initialize the matrix using x,y,z vectors and coordinate center.

§ Matrix4() [7/12]

Matrix4 ( const Point4< TYPE > &  x,
const Point4< TYPE > &  y,
const Point4< TYPE > &  z,
const Point4< TYPE > &  w 
)
explicit

Initialize the matrix using x,y,z vectors as columns.

§ Matrix4() [8/12]

Matrix4 ( const Point3< TYPE > &  pos,
const Point3< TYPE > &  normal,
const Point3< TYPE > &  dir 
)
explicit

Initialize the matrix using position, normal, and approximate x direction.

§ Matrix4() [9/12]

Matrix4 ( const Matrix34< TYPE > &  m)
explicit

Default constructor.

§ Matrix4() [10/12]

Matrix4 ( const Matrix3< TYPE > &  m)
explicit

Default constructor.

§ Matrix4() [11/12]

Matrix4 ( const Matrix2< TYPE > &  m)
explicit

Default constructor.

§ Matrix4() [12/12]

Matrix4 ( const TYPE &  row0col0,
const TYPE &  row0col1,
const TYPE &  row0col2,
const TYPE &  row0col3,
const TYPE &  row1col0,
const TYPE &  row1col1,
const TYPE &  row1col2,
const TYPE &  row1col3,
const TYPE &  row2col0,
const TYPE &  row2col1,
const TYPE &  row2col2,
const TYPE &  row2col3,
const TYPE &  row3col0,
const TYPE &  row3col1,
const TYPE &  row3col2,
const TYPE &  row3col3 
)

Constructor using row-major order for initialization.

Member Function Documentation

§ Zero()

void Zero ( )

Set all the values as zero.

§ IsZero()

bool IsZero ( ) const

Returns true if the matrix is exactly zero.

§ Get()

void Get ( TYPE *  values)

Copies the matrix data to the given values array of size 16.

§ Set() [1/4]

void Set ( const TYPE *  values)

Set Matrix using an array of 16 values.

§ Set() [2/4]

void Set ( const Point3< TYPE > &  x,
const Point3< TYPE > &  y,
const Point3< TYPE > &  z,
const Point3< TYPE > &  pos 
)

Set matrix using x,y,z vectors and coordinate center.

§ Set() [3/4]

void Set ( const Point4< TYPE > &  x,
const Point4< TYPE > &  y,
const Point4< TYPE > &  z,
const Point4< TYPE > &  w 
)

Set matrix using x,y,z,w vectors.

§ Set() [4/4]

void Set ( const Point3< TYPE > &  pos,
const Point3< TYPE > &  normal,
const Point3< TYPE > &  dir 
)

Set matrix using position, normal, and approximate x direction.

§ SetIdentity()

void SetIdentity ( )

Converts the matrix to an identity matrix.

§ SetScaledIdentity()

void SetScaledIdentity ( TYPE  v)

Converts the matrix to an identity matrix scaled by a scalar.

§ SetTensorProduct()

void SetTensorProduct ( const Point4< TYPE > &  v0,
const Point4< TYPE > &  v1 
)

Sets the matrix as the tensor product (outer product) of two vectors.

§ SetScale() [1/3]

void SetScale ( const TYPE &  uniformScale)

Sets a uniform scale matrix.

§ SetScale() [2/3]

void SetScale ( const TYPE &  scaleX,
const TYPE &  scaleY,
const TYPE &  scaleZ,
TYPE  scaleW = 1 
)

Sets a scale matrix.

§ SetScale() [3/3]

void SetScale ( const Point3< TYPE > &  scale)

Sets a scale matrix.

§ SetNoScale()

void SetNoScale ( )

Removes the scale component of the matrix.

§ SetRotationX() [1/2]

void SetRotationX ( TYPE  angle)

Set as rotation matrix around x axis.

§ SetRotationX() [2/2]

void SetRotationX ( TYPE  sinAngle,
TYPE  cosAngle 
)

Set as rotation matrix around x axis by cos and sin of angle.

§ SetRotationY() [1/2]

void SetRotationY ( TYPE  angle)

Set as rotation matrix around y axis.

§ SetRotationY() [2/2]

void SetRotationY ( TYPE  sinAngle,
TYPE  cosAngle 
)

Set as rotation matrix around y axis by cos and sin of angle.

§ SetRotationZ() [1/2]

void SetRotationZ ( TYPE  angle)

Set as rotation matrix around z axis.

§ SetRotationZ() [2/2]

void SetRotationZ ( TYPE  sinAngle,
TYPE  cosAngle 
)

Set as rotation matrix around z axis by cos and sin of angle.

§ SetRotationXYZ()

void SetRotationXYZ ( TYPE  angleX,
TYPE  angleY,
TYPE  angleZ 
)

Set as rotation matrix around x, y, and then z axes ( Rz * Ry * Rx )

§ SetRotationZYX()

void SetRotationZYX ( TYPE  angleX,
TYPE  angleY,
TYPE  angleZ 
)

Set as rotation matrix around z, y, and then x axes ( Rx * Ry * Rz )

§ SetRotation() [1/3]

void SetRotation ( const Point3< TYPE > &  axis,
TYPE  angle 
)

Set a rotation matrix about the given axis by angle.

§ SetRotation() [2/3]

void SetRotation ( const Point3< TYPE > &  axis,
TYPE  sinAngle,
TYPE  cosAngle 
)

Set a rotation matrix about the given axis by cos and sin of angle.

§ SetRotation() [3/3]

void SetRotation ( const Point3< TYPE > &  from,
const Point3< TYPE > &  to 
)

Set a rotation matrix that sets [from] unit vector to [to] unit vector.

§ SetTrans()

void SetTrans ( const Point3< TYPE > &  move)

Sets a translation matrix with no rotation or scale.

§ AddTrans()

void AddTrans ( const Point3< TYPE > &  move)

Adds a translation to the matrix.

§ SetTransComponent()

void SetTransComponent ( const Point3< TYPE > &  move)

Sets the translation component of the matrix.

§ SetView()

void SetView ( const Point3< TYPE > &  pos,
const Point3< TYPE > &  target,
const Point3< TYPE > &  up 
)

Set view matrix using position, target and approximate up vector.

§ SetNormal()

void SetNormal ( const Point3< TYPE > &  normal,
const Point3< TYPE > &  dir 
)

Set matrix using normal and approximate x direction.

§ SetPerspective()

void SetPerspective ( TYPE  fov,
TYPE  aspect,
TYPE  znear,
TYPE  zfar 
)

Set a project matrix with field of view in radians.

§ SetPerspectiveTan()

void SetPerspectiveTan ( TYPE  tan_fov_2,
TYPE  aspect,
TYPE  znear,
TYPE  zfar 
)

Set a project matrix with the tangent of the half field of view (tan_fov_2)

§ SetRow()

void SetRow ( int  row,
TYPE  x,
TYPE  y,
TYPE  z,
TYPE  w 
)

Sets a row of the matrix.

§ SetColumn()

void SetColumn ( int  column,
TYPE  x,
TYPE  y,
TYPE  z,
TYPE  w 
)

Sets a column of the matrix.

§ SetDiagonal() [1/4]

void SetDiagonal ( const TYPE &  xx,
const TYPE &  yy,
const TYPE &  zz,
const TYPE &  ww = 1 
)

Sets the diagonal values of the matrix.

§ SetDiagonal() [2/4]

void SetDiagonal ( const Point4< TYPE > &  p)

Sets the diagonal values of the matrix.

§ SetDiagonal() [3/4]

void SetDiagonal ( const Point3< TYPE > &  p)

Sets the diagonal values of the matrix.

§ SetDiagonal() [4/4]

void SetDiagonal ( const TYPE *  values)

Sets the 4 diagonal values of the matrix.

§ GetRow() [1/3]

Point4<TYPE> GetRow ( int  row) const

Returns a row of the matrix.

§ GetRow() [2/3]

void GetRow ( int  row,
Point4< TYPE > &  p 
) const

Returns a row of the matrix.

§ GetRow() [3/3]

void GetRow ( int  row,
TYPE *  values 
) const

Returns a row of the matrix.

§ GetColumn() [1/3]

Point4<TYPE> GetColumn ( int  col) const

Returns a column of the matrix.

§ GetColumn() [2/3]

void GetColumn ( int  col,
Point4< TYPE > &  p 
) const

Returns a column of the matrix.

§ GetColumn() [3/3]

void GetColumn ( int  col,
TYPE *  values 
) const

Returns a column of the matrix.

§ GetDiagonal() [1/3]

Point4<TYPE> GetDiagonal ( ) const

Returns the diagonal of the matrix.

§ GetDiagonal() [2/3]

void GetDiagonal ( Point4< TYPE > &  p) const

Returns the diagonal of the matrix.

§ GetDiagonal() [3/3]

void GetDiagonal ( TYPE *  values) const

Returns the diagonal of the matrix.

§ GetSubMatrix() [1/3]

void GetSubMatrix ( Matrix34< TYPE > &  m) const

Returns the 3x4 portion of the matrix.

§ GetSubMatrix() [2/3]

void GetSubMatrix ( Matrix3< TYPE > &  m) const

Returns the 3x3 portion of the matrix.

§ GetSubMatrix() [3/3]

void GetSubMatrix ( Matrix2< TYPE > &  m) const

Returns the 2x2 portion of the matrix.

§ GetSubMatrix34() [1/3]

Matrix34<TYPE> GetSubMatrix34 ( ) const

Returns the 3x4 portion of the matrix.

§ GetSubMatrix34() [2/3]

void GetSubMatrix34 ( Matrix34< TYPE > &  m) const

Returns the 3x4 portion of the matrix.

§ GetSubMatrix34() [3/3]

void GetSubMatrix34 ( TYPE *  mdata) const

Returns the 3x4 portion of the matrix.

§ GetSubMatrix3() [1/3]

Matrix3<TYPE> GetSubMatrix3 ( ) const

Returns the 3x3 portion of the matrix.

§ GetSubMatrix3() [2/3]

void GetSubMatrix3 ( Matrix3< TYPE > &  m) const

Returns the 3x3 portion of the matrix.

§ GetSubMatrix3() [3/3]

void GetSubMatrix3 ( TYPE *  mdata) const

Returns the 3x3 portion of the matrix.

§ GetSubMatrix2() [1/3]

Matrix2<TYPE> GetSubMatrix2 ( ) const

Returns the 2x2 portion of the matrix.

§ GetSubMatrix2() [2/3]

void GetSubMatrix2 ( Matrix2< TYPE > &  m) const

Returns the 2x2 portion of the matrix.

§ GetSubMatrix2() [3/3]

void GetSubMatrix2 ( TYPE *  mdata) const

Returns the 2x2 portion of the matrix.

§ GetTrans() [1/3]

Point3<TYPE> GetTrans ( ) const

Returns the 3x4 portion of the matrix.

§ GetTrans() [2/3]

void GetTrans ( Point3< TYPE > &  p) const

Returns the translation component of the matrix.

§ GetTrans() [3/3]

void GetTrans ( TYPE *  trans) const

Returns the translation component of the matrix.

§ operator==()

bool operator== ( const Matrix4< TYPE > &  right) const

compare equal

§ operator!=()

bool operator!= ( const Matrix4< TYPE > &  right) const

compare not equal

§ operator()() [1/2]

TYPE& operator() ( int  row,
int  column 
)

subscript operator

§ operator()() [2/2]

const TYPE& operator() ( int  row,
int  column 
) const

constant subscript operator

§ operator[]() [1/2]

TYPE& operator[] ( int  i)

subscript operator

§ operator[]() [2/2]

const TYPE& operator[] ( int  i) const

constant subscript operator

§ operator-() [1/2]

Matrix4 operator- ( ) const

negative matrix

§ operator*() [1/6]

Matrix4 operator* ( const TYPE &  value) const

multiply matrix by a value

§ operator/()

Matrix4 operator/ ( const TYPE &  value) const

divide matrix by a value;

§ operator+()

Matrix4 operator+ ( const Matrix4< TYPE > &  right) const

add two Matrices

§ operator-() [2/2]

Matrix4 operator- ( const Matrix4< TYPE > &  right) const

subtract one Matrix4 from another

§ operator*() [2/6]

Matrix4 operator* ( const Matrix4< TYPE > &  right) const

< multiply a matrix with another

§ operator*() [3/6]

Matrix4 operator* ( const Matrix34< TYPE > &  right) const

< multiply a matrix with another

§ operator*() [4/6]

Matrix4 operator* ( const Matrix3< TYPE > &  right) const

< multiply a matrix with another

§ operator*() [5/6]

Point4<TYPE> operator* ( const Point3< TYPE > &  p) const

negative matrix

§ operator*() [6/6]

Point4<TYPE> operator* ( const Point4< TYPE > &  p) const

negative matrix

§ operator=()

const Matrix4& operator= ( const Matrix4< TYPE > &  right)

add two Matrices modify this

§ operator+=()

const Matrix4& operator+= ( const Matrix4< TYPE > &  right)

add two Matrices modify this

§ operator-=()

const Matrix4& operator-= ( const Matrix4< TYPE > &  right)

subtract one Matrix4 from another matrix and modify this matrix

§ operator*=() [1/4]

const Matrix4& operator*= ( const Matrix4< TYPE > &  right)

multiply a matrix with another matrix and modify this matrix

§ operator*=() [2/4]

const Matrix4& operator*= ( const Matrix34< TYPE > &  right)

multiply a matrix with another matrix and modify this matrix

§ operator*=() [3/4]

const Matrix4& operator*= ( const Matrix3< TYPE > &  right)

multiply a matrix with another matrix and modify this matrix

§ operator*=() [4/4]

const Matrix4& operator*= ( const TYPE &  value)

multiply a matrix with a value modify this matrix

§ operator/=()

const Matrix4& operator/= ( const TYPE &  value)

divide the matrix by a value modify the this matrix

§ Transpose()

void Transpose ( )

< return Transpose of this matrix

§ GetTranspose() [1/2]

void GetTranspose ( Matrix4< TYPE > &  m) const

< return Transpose of this matrix

§ GetTranspose() [2/2]

Matrix4 GetTranspose ( ) const

return Transpose of this matrix

§ TransposeMult() [1/2]

Point4<TYPE> TransposeMult ( const Point3< TYPE > &  p) const

Multiply the give vector with the transpose of the matrix.

§ TransposeMult() [2/2]

Point4<TYPE> TransposeMult ( const Point4< TYPE > &  p) const

Multiply the give vector with the transpose of the matrix.

§ GetDeterminant()

TYPE GetDeterminant ( ) const

< Get the determinant of this matrix

§ Invert()

void Invert ( )

Invert this matrix.

§ GetInverse() [1/2]

void GetInverse ( Matrix4< TYPE > &  inverse) const

< Get the inverse of this matrix

§ GetInverse() [2/2]

Matrix4 GetInverse ( ) const

Get the inverse of this matrix.

§ OrthogonalizeX()

void OrthogonalizeX ( )

Orthogonalizes the matrix and removes the scale component, preserving the x direction.

§ OrthogonalizeY()

void OrthogonalizeY ( )

Orthogonalizes the matrix and removes the scale component, preserving the y direction.

§ OrthogonalizeZ()

void OrthogonalizeZ ( )

Orthogonalizes the matrix and removes the scale component, preserving the z direction.

§ IsIdentity()

bool IsIdentity ( TYPE  tollerance = TYPE(0.001)) const

Returns if the matrix is identity within the given error tollerance.

§ IsSymmetric()

bool IsSymmetric ( TYPE  tollerance = TYPE(0.001)) const

Returns if the matrix is symmetric within the given error tollerance.

§ MatrixIdentity()

static Matrix4 MatrixIdentity ( )
static

Returns an identity matrix.

§ MatrixView()

static Matrix4 MatrixView ( const Point3< TYPE > &  pos,
const Point3< TYPE > &  target,
Point3< TYPE > &  up 
)
static

Returns a view matrix using position, target and approximate up vector.

§ MatrixNormal()

static Matrix4 MatrixNormal ( const Point3< TYPE > &  normal,
Point3< TYPE > &  dir 
)
static

Returns a matrix using normal, and approximate x direction.

§ MatrixRotationX()

static Matrix4 MatrixRotationX ( TYPE  angle)
static

Returns a rotation matrix around x axis by angle in radians.

§ MatrixRotationY()

static Matrix4 MatrixRotationY ( TYPE  angle)
static

Returns a rotation matrix around y axis by angle in radians.

§ MatrixRotationZ()

static Matrix4 MatrixRotationZ ( TYPE  angle)
static

Returns a rotation matrix around z axis by angle in radians.

§ MatrixRotation() [1/2]

static Matrix4 MatrixRotation ( const Point3< TYPE > &  axis,
TYPE  angle 
)
static

Returns a rotation matrix about the given axis by angle in radians.

§ MatrixRotation() [2/2]

static Matrix4 MatrixRotation ( const Point3< TYPE > &  from,
const Point3< TYPE > &  to 
)
static

Returns a rotation matrix that sets [from] unit vector to [to] unit vector.

§ MatrixScale() [1/3]

static Matrix4 MatrixScale ( const TYPE &  uniformScale)
static

Returns a uniform scale matrix.

§ MatrixScale() [2/3]

static Matrix4 MatrixScale ( const TYPE &  scaleX,
const TYPE &  scaleY,
const TYPE &  scaleZ 
)
static

Returns a scale matrix.

§ MatrixScale() [3/3]

static Matrix4 MatrixScale ( const Point3< TYPE > &  scale)
static

Returns a scale matrix.

§ MatrixTrans()

static Matrix4 MatrixTrans ( const Point3< TYPE > &  move)
static

Returns a translation matrix with no rotation or scale.

§ MatrixPerspective()

static Matrix4 MatrixPerspective ( TYPE  fov,
TYPE  aspect,
TYPE  znear,
TYPE  zfar 
)
static

Returns a project matrix with field of view in radians.

§ MatrixPerspectiveTan()

static Matrix4 MatrixPerspectiveTan ( TYPE  tan_fov_2,
TYPE  aspect,
TYPE  znear,
TYPE  zfar 
)
static

Returns a project matrix with the tangent of the half field of view (tan_fov_2)

Friends And Related Function Documentation

§ operator* [1/2]

Matrix4 operator* ( const TYPE  value,
const Matrix4< TYPE > &  right 
)
friend

multiply matrix by a value

§ Inverse

Matrix4 Inverse ( const Matrix4< TYPE > &  m)
friend

return the inverse of the matrix

§ operator* [2/2]

Matrix4 operator* ( const Matrix34< TYPE > &  left,
const Matrix4< TYPE > &  right 
)
friend

multiply a 4x4 matrix with a 3x4 matrix, treating it as a 4x4 matrix with last row 0,0,0,1

Member Data Documentation

§ data

TYPE data[16]

Elements of the matrix are column-major:
| 0 4 8 12 |
| 1 5 9 13 |
| 2 6 10 14 |
| 3 7 11 15 |
.