![]() |
Murl Engine API
Version 2018.3
|
A 4x4 matrix class. More...
#include <murl_math_matrix.h>
A 4x4 matrix class.
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... | |
Matrix & | operator*= (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 (const Vector< DataType > &angles, IEnums::RotationOrder rotationOrder) |
Set the rotation component by euler angles with a given rotation order. 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 > ¢er, 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... | |
typedef DataType Murl::Math::Matrix< DataType >::ValueType |
The template parameter value type.
enum Murl::Math::Matrix::Component |
enum Murl::Math::Matrix::ComponentMask |
Enumeration of the components' bit masks.
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. |
enum Murl::Math::Matrix::HintFlags |
Enumeration of hint flags.
Hints are used internally to optimize several operations.
|
inline |
The default constructor, creating an identity matrix.
Hints are disabled by default.
|
inline |
Constructor to create a matrix from a predefined type.
Hints are disabled by default.
type | The predefined type. |
|
inline |
|
inlinestatic |
Create a look-at matrix from a given center point, target point and up vector.
center | The center point position vector. |
target | The target point position vector. |
up | The up direction vector. |
|
inline |
Get the hint flags.
|
inline |
Set the hint flags.
mask | The bit-mask of hints to set. |
|
inline |
Clear hint flags.
mask | The bit-mask of hints to clear. |
|
inline |
Enable hints.
Enabling hints requires good knowlede of the entire Matrix class e.g. several setter methods do not consider hints.
autoDetect | Evaluate the correct hints if true. |
|
inline |
Get a component element.
index | The component index, see enum Component. |
|
inline |
Get a writeable reference to a component element.
index | The component index, see enum Component. |
|
inline |
Get a const pointer to the raw data.
|
inline |
Get a writeable pointer to the raw data.
|
inline |
In-place matrix-matrix multiplication operator.
m | The matrix to multiply. |
|
inline |
Matrix-matrix multiplication operator.
rhs | The right hand side matrix. |
|
inline |
Matrix-vector multiplication operator.
rhs | The right hand side vector. |
|
inline |
Clear all components of the matrix instance.
Set the component data array to zero.
|
inline |
Copy the content of a source matrix to the matrix instance.
m | The matrix to copy from. |
|
inline |
Set the translation component to a given vector.
v | The vector to set the translation component. |
|
inline |
Set the translation component to given values.
x | The X translation component. |
y | The Y translation component. |
z | The Z translation component. |
|
inline |
Set the translation X component.
x | The X translation component. |
|
inline |
Set the translation Y component.
y | The Y translation component. |
|
inline |
Set the translation Z component.
z | The Z translation component. |
|
inline |
Get the translation component vector.
|
inline |
Get the translation component's X value.
|
inline |
Get the translation component's Y value.
|
inline |
Get the translation component's Z value.
|
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.
v | The vector containing X, Y and Z scaling components. |
|
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.
x | The X scaling factor. |
y | The Y scaling factor. |
z | The Z scaling factor. |
|
inline |
Get a vector containing the X, Y and Z scaling components of the matrix.
|
inline |
Get the X scale value of the matrix.
|
inline |
Get the Y scale value of the matrix.
|
inline |
Get the Z scale value of the matrix.
|
inline |
Set the rotation component by a vector.
axisAngle | The vector of the rotation including the angle in w component in radiants. |
|
inline |
Set the rotation component by an angle and vector.
angle | The angle of the rotation in radiants. |
axis | The vector of the rotation. |
|
inline |
Set the rotation component by an angle and vector components.
angle | The angle of the rotation in radiants. |
ax | The x-component of the rotation vector. |
ay | The y-component of the rotation vector. |
az | The z-component of the rotation vector. |
|
inline |
Set the rotation component by euler angles.
The default axis rotation order is IEnums::ROTATION_ORDER_ZYX.
angleX | The x-axis angle in radiants. |
angleY | The y-axis angle in radiants. |
angleZ | The z-axis angle in radiants. |
|
inline |
Set the rotation component by euler angles with a given rotation order.
angles | A vector containing the X, Y and Z angles in radiants. |
rotationOrder | The axis rotation order. |
|
inline |
Set the rotation component by euler angles with a given rotation order.
angleX | The x-axis angle in radiants. |
angleY | The y-axis angle in radiants. |
angleZ | The z-axis angle in radiants. |
rotationOrder | The axis rotation order. |
|
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.
angleX | The x-axis angle in radiants. |
|
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.
angleY | The y-axis angle in radiants. |
|
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.
angleZ | The z-axis angle in radiants. |
|
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
|
inline |
Set the rotation component by a quaternion.
q | The quaternion. |
|
inline |
Set the rotation component by a rotation matrix.
rotationMatrix | The rotation matrix. |
|
inline |
Extract the rotation and scaling component of the matrix.
|
inline |
Get the vector of a specified column.
columnIndex | The column index in range [0 .. 3]. |
|
inline |
Set a specified column by a vector.
Hints are not considered.
columnIndex | The column index in range [0 .. 3]. |
vec | The vector to set the colum at the specified index. |
|
inline |
Get the vector of a specified row.
rowIndex | The row index in range [0 .. 3]. |
|
inline |
Set a specified row by a vector.
Hints are not considered.
rowIndex | The row index in range [0 .. 3]. |
vec | The vector to set the row at the specified index. |
|
inline |
In-place matrix-matrix multiplication.
m | The matrix to multiply. |
|
inline |
In-place reverse matrix-matrix multiplication.
m | The matrix to multiply. |
|
inline |
Transform (multiply) a vector by the matrix.
v | The vector to mulitply. |
|
inline |
Rotate a vector by the matrix.
v | The vector to rotate. |
|
inline |
Translate a vector by the matrix (add the translation component).
v | The vector to translate. |
|
inline |
Multiply a matrix by the matrix.
m | The matrix to mulitply. |
|
inline |
Multiply a vector by the matrix.
v | The vector to mulitply. |
|
inline |
Get the transposed matrix.
|
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().
|
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.
|
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.
|
inline |
Solve the matrix by a vector.
v | The vector to solve. |
|
inline |
Set a component element.
Hints are not considered.
row | The row in range [0 .. 3]. |
col | The column in range [0 .. 3]. |
value | The value to set. |
|
inline |
Get a component element.
row | The row in range [0 .. 3]. |
col | The column in range [0 .. 3]. |
|
inline |
Get a writeable reference to a component element.
row | The row in range [0 .. 3]. |
col | The column in range [0 .. 3]. |
|
inline |
Set a component element.
Hints are not considered.
element | The element |
value | The value to set. |
|
inline |
Get a component element.
element | The element's component. |
|
inline |
Get a writeable reference to a component element.
element | The element's component. |
|
inline |
Set the XX component.
Hints are not considered.
value | The XX component value to set. |
|
inline |
Set the XY component.
Hints are not considered.
value | The XY component value to set. |
|
inline |
Set the XZ component.
Hints are not considered.
value | The XZ component value to set. |
|
inline |
Set the XW component.
Hints are not considered.
value | The XW component value to set. |
|
inline |
Set the YX component.
Hints are not considered.
value | The YX component value to set. |
|
inline |
Set the YY component.
Hints are not considered.
value | The YY component value to set. |
|
inline |
Set the YZ component.
Hints are not considered.
value | The YZ component value to set. |
|
inline |
Set the YW component.
Hints are not considered.
value | The YW component value to set. |
|
inline |
Set the ZX component.
Hints are not considered.
value | The ZX component value to set. |
|
inline |
Set the ZY component.
Hints are not considered.
value | The ZY component value to set. |
|
inline |
Set the ZZ component.
Hints are not considered.
value | The ZZ component value to set. |
|
inline |
Set the ZW component.
Hints are not considered.
value | The ZW component value to set. |
|
inline |
Set the WX component.
Hints are not considered.
value | The WX component value to set. |
|
inline |
Set the WY component.
Hints are not considered.
value | The WY component value to set. |
|
inline |
Set the WZ component.
Hints are not considered.
value | The WZ component value to set. |
|
inline |
Set the WW component.
Hints are not considered.
value | The WW component value to set. |
|
inline |
Get the XX component.
|
inline |
Get the XY component.
|
inline |
Get the XZ component.
|
inline |
Get the XW component.
|
inline |
Get the YX component.
|
inline |
Get the YY component.
|
inline |
Get the YZ component.
|
inline |
Get the YW component.
|
inline |
Get the ZX component.
|
inline |
Get the ZY component.
|
inline |
Get the ZZ component.
|
inline |
Get the ZW component.
|
inline |
Get the WX component.
|
inline |
Get the WY component.
|
inline |
Get the WZ component.
|
inline |
Get the WW component.
|
inline |
Check if the matrix is equal to a given matrix.
Compares all values within the default epsilon range Limits::Epsilon().
m | The matrix to compare. |
|
inline |
Check if the matrix is equal to a given matrix.
Compares all values within a given epsilon range.
m | The matrix to compare. |
epsilon | The epsilon to compare. |
|
inline |
Check if the matrix is equal to the identity matrix.
Performs a test without an epsilon range.
|
inline |
Check if the matrix is equal to the identity matrix.
Compares all values within a given epsilon range.
epsilon | The epsilon to compare. |
|
inline |
Get the string representation of the object.
|
inline |
Get the number of elements in the object.
|
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().
lhs | The left hand side matrix to compare. |
rhs | The right hand side matrix to compare. |
|
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().
lhs | The left hand side matrix to compare. |
rhs | The right hand side matrix to compare. |
DataType Murl::Math::Matrix< DataType >::mComponents[NUM_COMPONENTS] |
The components data array.
|
protected |
The hint flags.