Files Class List
Matrix4d Class Reference

Detailed Description

4x4 Matrix class with double type elements

+ Inheritance diagram for Matrix4d:

Public Member Functions

Unary and Binary Operators
Matrix4 operator* (const double &value) const
 
Matrix4 operator* (const Matrix4 &right) const
 
Matrix4 operator* (const Matrix34< double > &right) const
 
Matrix4 operator* (const Matrix3< double > &right) const
 
Point4< double > operator* (const Point3< double > &p) const
 
Point4< double > operator* (const Point4< double > &p) const
 
Matrix4 operator- () const
 
Matrix4 operator- (const Matrix4 &right) const
 
Matrix4 operator/ (const double &value) const
 
Matrix4 operator+ (const Matrix4 &right) const
 
Set & Get Methods
void Zero ()
 
bool IsZero () const
 
void Get (double *values)
 
void Set (const double *values)
 
void Set (const Point3< double > &x, const Point3< double > &y, const Point3< double > &z, const Point3< double > &pos)
 
void Set (const Point4< double > &x, const Point4< double > &y, const Point4< double > &z, const Point4< double > &w)
 
void Set (const Point3< double > &pos, const Point3< double > &normal, const Point3< double > &dir)
 
void SetIdentity ()
 
void SetScaledIdentity (double v)
 
void SetTensorProduct (const Point4< double > &v0, const Point4< double > &v1)
 
Affine transformations
void SetScale (const double &uniformScale)
 
void SetScale (const double &scaleX, const double &scaleY, const double &scaleZ, double scaleW=1)
 
void SetScale (const Point3< double > &scale)
 
void SetNoScale ()
 
void SetRotationX (double angle)
 
void SetRotationX (double sinAngle, double cosAngle)
 
void SetRotationY (double angle)
 
void SetRotationY (double sinAngle, double cosAngle)
 
void SetRotationZ (double angle)
 
void SetRotationZ (double sinAngle, double cosAngle)
 
void SetRotationXYZ (double angleX, double angleY, double angleZ)
 
void SetRotationZYX (double angleX, double angleY, double angleZ)
 
void SetRotation (const Point3< double > &axis, double angle)
 
void SetRotation (const Point3< double > &axis, double sinAngle, double cosAngle)
 
void SetRotation (const Point3< double > &from, const Point3< double > &to)
 
void SetTrans (const Point3< double > &move)
 
void AddTrans (const Point3< double > &move)
 
void SetTransComponent (const Point3< double > &move)
 
void SetView (const Point3< double > &pos, const Point3< double > &target, const Point3< double > &up)
 
void SetNormal (const Point3< double > &normal, const Point3< double > &dir)
 
void SetPerspective (double fov, double aspect, double znear, double zfar)
 
void SetPerspectiveTan (double tan_fov_2, double aspect, double znear, double zfar)
 
Set Row, Column, or Diagonal
void SetRow (int row, double x, double y, double z, double w)
 
void SetColumn (int column, double x, double y, double z, double w)
 
void SetDiagonal (const double &xx, const double &yy, const double &zz, const double &ww=1)
 
void SetDiagonal (const Point4< double > &p)
 
void SetDiagonal (const Point3< double > &p)
 
void SetDiagonal (const double *values)
 
Get Row, Column, or Diagonal
Point4< double > GetRow (int row) const
 
void GetRow (int row, Point4< double > &p) const
 
void GetRow (int row, double *values) const
 
Point4< double > GetColumn (int col) const
 
void GetColumn (int col, Point4< double > &p) const
 
void GetColumn (int col, double *values) const
 
Point4< double > GetDiagonal () const
 
void GetDiagonal (Point4< double > &p) const
 
void GetDiagonal (double *values) const
 
Get Sub-matrix data
void GetSubMatrix (Matrix34< double > &m) const
 
void GetSubMatrix (Matrix3< double > &m) const
 
void GetSubMatrix (Matrix2< double > &m) const
 
Matrix34< double > GetSubMatrix34 () const
 
void GetSubMatrix34 (Matrix34< double > &m) const
 
void GetSubMatrix34 (double *mdata) const
 
Matrix3< double > GetSubMatrix3 () const
 
void GetSubMatrix3 (Matrix3< double > &m) const
 
void GetSubMatrix3 (double *mdata) const
 
Matrix2< double > GetSubMatrix2 () const
 
void GetSubMatrix2 (Matrix2< double > &m) const
 
void GetSubMatrix2 (double *mdata) const
 
Point3< double > GetTrans () const
 
void GetTrans (Point3< double > &p) const
 
void GetTrans (double *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
double & operator() (int row, int column)
 
const double & operator() (int row, int column) const
 
double & operator[] (int i)
 
const double & operator[] (int i) const
 
Assignment Operators
const Matrix4operator+= (const Matrix4 &right)
 
const Matrix4operator-= (const Matrix4 &right)
 
const Matrix4operator*= (const Matrix4 &right)
 
const Matrix4operator*= (const Matrix34< double > &right)
 
const Matrix4operator*= (const Matrix3< double > &right)
 
const Matrix4operator*= (const double &value)
 
const Matrix4operator/= (const double &value)
 
Other Methods
void Transpose ()
 
void GetTranspose (Matrix4 &m) const
 
Matrix4 GetTranspose () const
 
Point4< double > TransposeMult (const Point3< double > &p) const
 
Point4< double > TransposeMult (const Point4< double > &p) const
 
double GetDeterminant () const
 
void Invert ()
 
void GetInverse (Matrix4 &inverse) const
 
Matrix4 GetInverse () const
 
void OrthogonalizeX ()
 
void OrthogonalizeY ()
 
void OrthogonalizeZ ()
 
bool IsIdentity (double tollerance=double(0.001)) const
 
bool IsSymmetric (double tollerance=double(0.001)) const
 

Static Public Member Functions

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

Public Attributes

double data [16]
 

Member Function Documentation

§ operator*() [1/6]

Matrix4 operator* ( const double &  value) const
inherited

multiply matrix by a value

§ operator*() [2/6]

Matrix4 operator* ( const Matrix4< double > &  right) const
inherited

< multiply a matrix with another

§ operator*() [3/6]

Matrix4 operator* ( const Matrix34< double > &  right) const
inherited

< multiply a matrix with another

§ operator*() [4/6]

Matrix4 operator* ( const Matrix3< double > &  right) const
inherited

< multiply a matrix with another

§ operator*() [5/6]

Point4<double > operator* ( const Point3< double > &  p) const
inherited

negative matrix

§ operator*() [6/6]

Point4<double > operator* ( const Point4< double > &  p) const
inherited

negative matrix

§ Zero()

void Zero ( )
inherited

Set all the values as zero.

§ IsZero()

bool IsZero ( ) const
inherited

Returns true if the matrix is exactly zero.

§ Get()

void Get ( double *  values)
inherited

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

§ Set() [1/4]

void Set ( const double *  values)
inherited

Set Matrix using an array of 16 values.

§ Set() [2/4]

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

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

§ Set() [3/4]

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

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

§ Set() [4/4]

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

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

§ SetIdentity()

void SetIdentity ( )
inherited

Converts the matrix to an identity matrix.

§ SetScaledIdentity()

void SetScaledIdentity ( double  v)
inherited

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

§ SetTensorProduct()

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

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

§ SetScale() [1/3]

void SetScale ( const double &  uniformScale)
inherited

Sets a uniform scale matrix.

§ SetScale() [2/3]

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

Sets a scale matrix.

§ SetScale() [3/3]

void SetScale ( const Point3< double > &  scale)
inherited

Sets a scale matrix.

§ SetNoScale()

void SetNoScale ( )
inherited

Removes the scale component of the matrix.

§ SetRotationX() [1/2]

void SetRotationX ( double  angle)
inherited

Set as rotation matrix around x axis.

§ SetRotationX() [2/2]

void SetRotationX ( double  sinAngle,
double  cosAngle 
)
inherited

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

§ SetRotationY() [1/2]

void SetRotationY ( double  angle)
inherited

Set as rotation matrix around y axis.

§ SetRotationY() [2/2]

void SetRotationY ( double  sinAngle,
double  cosAngle 
)
inherited

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

§ SetRotationZ() [1/2]

void SetRotationZ ( double  angle)
inherited

Set as rotation matrix around z axis.

§ SetRotationZ() [2/2]

void SetRotationZ ( double  sinAngle,
double  cosAngle 
)
inherited

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

§ SetRotationXYZ()

void SetRotationXYZ ( double  angleX,
double  angleY,
double  angleZ 
)
inherited

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

§ SetRotationZYX()

void SetRotationZYX ( double  angleX,
double  angleY,
double  angleZ 
)
inherited

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

§ SetRotation() [1/3]

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

Set a rotation matrix about the given axis by angle.

§ SetRotation() [2/3]

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

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

§ SetRotation() [3/3]

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

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

§ SetTrans()

void SetTrans ( const Point3< double > &  move)
inherited

Sets a translation matrix with no rotation or scale.

§ AddTrans()

void AddTrans ( const Point3< double > &  move)
inherited

Adds a translation to the matrix.

§ SetTransComponent()

void SetTransComponent ( const Point3< double > &  move)
inherited

Sets the translation component of the matrix.

§ SetView()

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

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

§ SetNormal()

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

Set matrix using normal and approximate x direction.

§ SetPerspective()

void SetPerspective ( double  fov,
double  aspect,
double  znear,
double  zfar 
)
inherited

Set a project matrix with field of view in radians.

§ SetPerspectiveTan()

void SetPerspectiveTan ( double  tan_fov_2,
double  aspect,
double  znear,
double  zfar 
)
inherited

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

§ SetRow()

void SetRow ( int  row,
double  x,
double  y,
double  z,
double  w 
)
inherited

Sets a row of the matrix.

§ SetColumn()

void SetColumn ( int  column,
double  x,
double  y,
double  z,
double  w 
)
inherited

Sets a column of the matrix.

§ SetDiagonal() [1/4]

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

Sets the diagonal values of the matrix.

§ SetDiagonal() [2/4]

void SetDiagonal ( const Point4< double > &  p)
inherited

Sets the diagonal values of the matrix.

§ SetDiagonal() [3/4]

void SetDiagonal ( const Point3< double > &  p)
inherited

Sets the diagonal values of the matrix.

§ SetDiagonal() [4/4]

void SetDiagonal ( const double *  values)
inherited

Sets the 4 diagonal values of the matrix.

§ GetRow() [1/3]

Point4<double > GetRow ( int  row) const
inherited

Returns a row of the matrix.

§ GetRow() [2/3]

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

Returns a row of the matrix.

§ GetRow() [3/3]

void GetRow ( int  row,
double *  values 
) const
inherited

Returns a row of the matrix.

§ GetColumn() [1/3]

Point4<double > GetColumn ( int  col) const
inherited

Returns a column of the matrix.

§ GetColumn() [2/3]

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

Returns a column of the matrix.

§ GetColumn() [3/3]

void GetColumn ( int  col,
double *  values 
) const
inherited

Returns a column of the matrix.

§ GetDiagonal() [1/3]

Point4<double > GetDiagonal ( ) const
inherited

Returns the diagonal of the matrix.

§ GetDiagonal() [2/3]

void GetDiagonal ( Point4< double > &  p) const
inherited

Returns the diagonal of the matrix.

§ GetDiagonal() [3/3]

void GetDiagonal ( double *  values) const
inherited

Returns the diagonal of the matrix.

§ GetSubMatrix() [1/3]

void GetSubMatrix ( Matrix34< double > &  m) const
inherited

Returns the 3x4 portion of the matrix.

§ GetSubMatrix() [2/3]

void GetSubMatrix ( Matrix3< double > &  m) const
inherited

Returns the 3x3 portion of the matrix.

§ GetSubMatrix() [3/3]

void GetSubMatrix ( Matrix2< double > &  m) const
inherited

Returns the 2x2 portion of the matrix.

§ GetSubMatrix34() [1/3]

Matrix34<double > GetSubMatrix34 ( ) const
inherited

Returns the 3x4 portion of the matrix.

§ GetSubMatrix34() [2/3]

void GetSubMatrix34 ( Matrix34< double > &  m) const
inherited

Returns the 3x4 portion of the matrix.

§ GetSubMatrix34() [3/3]

void GetSubMatrix34 ( double *  mdata) const
inherited

Returns the 3x4 portion of the matrix.

§ GetSubMatrix3() [1/3]

Matrix3<double > GetSubMatrix3 ( ) const
inherited

Returns the 3x3 portion of the matrix.

§ GetSubMatrix3() [2/3]

void GetSubMatrix3 ( Matrix3< double > &  m) const
inherited

Returns the 3x3 portion of the matrix.

§ GetSubMatrix3() [3/3]

void GetSubMatrix3 ( double *  mdata) const
inherited

Returns the 3x3 portion of the matrix.

§ GetSubMatrix2() [1/3]

Matrix2<double > GetSubMatrix2 ( ) const
inherited

Returns the 2x2 portion of the matrix.

§ GetSubMatrix2() [2/3]

void GetSubMatrix2 ( Matrix2< double > &  m) const
inherited

Returns the 2x2 portion of the matrix.

§ GetSubMatrix2() [3/3]

void GetSubMatrix2 ( double *  mdata) const
inherited

Returns the 2x2 portion of the matrix.

§ GetTrans() [1/3]

Point3<double > GetTrans ( ) const
inherited

Returns the 3x4 portion of the matrix.

§ GetTrans() [2/3]

void GetTrans ( Point3< double > &  p) const
inherited

Returns the translation component of the matrix.

§ GetTrans() [3/3]

void GetTrans ( double *  trans) const
inherited

Returns the translation component of the matrix.

§ operator==()

bool operator== ( const Matrix4< double > &  right) const
inherited

compare equal

§ operator!=()

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

compare not equal

§ operator()() [1/2]

double & operator() ( int  row,
int  column 
)
inherited

subscript operator

§ operator()() [2/2]

const double & operator() ( int  row,
int  column 
) const
inherited

constant subscript operator

§ operator[]() [1/2]

double & operator[] ( int  i)
inherited

subscript operator

§ operator[]() [2/2]

const double & operator[] ( int  i) const
inherited

constant subscript operator

§ operator-() [1/2]

Matrix4 operator- ( ) const
inherited

negative matrix

§ operator-() [2/2]

Matrix4 operator- ( const Matrix4< double > &  right) const
inherited

subtract one Matrix4 from another

§ operator/()

Matrix4 operator/ ( const double &  value) const
inherited

divide matrix by a value;

§ operator+()

Matrix4 operator+ ( const Matrix4< double > &  right) const
inherited

add two Matrices

§ operator+=()

const Matrix4& operator+= ( const Matrix4< double > &  right)
inherited

add two Matrices modify this

§ operator-=()

const Matrix4& operator-= ( const Matrix4< double > &  right)
inherited

subtract one Matrix4 from another matrix and modify this matrix

§ operator*=() [1/4]

const Matrix4& operator*= ( const Matrix4< double > &  right)
inherited

multiply a matrix with another matrix and modify this matrix

§ operator*=() [2/4]

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

multiply a matrix with another matrix and modify this matrix

§ operator*=() [3/4]

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

multiply a matrix with another matrix and modify this matrix

§ operator*=() [4/4]

const Matrix4& operator*= ( const double &  value)
inherited

multiply a matrix with a value modify this matrix

§ operator/=()

const Matrix4& operator/= ( const double &  value)
inherited

divide the matrix by a value modify the this matrix

§ Transpose()

void Transpose ( )
inherited

< return Transpose of this matrix

§ GetTranspose() [1/2]

void GetTranspose ( Matrix4< double > &  m) const
inherited

< return Transpose of this matrix

§ GetTranspose() [2/2]

Matrix4 GetTranspose ( ) const
inherited

return Transpose of this matrix

§ TransposeMult() [1/2]

Point4<double > TransposeMult ( const Point3< double > &  p) const
inherited

Multiply the give vector with the transpose of the matrix.

§ TransposeMult() [2/2]

Point4<double > TransposeMult ( const Point4< double > &  p) const
inherited

Multiply the give vector with the transpose of the matrix.

§ GetDeterminant()

double GetDeterminant ( ) const
inherited

< Get the determinant of this matrix

§ Invert()

void Invert ( )
inherited

Invert this matrix.

§ GetInverse() [1/2]

void GetInverse ( Matrix4< double > &  inverse) const
inherited

< Get the inverse of this matrix

§ GetInverse() [2/2]

Matrix4 GetInverse ( ) const
inherited

Get the inverse of this matrix.

§ OrthogonalizeX()

void OrthogonalizeX ( )
inherited

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

§ OrthogonalizeY()

void OrthogonalizeY ( )
inherited

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

§ OrthogonalizeZ()

void OrthogonalizeZ ( )
inherited

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

§ IsIdentity()

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

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

§ IsSymmetric()

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

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

§ MatrixIdentity()

static Matrix4 MatrixIdentity ( )
staticinherited

Returns an identity matrix.

§ MatrixView()

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

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

§ MatrixNormal()

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

Returns a matrix using normal, and approximate x direction.

§ MatrixRotationX()

static Matrix4 MatrixRotationX ( double  angle)
staticinherited

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

§ MatrixRotationY()

static Matrix4 MatrixRotationY ( double  angle)
staticinherited

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

§ MatrixRotationZ()

static Matrix4 MatrixRotationZ ( double  angle)
staticinherited

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

§ MatrixRotation() [1/2]

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

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

§ MatrixRotation() [2/2]

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

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

§ MatrixScale() [1/3]

static Matrix4 MatrixScale ( const double &  uniformScale)
staticinherited

Returns a uniform scale matrix.

§ MatrixScale() [2/3]

static Matrix4 MatrixScale ( const double &  scaleX,
const double &  scaleY,
const double &  scaleZ 
)
staticinherited

Returns a scale matrix.

§ MatrixScale() [3/3]

static Matrix4 MatrixScale ( const Point3< double > &  scale)
staticinherited

Returns a scale matrix.

§ MatrixTrans()

static Matrix4 MatrixTrans ( const Point3< double > &  move)
staticinherited

Returns a translation matrix with no rotation or scale.

§ MatrixPerspective()

static Matrix4 MatrixPerspective ( double  fov,
double  aspect,
double  znear,
double  zfar 
)
staticinherited

Returns a project matrix with field of view in radians.

§ MatrixPerspectiveTan()

static Matrix4 MatrixPerspectiveTan ( double  tan_fov_2,
double  aspect,
double  znear,
double  zfar 
)
staticinherited

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

Member Data Documentation

§ data

double data[16]
inherited

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