A 4x4 matrix class. More...

#include "murl_math_matrix.h"

Public Types

enum  Component { , NUM_COMPONENTS }
 Enumeration of the components raw data index. More...
 
enum  ComponentMask {
  MASK_NONE, MASK_XX, MASK_YX, MASK_ZX,
  MASK_WX, MASK_XY, MASK_YY, MASK_ZY,
  MASK_WY, MASK_XZ, MASK_YZ, MASK_ZZ,
  MASK_WZ, MASK_XW, MASK_YW, MASK_ZW,
  MASK_WW, MASK_ALL
}
 Enumeration of the components' bit masks. More...
 
enum  PredefinedType { UNINITIALIZED, ZERO, IDENTITY }
 Enumeration of the predefined initialization types for constructing a Matrix(PredefinedType type). More...
 
enum  HintFlags {
  FLAG_TRANSLATION, FLAG_ROTATION, FLAG_SCALE, FLAG_ARBITRARY,
  FLAG_NO_HINTS
}
 Enumeration of hint flags. More...
 
typedef DataType ValueType
 The template parameter value type. More...
 

Public Member Functions

 Matrix ()
 The default constructor, creating an identity matrix. More...
 
 Matrix (PredefinedType type)
 Constructor to create a matrix from a predefined type. More...
 
template<class DataType2 >
 Matrix (const Matrix< DataType2 > &matrix)
 The copy constructor using a Matrix of different type. More...
 
UInt32 GetHints () const
 Get the hint flags. More...
 
void SetHints (UInt32 mask)
 Set the hint flags. More...
 
void ClearHints (UInt32 mask)
 Clear hint flags. More...
 
void EnableHints (Bool autoDetect)
 Enable hints. More...
 
void DisableHints ()
 Disable hints.
 
DataType operator[] (UInt32 index) const
 Get a component element. More...
 
DataType & operator[] (UInt32 index)
 Get a writeable reference to a component element. More...
 
const DataType * GetPointer () const
 Get a const pointer to the raw data. More...
 
DataType * GetPointer ()
 Get a writeable pointer to the raw data. More...
 
Matrixoperator*= (const Matrix &m)
 In-place matrix-matrix multiplication operator. More...
 
Matrix operator* (const Matrix &rhs) const
 Matrix-matrix multiplication operator. More...
 
Vector< DataType > operator* (const Vector< DataType > &rhs) const
 Matrix-vector multiplication operator. More...
 
void Clear ()
 Clear all components of the matrix instance. More...
 
void SetIdentity ()
 Load the identity matrix to the current instance.
 
void SetIdentityRotation ()
 Load the identity matrix to the upper 3x3 matrix.
 
void Set (const Matrix &m)
 Copy the content of a source matrix to the matrix instance. More...
 
void SetTranslationComponent (const Vector< DataType > &v)
 Set the translation component to a given vector. More...
 
void SetTranslationComponent (DataType x, DataType y, DataType z)
 Set the translation component to given values. More...
 
void SetTranslationComponentX (DataType x)
 Set the translation X component. More...
 
void SetTranslationComponentY (DataType y)
 Set the translation Y component. More...
 
void SetTranslationComponentZ (DataType z)
 Set the translation Z component. More...
 
const Vector< DataType > & GetTranslationComponent () const
 Get the translation component vector. More...
 
DataType GetTranslationComponentX () const
 Get the translation component's X value. More...
 
DataType GetTranslationComponentY () const
 Get the translation component's Y value. More...
 
DataType GetTranslationComponentZ () const
 Get the translation component's Z value. More...
 
void SetScalingComponent (const Vector< DataType > &v)
 Set the scaling component using a vector. More...
 
void SetScalingComponent (DataType x, DataType y, DataType z)
 Set the scaling component using three distinct values. More...
 
Vector< DataType > GetScalingComponent () const
 Get a vector containing the X, Y and Z scaling components of the matrix. More...
 
DataType GetScalingComponentX () const
 Get the X scale value of the matrix. More...
 
DataType GetScalingComponentY () const
 Get the Y scale value of the matrix. More...
 
DataType GetScalingComponentZ () const
 Get the Z scale value of the matrix. More...
 
void SetRotationComponent (const Vector< DataType > &axisAngle)
 Set the rotation component by a vector. More...
 
void SetRotationComponent (DataType angle, const Vector< DataType > &axis)
 Set the rotation component by an angle and vector. More...
 
void SetRotationComponentAxisAngle (DataType angle, DataType ax, DataType ay, DataType az)
 Set the rotation component by an angle and vector components. More...
 
void SetRotationComponent (DataType angleX, DataType angleY, DataType angleZ)
 Set the rotation component by euler angles. More...
 
void SetRotationComponentXYZ (DataType angleX, DataType angleY, DataType angleZ, IEnums::RotationOrder rotationOrder)
 Set the rotation component by euler angles with a given rotation order. More...
 
void SetRotationComponentX (DataType angleX)
 Set the rotation component of the transformation matrix to only rotate around the X axis. More...
 
void SetRotationComponentY (DataType angleY)
 Set the rotation component of the transformation matrix to only rotate around the Y axis. More...
 
void SetRotationComponentZ (DataType angleZ)
 Set the rotation component of the transformation matrix to only rotate around the Z axis. More...
 
Vector< DataType > GetEulerRotation () const
 Get the euler rotation angles. More...
 
void SetRotationComponent (const Quaternion< DataType > &q)
 Set the rotation component by a quaternion. More...
 
void SetRotationComponent (const Matrix< DataType > &rotationMatrix)
 Set the rotation component by a rotation matrix. More...
 
Matrix< DataType > GetRotationAndScalingComponent ()
 Extract the rotation and scaling component of the matrix. More...
 
const Vector< DataType > & GetColumnVector (UInt32 columnIndex) const
 Get the vector of a specified column. More...
 
void SetColumnVector (UInt32 columnIndex, const Vector< DataType > &vec)
 Set a specified column by a vector. More...
 
Vector< DataType > GetRowVector (UInt32 rowIndex) const
 Get the vector of a specified row. More...
 
void SetRowVector (UInt32 rowIndex, const Vector< DataType > vec)
 Set a specified row by a vector. More...
 
void MultiplySelf (const Matrix &m)
 In-place matrix-matrix multiplication. More...
 
void MultiplySelfReverse (const Matrix &m)
 In-place reverse matrix-matrix multiplication. More...
 
void TransposeSelf ()
 In-place transpose of the matrix.
 
void InvertSelf ()
 In-place inversion of the matrix.
 
Vector< DataType > Transform (const Vector< DataType > &v) const
 Transform (multiply) a vector by the matrix. More...
 
Vector< DataType > Rotate (const Vector< DataType > &v) const
 Rotate a vector by the matrix. More...
 
Vector< DataType > Translate (const Vector< DataType > &v) const
 Translate a vector by the matrix (add the translation component). More...
 
Matrix Multiply (const Matrix &m) const
 Multiply a matrix by the matrix. More...
 
Vector< DataType > Multiply (const Vector< DataType > &v) const
 Multiply a vector by the matrix. More...
 
Matrix Transpose () const
 Get the transposed matrix. More...
 
Matrix InvertTransRot () const
 Fast inversion of a rotation/translation matrix. More...
 
Matrix InvertTransRotScl () const
 Fast inversion of a rotation/translation/scaling matrix. More...
 
Matrix Invert () const
 Matrix inversion. More...
 
Vector< DataType > Solve (const Vector< DataType > &v) const
 Solve the matrix by a vector. More...
 
void SetElementAt (UInt32 row, UInt32 col, DataType value)
 Set a component element. More...
 
DataType GetElementAt (UInt32 row, UInt32 col) const
 Get a component element. More...
 
DataType & GetElementAt (UInt32 row, UInt32 col)
 Get a writeable reference to a component element. More...
 
void SetElement (Component element, DataType value)
 Set a component element. More...
 
DataType GetElement (Component element) const
 Get a component element. More...
 
DataType & GetElement (Component element)
 Get a writeable reference to a component element. More...
 
void SetXX (DataType value)
 Set the XX component. More...
 
void SetXY (DataType value)
 Set the XY component. More...
 
void SetXZ (DataType value)
 Set the XZ component. More...
 
void SetXW (DataType value)
 Set the XW component. More...
 
void SetYX (DataType value)
 Set the YX component. More...
 
void SetYY (DataType value)
 Set the YY component. More...
 
void SetYZ (DataType value)
 Set the YZ component. More...
 
void SetYW (DataType value)
 Set the YW component. More...
 
void SetZX (DataType value)
 Set the ZX component. More...
 
void SetZY (DataType value)
 Set the ZY component. More...
 
void SetZZ (DataType value)
 Set the ZZ component. More...
 
void SetZW (DataType value)
 Set the ZW component. More...
 
void SetWX (DataType value)
 Set the WX component. More...
 
void SetWY (DataType value)
 Set the WY component. More...
 
void SetWZ (DataType value)
 Set the WZ component. More...
 
void SetWW (DataType value)
 Set the WW component. More...
 
DataType GetXX () const
 Get the XX component. More...
 
DataType GetXY () const
 Get the XY component. More...
 
DataType GetXZ () const
 Get the XZ component. More...
 
DataType GetXW () const
 Get the XW component. More...
 
DataType GetYX () const
 Get the YX component. More...
 
DataType GetYY () const
 Get the YY component. More...
 
DataType GetYZ () const
 Get the YZ component. More...
 
DataType GetYW () const
 Get the YW component. More...
 
DataType GetZX () const
 Get the ZX component. More...
 
DataType GetZY () const
 Get the ZY component. More...
 
DataType GetZZ () const
 Get the ZZ component. More...
 
DataType GetZW () const
 Get the ZW component. More...
 
DataType GetWX () const
 Get the WX component. More...
 
DataType GetWY () const
 Get the WY component. More...
 
DataType GetWZ () const
 Get the WZ component. More...
 
DataType GetWW () const
 Get the WW component. More...
 
Bool IsEqual (const Matrix &m) const
 Check if the matrix is equal to a given matrix. More...
 
Bool IsEqual (const Matrix &m, DataType epsilon) const
 Check if the matrix is equal to a given matrix. More...
 
Bool IsIdentity () const
 Check if the matrix is equal to the identity matrix. More...
 
Bool IsIdentity (DataType epsilon) const
 Check if the matrix is equal to the identity matrix. More...
 
String ToString () const
 Get the string representation of the object. More...
 
SInt32 GetCount () const
 Get the number of elements in the object. More...
 

Static Public Member Functions

static Matrix LookAt (const Vector< DataType > &center, const Vector< DataType > &target, const Vector< DataType > &up)
 Create a look-at matrix from a given center point, target point and up vector. More...
 

Protected Attributes

union {
   DataType   mComponents [NUM_COMPONENTS]
 The components data array. More...
 
   struct {
   } 
 The components member struct. More...
 
}; 
 The components storage union overlaps the raw data array mComponents and the component structure.
 
UInt32 mFlags
 The hint flags. More...
 

Friends

bool operator== (const Matrix< DataType > &lhs, const Matrix< DataType > &rhs)
 Equal to comparison operator. More...
 
bool operator!= (const Matrix< DataType > &lhs, const Matrix< DataType > &rhs)
 Not equal to comparison operator. More...
 

Detailed Description

template<class DataType>
class Murl::Math::Matrix< DataType >

A 4x4 matrix class.

Member Typedef Documentation

◆ ValueType

template<class DataType>
typedef DataType Murl::Math::Matrix< DataType >::ValueType

The template parameter value type.

Member Enumeration Documentation

◆ Component

template<class DataType>
enum Murl::Math::Matrix::Component

Enumeration of the components raw data index.

The components can be accessed by using the [] operator.

Enumerator
NUM_COMPONENTS 

The number of components.

◆ ComponentMask

template<class DataType>
enum Murl::Math::Matrix::ComponentMask

Enumeration of the components' bit masks.

Enumerator
MASK_NONE 

No component.

MASK_XX 

XX component mask.

MASK_YX 

YX component mask.

MASK_ZX 

ZX component mask.

MASK_WX 

WX component mask.

MASK_XY 

XY component mask.

MASK_YY 

YY component mask.

MASK_ZY 

ZY component mask.

MASK_WY 

WY component mask.

MASK_XZ 

XZ component mask.

MASK_YZ 

YZ component mask.

MASK_ZZ 

ZZ component mask.

MASK_WZ 

WZ component mask.

MASK_XW 

XW component mask.

MASK_YW 

YW component mask.

MASK_ZW 

ZW component mask.

MASK_WW 

WW component mask.

MASK_ALL 

All components.

◆ PredefinedType

template<class DataType>
enum Murl::Math::Matrix::PredefinedType

Enumeration of the predefined initialization types for constructing a Matrix(PredefinedType type).

Enumerator
UNINITIALIZED 

Create an uninitialized instance.

ZERO 

Initialize with zero.

IDENTITY 

Initialize with the identity matrix.

◆ HintFlags

template<class DataType>
enum Murl::Math::Matrix::HintFlags

Enumeration of hint flags.

Hints are used internally to optimize several operations.

Enumerator
FLAG_TRANSLATION 

The matrix contains translation components.

FLAG_ROTATION 

The matrix contains rotation components.

FLAG_SCALE 

The matrix contains scale components.

FLAG_ARBITRARY 

The matrix contains arbitrary components.

FLAG_NO_HINTS 

The matrix has no component hints.

Constructor & Destructor Documentation

◆ Matrix() [1/3]

template<class DataType>
Murl::Math::Matrix< DataType >::Matrix ( )
inline

The default constructor, creating an identity matrix.

Hints are disabled by default.

◆ Matrix() [2/3]

template<class DataType>
Murl::Math::Matrix< DataType >::Matrix ( PredefinedType  type)
inline

Constructor to create a matrix from a predefined type.

Hints are disabled by default.

Parameters
typeThe predefined type.

◆ Matrix() [3/3]

template<class DataType>
template<class DataType2 >
Murl::Math::Matrix< DataType >::Matrix ( const Matrix< DataType2 > &  matrix)
inline

The copy constructor using a Matrix of different type.

Parameters
matrixThe Matrix to copy.

Member Function Documentation

◆ LookAt()

template<class DataType>
static Matrix Murl::Math::Matrix< DataType >::LookAt ( const Vector< DataType > &  center,
const Vector< DataType > &  target,
const Vector< DataType > &  up 
)
inlinestatic

Create a look-at matrix from a given center point, target point and up vector.

Parameters
centerThe center point position vector.
targetThe target point position vector.
upThe up direction vector.
Returns
The calculated matrix.

◆ GetHints()

template<class DataType>
UInt32 Murl::Math::Matrix< DataType >::GetHints ( ) const
inline

Get the hint flags.

Returns
The bit-mask of hints.

◆ SetHints()

template<class DataType>
void Murl::Math::Matrix< DataType >::SetHints ( UInt32  mask)
inline

Set the hint flags.

Parameters
maskThe bit-mask of hints to set.

◆ ClearHints()

template<class DataType>
void Murl::Math::Matrix< DataType >::ClearHints ( UInt32  mask)
inline

Clear hint flags.

Parameters
maskThe bit-mask of hints to clear.

◆ EnableHints()

template<class DataType>
void Murl::Math::Matrix< DataType >::EnableHints ( Bool  autoDetect)
inline

Enable hints.

Enabling hints requires good knowlede of the entire Matrix class e.g. several setter methods do not consider hints.

Parameters
autoDetectEvaluate the correct hints if true.

◆ operator[]() [1/2]

template<class DataType>
DataType Murl::Math::Matrix< DataType >::operator[] ( UInt32  index) const
inline

Get a component element.

Parameters
indexThe component index, see enum Component.
Returns
The component value.

◆ operator[]() [2/2]

template<class DataType>
DataType& Murl::Math::Matrix< DataType >::operator[] ( UInt32  index)
inline

Get a writeable reference to a component element.

Parameters
indexThe component index, see enum Component.
Returns
The component value reference.

◆ GetPointer() [1/2]

template<class DataType>
const DataType* Murl::Math::Matrix< DataType >::GetPointer ( ) const
inline

Get a const pointer to the raw data.

Returns
Const pointer to the raw data.

◆ GetPointer() [2/2]

template<class DataType>
DataType* Murl::Math::Matrix< DataType >::GetPointer ( )
inline

Get a writeable pointer to the raw data.

Returns
Pointer to the raw data.

◆ operator*=()

template<class DataType>
Matrix& Murl::Math::Matrix< DataType >::operator*= ( const Matrix< DataType > &  m)
inline

In-place matrix-matrix multiplication operator.

Parameters
mThe matrix to multiply.
Returns
The object itself.

◆ operator*() [1/2]

template<class DataType>
Matrix Murl::Math::Matrix< DataType >::operator* ( const Matrix< DataType > &  rhs) const
inline

Matrix-matrix multiplication operator.

Parameters
rhsThe right hand side matrix.
Returns
The multiplied matrix.

◆ operator*() [2/2]

template<class DataType>
Vector<DataType> Murl::Math::Matrix< DataType >::operator* ( const Vector< DataType > &  rhs) const
inline

Matrix-vector multiplication operator.

Parameters
rhsThe right hand side vector.
Returns
The multiplied vector.

◆ Clear()

template<class DataType>
void Murl::Math::Matrix< DataType >::Clear ( )
inline

Clear all components of the matrix instance.

Set the component data array to zero.

Referenced by Murl::Math::Matrix< Real >::Matrix().

◆ Set()

template<class DataType>
void Murl::Math::Matrix< DataType >::Set ( const Matrix< DataType > &  m)
inline

Copy the content of a source matrix to the matrix instance.

Parameters
mThe matrix to copy from.

Referenced by Murl::Math::Matrix< Real >::InvertSelf(), Murl::Math::Matrix< Real >::MultiplySelf(), and Murl::Math::Matrix< Real >::MultiplySelfReverse().

◆ SetTranslationComponent() [1/2]

template<class DataType>
void Murl::Math::Matrix< DataType >::SetTranslationComponent ( const Vector< DataType > &  v)
inline

Set the translation component to a given vector.

Parameters
vThe vector to set the translation component.

Referenced by Murl::Math::Matrix< Real >::SetTranslationComponent().

◆ SetTranslationComponent() [2/2]

template<class DataType>
void Murl::Math::Matrix< DataType >::SetTranslationComponent ( DataType  x,
DataType  y,
DataType  z 
)
inline

Set the translation component to given values.

Parameters
xThe X translation component.
yThe Y translation component.
zThe Z translation component.

◆ SetTranslationComponentX()

template<class DataType>
void Murl::Math::Matrix< DataType >::SetTranslationComponentX ( DataType  x)
inline

Set the translation X component.

Parameters
xThe X translation component.

◆ SetTranslationComponentY()

template<class DataType>
void Murl::Math::Matrix< DataType >::SetTranslationComponentY ( DataType  y)
inline

Set the translation Y component.

Parameters
yThe Y translation component.

◆ SetTranslationComponentZ()

template<class DataType>
void Murl::Math::Matrix< DataType >::SetTranslationComponentZ ( DataType  z)
inline

Set the translation Z component.

Parameters
zThe Z translation component.

◆ GetTranslationComponent()

template<class DataType>
const Vector<DataType>& Murl::Math::Matrix< DataType >::GetTranslationComponent ( ) const
inline

Get the translation component vector.

Returns
The translation component vector.

◆ GetTranslationComponentX()

template<class DataType>
DataType Murl::Math::Matrix< DataType >::GetTranslationComponentX ( ) const
inline

Get the translation component's X value.

Returns
The X value.

◆ GetTranslationComponentY()

template<class DataType>
DataType Murl::Math::Matrix< DataType >::GetTranslationComponentY ( ) const
inline

Get the translation component's Y value.

Returns
The Y value.

◆ GetTranslationComponentZ()

template<class DataType>
DataType Murl::Math::Matrix< DataType >::GetTranslationComponentZ ( ) const
inline

Get the translation component's Z value.

Returns
The Z value.

◆ SetScalingComponent() [1/2]

template<class DataType>
void Murl::Math::Matrix< DataType >::SetScalingComponent ( const Vector< DataType > &  v)
inline

Set the scaling component using a vector.

This method only sets the upper 3 diagonal elements of the matrix, so it should only be applied to matrices without rotation.

Parameters
vThe vector containing X, Y and Z scaling components.

Referenced by Murl::Math::Matrix< Real >::SetScalingComponent().

◆ SetScalingComponent() [2/2]

template<class DataType>
void Murl::Math::Matrix< DataType >::SetScalingComponent ( DataType  x,
DataType  y,
DataType  z 
)
inline

Set the scaling component using three distinct values.

This method only sets the upper 3 diagonal elements of the matrix, so it should only be applied to matrices without rotation.

Parameters
xThe X scaling factor.
yThe Y scaling factor.
zThe Z scaling factor.

◆ GetScalingComponent()

template<class DataType>
Vector<DataType> Murl::Math::Matrix< DataType >::GetScalingComponent ( ) const
inline

Get a vector containing the X, Y and Z scaling components of the matrix.

Returns
The scaling components.

◆ GetScalingComponentX()

template<class DataType>
DataType Murl::Math::Matrix< DataType >::GetScalingComponentX ( ) const
inline

Get the X scale value of the matrix.

Returns
The X scale value.

◆ GetScalingComponentY()

template<class DataType>
DataType Murl::Math::Matrix< DataType >::GetScalingComponentY ( ) const
inline

Get the Y scale value of the matrix.

Returns
The Y scale value.

◆ GetScalingComponentZ()

template<class DataType>
DataType Murl::Math::Matrix< DataType >::GetScalingComponentZ ( ) const
inline

Get the Z scale value of the matrix.

Returns
The Z scale value.

◆ SetRotationComponent() [1/5]

template<class DataType>
void Murl::Math::Matrix< DataType >::SetRotationComponent ( const Vector< DataType > &  axisAngle)
inline

Set the rotation component by a vector.

Parameters
axisAngleThe vector of the rotation including the angle in w component in radiants.

◆ SetRotationComponent() [2/5]

template<class DataType>
void Murl::Math::Matrix< DataType >::SetRotationComponent ( DataType  angle,
const Vector< DataType > &  axis 
)
inline

Set the rotation component by an angle and vector.

Parameters
angleThe angle of the rotation in radiants.
axisThe vector of the rotation.

◆ SetRotationComponentAxisAngle()

template<class DataType>
void Murl::Math::Matrix< DataType >::SetRotationComponentAxisAngle ( DataType  angle,
DataType  ax,
DataType  ay,
DataType  az 
)
inline

Set the rotation component by an angle and vector components.

Parameters
angleThe angle of the rotation in radiants.
axThe x-component of the rotation vector.
ayThe y-component of the rotation vector.
azThe z-component of the rotation vector.

Referenced by Murl::Math::Matrix< Real >::SetRotationComponent().

◆ SetRotationComponent() [3/5]

template<class DataType>
void Murl::Math::Matrix< DataType >::SetRotationComponent ( DataType  angleX,
DataType  angleY,
DataType  angleZ 
)
inline

Set the rotation component by euler angles.

The default axis rotation order is IEnums::ROTATION_ORDER_ZYX.

Parameters
angleXThe x-axis angle in radiants.
angleYThe y-axis angle in radiants.
angleZThe z-axis angle in radiants.

◆ SetRotationComponentXYZ()

template<class DataType>
void Murl::Math::Matrix< DataType >::SetRotationComponentXYZ ( DataType  angleX,
DataType  angleY,
DataType  angleZ,
IEnums::RotationOrder  rotationOrder 
)
inline

Set the rotation component by euler angles with a given rotation order.

Parameters
angleXThe x-axis angle in radiants.
angleYThe y-axis angle in radiants.
angleZThe z-axis angle in radiants.
rotationOrderThe axis rotation order.

Referenced by Murl::Math::Matrix< Real >::SetRotationComponent().

◆ SetRotationComponentX()

template<class DataType>
void Murl::Math::Matrix< DataType >::SetRotationComponentX ( DataType  angleX)
inline

Set the rotation component of the transformation matrix to only rotate around the X axis.

This method directly overwrites the upper 3x3 matrix of the internal transformation by calculating and applying a rotation around the unit X axis. The angle value must be given in radians. A positive value result in a clockwise rotation.

Parameters
angleXThe x-axis angle in radiants.

◆ SetRotationComponentY()

template<class DataType>
void Murl::Math::Matrix< DataType >::SetRotationComponentY ( DataType  angleY)
inline

Set the rotation component of the transformation matrix to only rotate around the Y axis.

This method directly overwrites the upper 3x3 matrix of the internal transformation by calculating and applying a rotation around the unit Y axis. The angle value must be given in radians. A positive value result in a clockwise rotation.

Parameters
angleYThe y-axis angle in radiants.

◆ SetRotationComponentZ()

template<class DataType>
void Murl::Math::Matrix< DataType >::SetRotationComponentZ ( DataType  angleZ)
inline

Set the rotation component of the transformation matrix to only rotate around the Z axis.

This method directly overwrites the upper 3x3 matrix of the internal transformation by calculating and applying a rotation around the unit Z axis. The angle value must be given in radians. A positive value result in a clockwise rotation.

Parameters
angleZThe z-axis angle in radiants.

◆ GetEulerRotation()

template<class DataType>
Vector<DataType> Murl::Math::Matrix< DataType >::GetEulerRotation ( ) const
inline

Get the euler rotation angles.

Extract the euer rotation angles based on https://d3cw3dd2w32x2b.cloudfront.net/wp-content/uploads/2012/07/euler-angles.pdf

Returns
The euler rotation angles in radiants. The vector members x, y and z corresponds to the axis angles.

◆ SetRotationComponent() [4/5]

template<class DataType>
void Murl::Math::Matrix< DataType >::SetRotationComponent ( const Quaternion< DataType > &  q)
inline

Set the rotation component by a quaternion.

Parameters
qThe quaternion.

◆ SetRotationComponent() [5/5]

template<class DataType>
void Murl::Math::Matrix< DataType >::SetRotationComponent ( const Matrix< DataType > &  rotationMatrix)
inline

Set the rotation component by a rotation matrix.

Parameters
rotationMatrixThe rotation matrix.

◆ GetRotationAndScalingComponent()

template<class DataType>
Matrix<DataType> Murl::Math::Matrix< DataType >::GetRotationAndScalingComponent ( )
inline

Extract the rotation and scaling component of the matrix.

Returns
A matrix containing only scaling and rotation.

◆ GetColumnVector()

template<class DataType>
const Vector<DataType>& Murl::Math::Matrix< DataType >::GetColumnVector ( UInt32  columnIndex) const
inline

Get the vector of a specified column.

Parameters
columnIndexThe column index in range [0 .. 3].
Returns
The vector of the colum at the specified index.

◆ SetColumnVector()

template<class DataType>
void Murl::Math::Matrix< DataType >::SetColumnVector ( UInt32  columnIndex,
const Vector< DataType > &  vec 
)
inline

Set a specified column by a vector.

Hints are not considered.

Parameters
columnIndexThe column index in range [0 .. 3].
vecThe vector to set the colum at the specified index.

◆ GetRowVector()

template<class DataType>
Vector<DataType> Murl::Math::Matrix< DataType >::GetRowVector ( UInt32  rowIndex) const
inline

Get the vector of a specified row.

Parameters
rowIndexThe row index in range [0 .. 3].
Returns
The vector of the row at the specified index.

◆ SetRowVector()

template<class DataType>
void Murl::Math::Matrix< DataType >::SetRowVector ( UInt32  rowIndex,
const Vector< DataType >  vec 
)
inline

Set a specified row by a vector.

Hints are not considered.

Parameters
rowIndexThe row index in range [0 .. 3].
vecThe vector to set the row at the specified index.

◆ MultiplySelf()

template<class DataType>
void Murl::Math::Matrix< DataType >::MultiplySelf ( const Matrix< DataType > &  m)
inline

In-place matrix-matrix multiplication.

Parameters
mThe matrix to multiply.

Referenced by Murl::Math::Matrix< Real >::operator*=().

◆ MultiplySelfReverse()

template<class DataType>
void Murl::Math::Matrix< DataType >::MultiplySelfReverse ( const Matrix< DataType > &  m)
inline

In-place reverse matrix-matrix multiplication.

Parameters
mThe matrix to multiply.

◆ Transform()

template<class DataType>
Vector<DataType> Murl::Math::Matrix< DataType >::Transform ( const Vector< DataType > &  v) const
inline

Transform (multiply) a vector by the matrix.

Parameters
vThe vector to mulitply.
Returns
The multiplied vector.

◆ Rotate()

template<class DataType>
Vector<DataType> Murl::Math::Matrix< DataType >::Rotate ( const Vector< DataType > &  v) const
inline

Rotate a vector by the matrix.

Parameters
vThe vector to rotate.
Returns
The rotated vector.

◆ Translate()

template<class DataType>
Vector<DataType> Murl::Math::Matrix< DataType >::Translate ( const Vector< DataType > &  v) const
inline

Translate a vector by the matrix (add the translation component).

Parameters
vThe vector to translate.
Returns
The translated vector.

◆ Multiply() [1/2]

template<class DataType>
Matrix Murl::Math::Matrix< DataType >::Multiply ( const Matrix< DataType > &  m) const
inline

Multiply a matrix by the matrix.

Parameters
mThe matrix to mulitply.
Returns
The multiplied matrix.

Referenced by Murl::Math::Matrix< Real >::MultiplySelf(), Murl::Math::Matrix< Real >::operator*(), and Murl::Math::Matrix< Real >::Transform().

◆ Multiply() [2/2]

template<class DataType>
Vector<DataType> Murl::Math::Matrix< DataType >::Multiply ( const Vector< DataType > &  v) const
inline

Multiply a vector by the matrix.

Parameters
vThe vector to mulitply.
Returns
The multiplied vector.

◆ Transpose()

template<class DataType>
Matrix Murl::Math::Matrix< DataType >::Transpose ( ) const
inline

Get the transposed matrix.

Returns
The transposed matrix.

◆ InvertTransRot()

template<class DataType>
Matrix Murl::Math::Matrix< DataType >::InvertTransRot ( ) const
inline

Fast inversion of a rotation/translation matrix.

This method can be used to quickly invert a given matrix that is only made up from rotation and translation operations. If the matrix also contains any scaling operations, use InvertTransRotScl() instead. For general 4x4 matrices, use Invert().

Returns
The inverted rotation/translation matrix.

◆ InvertTransRotScl()

template<class DataType>
Matrix Murl::Math::Matrix< DataType >::InvertTransRotScl ( ) const
inline

Fast inversion of a rotation/translation/scaling matrix.

This method can be used to quickly invert a given matrix that is only made up from rotation, translation and scaling operations. If only rotation and translation is present, use InvertTransRot(). For general 4x4 matrices, use Invert() instead.

Returns
The inverted rotation/translation/scaling matrix.

◆ Invert()

template<class DataType>
Matrix Murl::Math::Matrix< DataType >::Invert ( ) const
inline

Matrix inversion.

This method can be used to calculate the inverse of a general 4x4 matrix. In case the matrix is only made up from rotation and translation operations, it is possible to use InvertTransRot() instead. If it also contains additional scaling operations, InvertTransRotScl() can be used; both alternative methods show better overall performance.

Returns
The inverted matrix.

Referenced by Murl::Math::Matrix< Real >::InvertSelf().

◆ Solve()

template<class DataType>
Vector<DataType> Murl::Math::Matrix< DataType >::Solve ( const Vector< DataType > &  v) const
inline

Solve the matrix by a vector.

Parameters
vThe vector to solve.
Returns
The solved vector.

◆ SetElementAt()

template<class DataType>
void Murl::Math::Matrix< DataType >::SetElementAt ( UInt32  row,
UInt32  col,
DataType  value 
)
inline

Set a component element.

Hints are not considered.

Parameters
rowThe row in range [0 .. 3].
colThe column in range [0 .. 3].
valueThe value to set.

◆ GetElementAt() [1/2]

template<class DataType>
DataType Murl::Math::Matrix< DataType >::GetElementAt ( UInt32  row,
UInt32  col 
) const
inline

Get a component element.

Parameters
rowThe row in range [0 .. 3].
colThe column in range [0 .. 3].
Returns
The value at the given position.

Referenced by Murl::Math::Matrix< Real >::Invert(), and Murl::Math::Matrix< Real >::Solve().

◆ GetElementAt() [2/2]

template<class DataType>
DataType& Murl::Math::Matrix< DataType >::GetElementAt ( UInt32  row,
UInt32  col 
)
inline

Get a writeable reference to a component element.

Parameters
rowThe row in range [0 .. 3].
colThe column in range [0 .. 3].
Returns
The value at the given position.

◆ SetElement()

template<class DataType>
void Murl::Math::Matrix< DataType >::SetElement ( Component  element,
DataType  value 
)
inline

Set a component element.

Hints are not considered.

Parameters
elementThe element
valueThe value to set.

◆ GetElement() [1/2]

template<class DataType>
DataType Murl::Math::Matrix< DataType >::GetElement ( Component  element) const
inline

Get a component element.

Parameters
elementThe element's component.
Returns
The value at the given position.

◆ GetElement() [2/2]

template<class DataType>
DataType& Murl::Math::Matrix< DataType >::GetElement ( Component  element)
inline

Get a writeable reference to a component element.

Parameters
elementThe element's component.
Returns
The value at the given position.

◆ SetXX()

template<class DataType>
void Murl::Math::Matrix< DataType >::SetXX ( DataType  value)
inline

Set the XX component.

Hints are not considered.

Parameters
valueThe XX component value to set.

◆ SetXY()

template<class DataType>
void Murl::Math::Matrix< DataType >::SetXY ( DataType  value)
inline

Set the XY component.

Hints are not considered.

Parameters
valueThe XY component value to set.

◆ SetXZ()

template<class DataType>
void Murl::Math::Matrix< DataType >::SetXZ ( DataType  value)
inline

Set the XZ component.

Hints are not considered.

Parameters
valueThe XZ component value to set.

◆ SetXW()

template<class DataType>
void Murl::Math::Matrix< DataType >::SetXW ( DataType  value)
inline

Set the XW component.

Hints are not considered.

Parameters
valueThe XW component value to set.

◆ SetYX()

template<class DataType>
void Murl::Math::Matrix< DataType >::SetYX ( DataType  value)
inline

Set the YX component.

Hints are not considered.

Parameters
valueThe YX component value to set.

◆ SetYY()

template<class DataType>
void Murl::Math::Matrix< DataType >::SetYY ( DataType  value)
inline

Set the YY component.

Hints are not considered.

Parameters
valueThe YY component value to set.

◆ SetYZ()

template<class DataType>
void Murl::Math::Matrix< DataType >::SetYZ ( DataType  value)
inline

Set the YZ component.

Hints are not considered.

Parameters
valueThe YZ component value to set.

◆ SetYW()

template<class DataType>
void Murl::Math::Matrix< DataType >::SetYW ( DataType  value)
inline

Set the YW component.

Hints are not considered.

Parameters
valueThe YW component value to set.

◆ SetZX()

template<class DataType>
void Murl::Math::Matrix< DataType >::SetZX ( DataType  value)
inline

Set the ZX component.

Hints are not considered.

Parameters
valueThe ZX component value to set.

◆ SetZY()

template<class DataType>
void Murl::Math::Matrix< DataType >::SetZY ( DataType  value)
inline

Set the ZY component.

Hints are not considered.

Parameters
valueThe ZY component value to set.

◆ SetZZ()

template<class DataType>
void Murl::Math::Matrix< DataType >::SetZZ ( DataType  value)
inline

Set the ZZ component.

Hints are not considered.

Parameters
valueThe ZZ component value to set.

◆ SetZW()

template<class DataType>
void Murl::Math::Matrix< DataType >::SetZW ( DataType  value)
inline

Set the ZW component.

Hints are not considered.

Parameters
valueThe ZW component value to set.

◆ SetWX()

template<class DataType>
void Murl::Math::Matrix< DataType >::SetWX ( DataType  value)
inline

Set the WX component.

Hints are not considered.

Parameters
valueThe WX component value to set.

◆ SetWY()

template<class DataType>
void Murl::Math::Matrix< DataType >::SetWY ( DataType  value)
inline

Set the WY component.

Hints are not considered.

Parameters
valueThe WY component value to set.

◆ SetWZ()

template<class DataType>
void Murl::Math::Matrix< DataType >::SetWZ ( DataType  value)
inline

Set the WZ component.

Hints are not considered.

Parameters
valueThe WZ component value to set.

◆ SetWW()

template<class DataType>
void Murl::Math::Matrix< DataType >::SetWW ( DataType  value)
inline

Set the WW component.

Hints are not considered.

Parameters
valueThe WW component value to set.

◆ GetXX()

template<class DataType>
DataType Murl::Math::Matrix< DataType >::GetXX ( ) const
inline

Get the XX component.

Returns
The XX component value.

Referenced by Murl::Math::Frustum< Real >::Set(), and Murl::Math::Quaternion< Real >::Set().

◆ GetXY()

template<class DataType>
DataType Murl::Math::Matrix< DataType >::GetXY ( ) const
inline

Get the XY component.

Returns
The XY component value.

Referenced by Murl::Math::Frustum< Real >::Set(), and Murl::Math::Quaternion< Real >::Set().

◆ GetXZ()

template<class DataType>
DataType Murl::Math::Matrix< DataType >::GetXZ ( ) const
inline

Get the XZ component.

Returns
The XZ component value.

Referenced by Murl::Math::Frustum< Real >::Set(), and Murl::Math::Quaternion< Real >::Set().

◆ GetXW()

template<class DataType>
DataType Murl::Math::Matrix< DataType >::GetXW ( ) const
inline

Get the XW component.

Returns
The XW component value.

Referenced by Murl::Math::Frustum< Real >::Set().

◆ GetYX()

template<class DataType>
DataType Murl::Math::Matrix< DataType >::GetYX ( ) const
inline

Get the YX component.

Returns
The YX component value.

Referenced by Murl::Math::Frustum< Real >::Set(), and Murl::Math::Quaternion< Real >::Set().

◆ GetYY()

template<class DataType>
DataType Murl::Math::Matrix< DataType >::GetYY ( ) const
inline

Get the YY component.

Returns
The YY component value.

Referenced by Murl::Math::Frustum< Real >::Set(), and Murl::Math::Quaternion< Real >::Set().

◆ GetYZ()

template<class DataType>
DataType Murl::Math::Matrix< DataType >::GetYZ ( ) const
inline

Get the YZ component.

Returns
The YZ component value.

Referenced by Murl::Math::Frustum< Real >::Set(), and Murl::Math::Quaternion< Real >::Set().

◆ GetYW()

template<class DataType>
DataType Murl::Math::Matrix< DataType >::GetYW ( ) const
inline

Get the YW component.

Returns
The YW component value.

Referenced by Murl::Math::Frustum< Real >::Set().

◆ GetZX()

template<class DataType>
DataType Murl::Math::Matrix< DataType >::GetZX ( ) const
inline

Get the ZX component.

Returns
The ZX component value.

Referenced by Murl::Math::Frustum< Real >::Set(), and Murl::Math::Quaternion< Real >::Set().

◆ GetZY()

template<class DataType>
DataType Murl::Math::Matrix< DataType >::GetZY ( ) const
inline

Get the ZY component.

Returns
The ZY component value.

Referenced by Murl::Math::Frustum< Real >::Set(), and Murl::Math::Quaternion< Real >::Set().

◆ GetZZ()

template<class DataType>
DataType Murl::Math::Matrix< DataType >::GetZZ ( ) const
inline

Get the ZZ component.

Returns
The ZZ component value.

Referenced by Murl::Math::Frustum< Real >::Set(), and Murl::Math::Quaternion< Real >::Set().

◆ GetZW()

template<class DataType>
DataType Murl::Math::Matrix< DataType >::GetZW ( ) const
inline

Get the ZW component.

Returns
The ZW component value.

Referenced by Murl::Math::Frustum< Real >::Set().

◆ GetWX()

template<class DataType>
DataType Murl::Math::Matrix< DataType >::GetWX ( ) const
inline

Get the WX component.

Returns
The WX component value.

Referenced by Murl::Math::Frustum< Real >::Set().

◆ GetWY()

template<class DataType>
DataType Murl::Math::Matrix< DataType >::GetWY ( ) const
inline

Get the WY component.

Returns
The WY component value.

Referenced by Murl::Math::Frustum< Real >::Set().

◆ GetWZ()

template<class DataType>
DataType Murl::Math::Matrix< DataType >::GetWZ ( ) const
inline

Get the WZ component.

Returns
The WZ component value.

Referenced by Murl::Math::Frustum< Real >::Set().

◆ GetWW()

template<class DataType>
DataType Murl::Math::Matrix< DataType >::GetWW ( ) const
inline

Get the WW component.

Returns
The WW component value.

Referenced by Murl::Math::Frustum< Real >::Set().

◆ IsEqual() [1/2]

template<class DataType>
Bool Murl::Math::Matrix< DataType >::IsEqual ( const Matrix< DataType > &  m) const
inline

Check if the matrix is equal to a given matrix.

Compares all values within the default epsilon range Limits::Epsilon().

Parameters
mThe matrix to compare.
Returns
true if all components are exactly the same.

Referenced by Murl::Math::Matrix< Real >::IsEqual(), and Murl::Math::Matrix< Real >::IsIdentity().

◆ IsEqual() [2/2]

template<class DataType>
Bool Murl::Math::Matrix< DataType >::IsEqual ( const Matrix< DataType > &  m,
DataType  epsilon 
) const
inline

Check if the matrix is equal to a given matrix.

Compares all values within a given epsilon range.

Parameters
mThe matrix to compare.
epsilonThe epsilon to compare.
Returns
true if equal.

◆ IsIdentity() [1/2]

template<class DataType>
Bool Murl::Math::Matrix< DataType >::IsIdentity ( ) const
inline

Check if the matrix is equal to the identity matrix.

Performs a test without an epsilon range.

Returns
true if equal.

◆ IsIdentity() [2/2]

template<class DataType>
Bool Murl::Math::Matrix< DataType >::IsIdentity ( DataType  epsilon) const
inline

Check if the matrix is equal to the identity matrix.

Compares all values within a given epsilon range.

Parameters
epsilonThe epsilon to compare.
Returns
true if equal.

◆ ToString()

template<class DataType>
String Murl::Math::Matrix< DataType >::ToString ( ) const
inline

Get the string representation of the object.

Returns
The string representation of the object.

◆ GetCount()

template<class DataType>
SInt32 Murl::Math::Matrix< DataType >::GetCount ( ) const
inline

Get the number of elements in the object.

Returns
The number of elements in the object.

Friends And Related Function Documentation

◆ operator==

template<class DataType>
bool operator== ( const Matrix< DataType > &  lhs,
const Matrix< DataType > &  rhs 
)
friend

Equal to comparison operator.

Performs a test without an epsilon range, which can be used for detecting changes i.e. DoubleBuffer<Matrix> class. To compare within an epsilon range use Matrix::IsEqual().

Parameters
lhsThe left hand side matrix to compare.
rhsThe right hand side matrix to compare.
Returns
true if all components are exactly the same.

◆ operator!=

template<class DataType>
bool operator!= ( const Matrix< DataType > &  lhs,
const Matrix< DataType > &  rhs 
)
friend

Not equal to comparison operator.

Performs a test without an epsilon range, which can be used for detecting changes i.e. DoubleBuffer<Matrix> class. To compare within an epsilon range use Matrix::IsEqual().

Parameters
lhsThe left hand side matrix to compare.
rhsThe right hand side matrix to compare.
Returns
true if all components are not exactly the same.

Member Data Documentation

◆ mComponents

◆ mFlags


The documentation for this class was generated from the following files:
  • murl_app_types.h
  • murl_math_matrix.h


Copyright © 2011-2018 Spraylight GmbH.