Represents a 4x4 float matrix. More...
Public Member Functions | |
Matrix () noexcept | |
Matrix (float m00, float m01, float m10, float m11) noexcept | |
Matrix (float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22) noexcept | |
Matrix (float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33) noexcept | |
Matrix (const Matrix &other) noexcept | |
Vector | getRow0 () const |
Vector | getRow1 () const |
Vector | getRow2 () const |
Vector | getRow3 () const |
Vector | getCol0 () const |
Vector | getCol1 () const |
Vector | getCol2 () const |
Vector | getCol3 () const |
float | get (unsigned int row, unsigned int col) const |
Matrix & | set (float val, unsigned int row, unsigned int col) |
Matrix | getInverseMat2 () const |
Matrix | getInverseMat3 () const |
Matrix | getInverseMat4 () const |
Matrix | getTranspose () const |
Matrix & | inverseMat2 () |
Matrix & | inverseMat3 () |
Matrix & | inverseMat4 () |
Matrix & | transpose () |
Vector | getPositionComponent () const |
Matrix | getOrientationComponent () const |
Vector | getScaleComponent () const |
void | getDecomposed (Vector &position, Matrix &orientation, Vector &scale) const |
Matrix & | setToViewMatrixDirection (const Vector &position, const Vector &direction, const Vector &upDirection) |
Matrix & | setToPerspectiveMatrix (float fov, float aspect, float nearVal, float farVal) |
Matrix & | setToOrthographicMatrix (float widthNearPlane, float heightNearPlane, float nearVal, float farVal) |
Matrix & | setPositionComponent (const Vector &position) |
Matrix & | setOrientationComponent (const Quaternion &rot) |
Matrix & | setScaleComponent (const Vector &scale) |
Matrix & | setToTransformation (const Vector &position, const Quaternion &orientation, const Vector &scale) |
float | getDeterminantMat2 () const |
float | getDeterminantMat3 () const |
float | getDeterminantMat4 () const |
float | getTraceMat2 () const |
float | getTraceMat3 () const |
float | getTraceMat4 () const |
nkMemory::String | toString () const |
Matrix & | fromString (nkMemory::StringView str) |
Matrix & | operator= (const Matrix &other) noexcept |
bool | operator== (const Matrix &other) |
bool | operator!= (const Matrix &other) |
Matrix | operator+ (const Matrix &other) const |
void | operator+= (const Matrix &other) |
Matrix | operator- (const Matrix &other) const |
void | operator-= (const Matrix &other) |
Matrix | operator* (const Matrix &other) const |
Vector | operator* (const Vector &vec) const |
Quaternion | operator* (const Quaternion &q) const |
Matrix | operator* (float scalar) const |
void | operator*= (const Matrix &other) |
void | operator*= (float scalar) |
Matrix | operator/ (float scalar) const |
void | operator/= (float scalar) |
Public Attributes | |
float | _m [4][4] |
The matrix memory, considered in row-major order (_m[row][col]). | |
Represents a 4x4 float matrix.
The matrix is considered as row-major.
|
noexcept |
Default constructor. Defaults to an identity matrix.
|
noexcept |
Matrix 2x2 constructor.
m00 | The value for _m[0][0]. |
m01 | The value for _m[0][1]. |
m10 | The value for _m[1][0]. |
m11 | The value for _m[1][1]. |
|
noexcept |
Matrix 3x3 constructor.
m00 | The value for _m[0][0]. |
m01 | The value for _m[0][1]. |
m02 | The value for _m[0][2]. |
m10 | The value for _m[1][0]. |
m11 | The value for _m[1][1]. |
m12 | The value for _m[1][2]. |
m20 | The value for _m[2][0]. |
m21 | The value for _m[2][1]. |
m22 | The value for _m[2][2]. |
|
noexcept |
Matrix 4x4 constructor.
m00 | The value for _m[0][0]. |
m01 | The value for _m[0][1]. |
m02 | The value for _m[0][2]. |
m03 | The value for _m[0][3]. |
m10 | The value for _m[1][0]. |
m11 | The value for _m[1][1]. |
m12 | The value for _m[1][2]. |
m13 | The value for _m[1][3]. |
m20 | The value for _m[2][0]. |
m21 | The value for _m[2][1]. |
m22 | The value for _m[2][2]. |
m23 | The value for _m[2][3]. |
m30 | The value for _m[3][0]. |
m31 | The value for _m[3][1]. |
m32 | The value for _m[3][2]. |
m33 | The value for _m[3][3]. |
|
noexcept |
Copy constructor.
other | The matrix to copy from. |
Vector nkMaths::Matrix::getRow0 | ( | ) | const |
Vector nkMaths::Matrix::getRow1 | ( | ) | const |
Vector nkMaths::Matrix::getRow2 | ( | ) | const |
Vector nkMaths::Matrix::getRow3 | ( | ) | const |
Vector nkMaths::Matrix::getCol0 | ( | ) | const |
Vector nkMaths::Matrix::getCol1 | ( | ) | const |
Vector nkMaths::Matrix::getCol2 | ( | ) | const |
Vector nkMaths::Matrix::getCol3 | ( | ) | const |
float nkMaths::Matrix::get | ( | unsigned int | row, |
unsigned int | col | ||
) | const |
row | The row coordinate of the member to retrieve, between [0, 3]. |
col | The col coordinate of the member to retrieve, between [0, 3]. |
Matrix& nkMaths::Matrix::set | ( | float | val, |
unsigned int | row, | ||
unsigned int | col | ||
) |
val | The value to set in the matrix. |
row | The row coordinate to override, between [0, 3]. |
col | The col coordinate to override, between [0, 3]. |
Matrix nkMaths::Matrix::getInverseMat2 | ( | ) | const |
Matrix nkMaths::Matrix::getInverseMat3 | ( | ) | const |
Matrix nkMaths::Matrix::getInverseMat4 | ( | ) | const |
Matrix nkMaths::Matrix::getTranspose | ( | ) | const |
Matrix& nkMaths::Matrix::inverseMat2 | ( | ) |
Inverses the matrix, as if it was a 2x2 matrix.
Matrix& nkMaths::Matrix::inverseMat3 | ( | ) |
Inverses the matrix, as if it was a 3x3 matrix.
Matrix& nkMaths::Matrix::inverseMat4 | ( | ) |
Inverses the matrix, as if it was a 4x4 matrix.
Matrix& nkMaths::Matrix::transpose | ( | ) |
Transposes the matrix.
Vector nkMaths::Matrix::getPositionComponent | ( | ) | const |
Matrix nkMaths::Matrix::getOrientationComponent | ( | ) | const |
Vector nkMaths::Matrix::getScaleComponent | ( | ) | const |
void nkMaths::Matrix::getDecomposed | ( | Vector & | position, |
Matrix & | orientation, | ||
Vector & | scale | ||
) | const |
Decomposes the matrix into a set of translation, orientation, and scale, considering the matrix as a 4x4 transformation matrix.
position | The position, translation component to fill. |
orientation | The orientation component to fill. |
scale | The scale component to fill. |
Matrix& nkMaths::Matrix::setToViewMatrixDirection | ( | const Vector & | position, |
const Vector & | direction, | ||
const Vector & | upDirection | ||
) |
Sets the matrix as a view matrix.
position | The eye position. |
direction | The eye front direction. |
upDirection | The eye up direction. |
Matrix& nkMaths::Matrix::setToPerspectiveMatrix | ( | float | fov, |
float | aspect, | ||
float | nearVal, | ||
float | farVal | ||
) |
Sets the matrix as a perspective matrix.
fov | The field of view, vertical, in radians. |
aspect | The aspect ratio. |
nearVal | The near plane distance. |
farVal | The far plane distance. |
Matrix& nkMaths::Matrix::setToOrthographicMatrix | ( | float | widthNearPlane, |
float | heightNearPlane, | ||
float | nearVal, | ||
float | farVal | ||
) |
Sets the matrix as an orthographic matrix.
widthNearPlane | The width of the matrix, in eye space distance. |
heightNearPlane | The height of the matrix, in eye space distance. |
nearVal | The near plane distance. |
farVal | The far plane distance. |
Sets the position component in the matrix.
position | The position to set in the matrix. |
Matrix& nkMaths::Matrix::setOrientationComponent | ( | const Quaternion & | rot | ) |
Sets the rotation component in the matrix.
rot | The quaternion to use as orientation. |
Sets the scale component in the matrix.
scale | The scale on each axis. |
Matrix& nkMaths::Matrix::setToTransformation | ( | const Vector & | position, |
const Quaternion & | orientation, | ||
const Vector & | scale | ||
) |
Sets the matrix as a full transformation matrix.
position | The position, translation component to bake. |
orientation | The orientation component to bake. |
scale | The scale component to bake. |
float nkMaths::Matrix::getDeterminantMat2 | ( | ) | const |
float nkMaths::Matrix::getDeterminantMat3 | ( | ) | const |
float nkMaths::Matrix::getDeterminantMat4 | ( | ) | const |
float nkMaths::Matrix::getTraceMat2 | ( | ) | const |
float nkMaths::Matrix::getTraceMat3 | ( | ) | const |
float nkMaths::Matrix::getTraceMat4 | ( | ) | const |
nkMemory::String nkMaths::Matrix::toString | ( | ) | const |
Matrix& nkMaths::Matrix::fromString | ( | nkMemory::StringView | str | ) |
Interprets a string to set the components of the matrix. Format is m00,m01,m02,m03,...
str | The string to parse. |
Assignment operator.
other | The matrix to assign. |
bool nkMaths::Matrix::operator== | ( | const Matrix & | other | ) |
Equality operator.
other | The matrix to check against. |
bool nkMaths::Matrix::operator!= | ( | const Matrix & | other | ) |
Inequality operator.
other | The matrix to check against. |
Addition operator.
other | The matrix to operate with. |
void nkMaths::Matrix::operator+= | ( | const Matrix & | other | ) |
Addition and assignment operator.
other | The matrix to operate with. |
Subtraction operator.
other | The matrix to operate with. |
void nkMaths::Matrix::operator-= | ( | const Matrix & | other | ) |
Subtraction and assignment operator.
other | The matrix to operate with. |
Transformation operator.
other | The matrix to operate with. |
Transformation operator.
vec | The vector to apply to. |
Quaternion nkMaths::Matrix::operator* | ( | const Quaternion & | q | ) | const |
Transformation operator.
q | The quaternion to apply to. |
Matrix nkMaths::Matrix::operator* | ( | float | scalar | ) | const |
Multiplication operator.
scalar | The scalar to operate with. |
void nkMaths::Matrix::operator*= | ( | const Matrix & | other | ) |
Transformation and assignment operator.
other | The matrix to operate with. |
void nkMaths::Matrix::operator*= | ( | float | scalar | ) |
Multiplication and assignment operator.
scalar | The scalar to operate with. |
Matrix nkMaths::Matrix::operator/ | ( | float | scalar | ) | const |
Division operator.
scalar | The scalar to operate with. |
void nkMaths::Matrix::operator/= | ( | float | scalar | ) |
Addition and assignment operator.
scalar | The scalar to operate with. |