Menge
Modular Pedestrian Simulation Framework for Research and Development
|
Basic 4x4 matrix of floats. More...
#include <Matrix.h>
Public Member Functions | |
Matrix4x4 () | |
Constructor. More... | |
Matrix4x4 (bool garbage) | |
Non-initializing constructor. More... | |
void | identity () |
Sets the matrix to the identity matrix. | |
float | operator() (int row, int col) const |
Index operation. More... | |
float & | operator() (int row, int col) |
Reference index operation. More... | |
void | setRow (int row, float v0, float v1, float v2, float v3=1.f) |
Set the values of an entire row of the matrix. More... | |
void | setRow (int row, const Vector3 &vec, float v3=1.f) |
Set the values of an entire row of the matrix. More... | |
void | scale (const Vector3 &scale, Matrix4x4 &m) |
Multiplies the given matrix by an implicit scale matrix and stores it here. More... | |
void | scaleRight (const Vector3 &scale, Matrix4x4 &m) |
Multiplies the given matrix by an implicit scale matrix and stores it here. More... | |
float | trace () const |
Compute the trace of the 4x4 matrix. More... | |
float | trace3x3 () const |
Compute the trace of the upper-left 3x3 sub-matrix. More... | |
void | translateRotation (const Vector3 &trans) |
Right-multiply this matrix by a translation matrix. More... | |
void | translateRotationLeft (const Vector3 &trans) |
Left-multiply this matrix by a translation matrix. More... | |
void | setDiagonal (float v0, float v1, float v2, float v3=1.f) |
Sets the diagonal to the given values. More... | |
void | setDiagonal (const Vector3 &vec, float v3=1.f) |
Sets the diagonal to the given values. More... | |
void | product (const Matrix4x4 &m1, const Matrix4x4 &m2) |
Performs the matrix product and stores the result in this matrix. More... | |
void | product3x3 (const Matrix4x4 &m1, const Matrix4x4 &m2) |
Computes a 3x3 matrix multiplication on the inputs storing the result in this matrix. More... | |
void | setAsTranspose (Matrix4x4 &m1) |
Set this matrix to be the transpose of the given matrix. More... | |
void | transpose () |
Transpose this matrix in-place. | |
float * | getFlattened () |
Get a pointer to the underlying data as a flat array. More... | |
Friends | |
Logger & | operator<< (Logger &out, const Matrix4x4 &mat) |
Ouput the string-formatted matrix to an output stream. More... | |
Basic 4x4 matrix of floats.
Functions predominantly come in the form result.op( operand1, operand2 ) to limit implicit data copying. The operations is performed on the parameter, and the result is stored in the instance calling the operation.
The data is stored column-major data – i.e. the data is organized: [ [x-axis 0] [y-axis 0] [z-axis 0] [tx ty tz 1] ] It's assumed that multiplication with vectors is LEFT-multiplication by row vectors i.e. q = p * M (where q & p are vectors and M is matrix).
Menge::Math::Matrix4x4::Matrix4x4 | ( | ) |
Constructor.
This constructor initializes the matrix to be the identity.
|
inline |
Non-initializing constructor.
By constructing with an arbitrary boolean, the matrix will not be initialized.
garbage | The ignored boolean. |
|
inline |
Get a pointer to the underlying data as a flat array.
|
inline |
Index operation.
There is no run-time check on the index values.
row | The row index (should be in the range [0, 3]). |
col | The column index (should be in the range [0, 3]). |
|
inline |
Reference index operation.
There is no run-time check on the index values.
row | The row index (should be in the range [0, 3]). |
col | The column index (should be in the range [0, 3]). |
Performs the matrix product and stores the result in this matrix.
Computes the 4x4 matrix product: m1 * m2
m1 | The left-hand matrix. |
m2 | The right-hand matrix. |
Computes a 3x3 matrix multiplication on the inputs storing the result in this matrix.
Computes the 3x3 matrix product: m1 * m2. The final column and row of this matrix are set to the vector <0, 0, 0, 1>.
m1 | The left-hand matrix. |
m2 | The right-hand matrix. |
Multiplies the given matrix by an implicit scale matrix and stores it here.
The scale vector parameter is <sx, sy, sz>, which implicitly defines a scale transformation matrix S (with sx, sy, sz, 1 on the diagonal and zeros everywhere else). We then perform the matrix left multiplication: S * m and assign it to this matrix.
scale | A vector of scale amounts along the three axes <sx, sy, sz>. |
m | The matrix to scale: perform S * m. |
Multiplies the given matrix by an implicit scale matrix and stores it here.
The scale vector parameter is <sx, sy, sz>, which implicitly defines a scale transformation matrix S (with sx, sy, sz, 1 on the diagonal and zeros everywhere else). We then perform the matrix right multiplication: m * S and assign it to this matrix.
scale | A vector of scale amounts along the three axes <sx, sy, sz>. |
m | The matrix to scale: perform m * S. |
void Menge::Math::Matrix4x4::setAsTranspose | ( | Matrix4x4 & | m1 | ) |
Set this matrix to be the transpose of the given matrix.
m1 | The matrix whose transpose is stored in this matrix. |
void Menge::Math::Matrix4x4::setDiagonal | ( | float | v0, |
float | v1, | ||
float | v2, | ||
float | v3 = 1.f |
||
) |
Sets the diagonal to the given values.
v0 | The value for M[0, 0]. |
v1 | The value for M[1, 1]. |
v2 | The value for M[2, 2]. |
v3 | The value for M[3, 3]. |
void Menge::Math::Matrix4x4::setDiagonal | ( | const Vector3 & | vec, |
float | v3 = 1.f |
||
) |
Sets the diagonal to the given values.
vec | The values for M[0, 0], M[1, 1], and M[2, 2]. |
v3 | The value for M[3, 3]. |
void Menge::Math::Matrix4x4::setRow | ( | int | row, |
float | v0, | ||
float | v1, | ||
float | v2, | ||
float | v3 = 1.f |
||
) |
Set the values of an entire row of the matrix.
row | The index of the row to set (should be in the range [0, 3]). |
v0 | The value for the first column. |
v1 | The value for the second column. |
v2 | The value for the third column. |
v3 | The value for the fourth column. |
void Menge::Math::Matrix4x4::setRow | ( | int | row, |
const Vector3 & | vec, | ||
float | v3 = 1.f |
||
) |
Set the values of an entire row of the matrix.
row | The index of the row to set (should be in the range [0, 3]). |
vec | The value for the first, second, and third columns. |
v3 | The value for the fourth column. |
|
inline |
Compute the trace of the 4x4 matrix.
The trace of the matrix is the product of the values on the matrix's diagonal.
|
inline |
Compute the trace of the upper-left 3x3 sub-matrix.
The trace of the matrix is the product of the values on the matrix's diagonal.
void Menge::Math::Matrix4x4::translateRotation | ( | const Vector3 & | trans | ) |
Right-multiply this matrix by a translation matrix.
This should only be used if this matrix is known to have the vector <0,0,0,1> in both the last row and the last column. This method exploits that knowledge to perform the matrix multiplication efficiently. The result of the multiplication is written in place. Essentially, this is an optimized version of M = M * T. Where T is almost the identity matrix, but with <tx, ty, tz, 0> on the bottom row.
trans | The translation vector <tx, ty, tz> |
void Menge::Math::Matrix4x4::translateRotationLeft | ( | const Vector3 & | trans | ) |
Left-multiply this matrix by a translation matrix.
This should only be used if this matrix is known to have the vector <0,0,0,1> in both the last row and the last column. This method exploits that knowledge to perform the matrix multiplication efficiently. The result of the multiplication is written in place. Essentially, this is an optimized version of M = T * M. Where T is almost the identity matrix, but with <tx, ty, tz, 0> on the bottom row.
trans | The translation vector <tx, ty, tz> |
Ouput the string-formatted matrix to an output stream.
out | The output stream. |
mat | The matrix. |