mat4
Header file: include/mat4.h
mat4 is a column-major matrix with 4 columns and 4 rows.
\(mat4 = \begin{bmatrix} x.x & y.x & z.x & w.x \\ x.y & y.y & z.y & w.y \\ x.z & y.z & z.z & w.z \\ x.w & y.w & z.w & w.w \end{bmatrix}\)
Class variables
Type |
Name |
Description |
|---|---|---|
x |
The first column of the mat4. |
|
y |
The second column of the mat4. |
|
z |
The third column of the mat4. |
|
w |
The fourth column of the mat4. |
Class functions
Constructors
Name |
Description |
|---|---|
Construct a ([0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0]) matrix. |
|
Construct a ([_value, _value, _value, _value], [_value, _value, _value, _value], [_value, _value, _value, _value], [_value, _value, _value, _value]) matrix. |
|
Construct a ([_xx, _xy, _xz, _xw], [_yx, _yy, _yz, _yw], [_zx, _zy, _zz, _zw], [_wx, _wy, _wz, _ww]) matrix. |
|
Construct a ([_xx, _xy, _xz, _xw], [_yx, _yy, _yz, _yw], [_zx, _zy, _zz, _zw], [_w.x, _w.y, _w.z, _w.w]) matrix. |
|
Construct a ([_xx, _xy, _xz, _xw], [_yx, _yy, _yz, _yw], [_z.x, _z.y, _z.z, _z.w], [_wx, _wy, _wz, _ww]) matrix. |
|
Construct a ([_xx, _xy, _xz, _xw], [_y.x, _y.y, _y.z, _y.w], [_zx, _zy, _zz, _zw], [_wx, _wy, _wz, _ww]) matrix. |
|
Construct a ([_x.x, _x.y, _x.z, _x.w], [_yx, _yy, _yz, _yw], [_zx, _zy, _zz, _zw], [_wx, _wy, _wz, _ww]) matrix. |
|
Construct a ([_xx, _xy, _xz, _xw], [_yx, _yy, _yz, _yw], [_z.x, _z.y, _z.z, _z.w], [_w.x, _w.y, _w.z, _w.w]) matrix. |
|
Construct a ([_xx, _xy, _xz, _xw], [_y.x, _y.y, _y.z, _y.w], [_zx, _zy, _zz, _zw], [_w.x, _w.y, _w.z, _w.w]) matrix. |
|
Construct a ([_x.x, _x.y, _x.z, _x.w], [_yx, _yy, _yz, _yw], [_zx, _zy, _zz, _zw], [_w.x, _w.y, _w.z, _w.w]) matrix. |
|
Construct a ([_xx, _xy, _xz, _xw], [_y.x, _y.y, _y.z, _y.w], [_z.x, _z.y, _z.z, _z.w], [_wx, _wy, _wz, _ww]) matrix. |
|
Construct a ([_x.x, _x.y, _x.z, _x.w], [_yx, _yy, _yz, _yw], [_z.x, _z.y, _z.z, _z.w], [_wx, _wy, _wz, _ww]) matrix. |
|
Construct a ([_x.x, _x.y, _x.z, _x.w], [_y.x, _y.y, _y.z, _y.w], [_zx, _zy, _zz, _zw], [_wx, _wy, _wz, _ww]) matrix. |
|
Construct a ([_xx, _xy, _xz, _xw], [_y.x, _y.y, _y.z, _y.w], [_z.x, _z.y, _z.z, _z.w], [_w.x, _w.y, _w.z, _w.w]) matrix. |
|
Construct a ([_x.x, _x.y, _x.z, _x.w], [_yx, _yy, _yz, _yw], [_z.x, _z.y, _z.z, _z.w], [_w.x, _w.y, _w.z, _w.w]) matrix. |
|
Construct a ([_x.x, _x.y, _x.z, _x.w], [_y.x, _y.y, _y.z, _y.w], [_zx, _zy, _zz, _zw], [_w.x, _w.y, _w.z, _w.w]) matrix. |
|
Construct a ([_x.x, _x.y, _x.z, _x.w], [_y.x, _y.y, _y.z, _y.w], [_z.x, _z.y, _z.z, _z.w], [_wx, _wy, _wz, _ww]) matrix. |
|
mat4(const nml::vec4& _x, const nml::vec4& _y, const nml::vec4& _z, const nml::vec4& _w) |
Construct a ([_x.x, _x.y, _x.z, _x.w], [_y.x, _y.y, _y.z, _y.w], [_z.x, _z.y, _z.z, _z.w], [_w.x, _w.y, _w.z, _w.w]) matrix. |
Construct a matrix from a pointer. |
Operators
Name |
Description |
|---|---|
Add a mat4 to the current mat4. |
|
Substract a mat4 from the current mat4. |
|
Multiply the current mat4 by a mat4. |
|
Multiply the current mat4 by a scalar. |
|
Divide the current mat4 by a scalar. |
|
Return a reference to x if index is 0, a reference to y if index is 1, a reference to z if index is 2 or a reference to w if index is 3 else, throw an exception. |
|
Return a const reference to x if index is 0, a const reference to y if index is 1, a const reference to z if index is 2 or a const reference to w if index is 3 else, throw an exception. |
Functions
Name |
Description |
|---|---|
Return the determinant of the matrix. |
|
Return a pointer to the matrix’s elements. |
Static Functions
Name |
Description |
|---|---|
Return a ([1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]) identity matrix. |
Namespace functions
Operators
Name |
Description |
|---|---|
Return a mat4 that is the sum between two mat4. |
|
Return a mat4 that is the difference between two mat4. |
|
Return a mat4 that is the product between two mat4. |
|
Return a vec4 that is the product between a mat4 and a vec4. |
|
Return a mat4 that is the product between a mat4 and a scalar. |
|
Return a mat4 that is the product between a scalar and a mat4. |
|
Return a mat4 that is the quotient between a mat4 and a scalar. |
|
Return true if the two mat4 are identical, else, return false. |
|
Return true if the two mat4 are different, else, return false. |
Functions
Name |
Description |
|---|---|
Return a mat4 where the columns of mat are the rows and the rows of mat are the columns. |
|
Return the inverse of a mat4. |
|
Return a 3D translation matrix according to the translation vector. |
|
Return a 3D rotation matrix according to the angle (in radians) and the axis. |
|
Return a 3D scaling matrix according to the scaling factors. |
|
nml::mat4 lookAtLH(const nml::vec3& from, const nml::vec3& to, const nml::vec3& up) |
Return a left-hand look at view matrix. |
nml::mat4 lookAtRH(const nml::vec3& from, const nml::vec3& to, const nml::vec3& up) |
Return a right-hand look at view matrix. |
Return a left-hand orthographic projection matrix. |
|
Return a right-hand orthographic projection matrix. |
|
Return a left-hand perspective projection matrix. |
|
Return a right-hand perspective projection matrix. |
|
Decompose a transform matrix into a translation vector, a rotation quaternion and a scale vector. |
|
Return a 3D rotation matrix from a quaternion. |
|
Return a mat4 as a string under the format “[[x.x, x.y, x.z, x.w], [y.x, y.y, y.z, y.w], [z.x, z.y, z.z, z.w], [w.x, w.y, w.z, w.w]]”. |