Unigine.mat4 Struct
mat4 Class
Properties
vec4 AxisX#
The normalized vector representing the X axis.
vec4 AxisY#
The normalized vector representing the Y axis.
vec4 AxisZ#
The normalized vector representing the Z axis.
vec4 Diagonal#
The vector with the elements of the main diagonal.
vec3 Translate#
The three-component vector with the translation part of the matrix.
vec3 Scale#
The three-component vector, representing the scaling part of the matrix.
Members
mat4 ( ) #
Default constructor. Produces an identity matrix.mat4 ( float v ) #
Constructor. Initializes the matrix using a given scalar value.mat4(2.0);
/* Creates a matrix
| 2.0 2.0 2.0 2.0 |
| 2.0 2.0 2.0 2.0 |
| 2.0 2.0 2.0 2.0 |
| 2.0 2.0 2.0 2.0 |
*/
Arguments
- float v - Scalar value.
mat4 ( mat3 m ) #
Constructor. Initializes the matrix using a given mat3 source matrix (3x3). The matrix elements are filled using corresponding elements of the source matrix.Resulting matrix:
| m00 m01 m02 0.0f |
M= | m10 m11 m12 0.0f |
| m20 m21 m22 0.0f |
| 0.0f 0.0f 0.0f 1.0f |
Arguments
- mat3 m - Source matrix (3x3).
mat4 ( mat4 m ) #
Constructor. Initializes the matrix by copying a given source matrix.Arguments
- mat4 m - Source matrix.
mat4 ( dmat4 m ) #
Constructor. Initializes the matrix using a given dmat4 source matrix (3x4). The matrix elements are filled using corresponding elements of the source matrix.Arguments
- dmat4 m - Source matrix (3x4).
mat4 ( vec4 col0, vec4 col1, vec4 col2, vec4 col3 ) #
Constructor. Initializes the matrix using given three vec4 vectors.Resulting matrix:
| col0.x col1.x col2.x col3.x |
M= | col0.y col1.y col2.y col3.y |
| col0.z col1.z col2.z col3.z |
| col0.w col1.w col2.w col3.w |
Arguments
- vec4 col0 - Source vector for the first column.
- vec4 col1 - Source vector for the second column.
- vec4 col2 - Source vector for the third column.
- vec4 col3 - Source vector for the fourth column.
mat4 ( quat q ) #
Constructor. Initializes the matrix using a given source quaternion.For the quaternion (x, y, z, w) the corresponding rotation matrix M is defined as follows:
| 1 - 2y² - 2z² 2xy + 2wz 2xz - 2wy 0.0f |
M= | 2xy - 2wz 1 - 2x² - 2z² 2yz + 2wx 0.0f |
| 2xz + 2wy 2yz - 2wx 1 - 2x² - 2y² 0.0f |
| 0.0f 0.0f 0.0f 1.0f |
Arguments
- quat q - Source quaternion.
mat4 ( mat3 m, vec3 v ) #
Constructor. Initializes the matrix using a given source mat3 matrix (3x3) and a vec3 vector.Arguments
mat4 ( quat q, vec3 v ) #
Constructor. Initializes the matrix using a given quaternion and a vec3 vector.Arguments
mat4 ( float[] m, int transpose ) #
Constructor. Initializes the matrix using a given pointer to the source matrix.Arguments
- float[] m - Pointer to the source matrix.
- int transpose - If transpose is 0 (by default), the matrix is specified in the column major style.
void SetColumn ( int column, vec4 v ) #
Sets the specified column of the matrix using a given vec4 vector as a source.Arguments
- int column - Column.
- vec4 v - Source vector.
vec4 GetColumn ( int column ) #
Returns the specified matrix column.Arguments
- int column - Column.
Return value
The vec4 vector with column values.void SetColumn3 ( int column, vec3 v ) #
Sets the specified column of the matrix using a given three-component vec3 vector as a source, the last element of the column remains as is.Arguments
- int column - Column.
- vec3 v - Three-component source vector.
vec3 GetColumn3 ( int column ) #
Returns the XYZ components of the specified matrix column.Arguments
- int column - Column.
Return value
The vec3 vector with the first three elements of the specified matrix column.void SetIdentity ( ) #
Sets the matrix equal to the identity matrix.void SetRotate ( vec3 axis, float angle ) #
Sets the rotation matrix for a given axis.Arguments
- vec3 axis - Rotation axis.
- float angle - Rotation angle, in degrees.
quat GetRotate ( ) #
Returns the quaternion, representing the rotation part of the matrix.Return value
Matrix rotation part.void SetRotateX ( float angle ) #
Sets X rotation matrix.Arguments
- float angle - Rotation angle, in degrees.
void SetRotateY ( float angle ) #
Sets Y rotation matrix.Arguments
- float angle - Rotation angle, in degrees.
void SetRotateZ ( float angle ) #
Set Z rotation matrix.Arguments
- float angle - Rotation angle, in degrees.
void SetRow ( int row, vec4 v ) #
Sets the specified row of the matrix using a given vec4 vector as a source.Arguments
- int row - Row.
- vec4 v - Source vector.
vec4 GetRow ( int row ) #
Returns the specified matrix row.Arguments
- int row - Row.
Return value
The vec4 vector with row values.void SetRow3 ( int row, vec3 v ) #
Sets the specified row of the matrix using a given three-component vec3 vector as a source, the last element of the row remains as is.Arguments
- int row - Row.
- vec3 v - Three-component source vector.
vec3 GetRow3 ( int row ) #
Returns the first three elements of the specified matrix row.Arguments
- int row - Row.
Return value
The vec3 vector with the first three elements of the specified matrix row.void setZero ( ) #
Sets all matrix elements equal to 0.mat4 Operator*= ( mat4 m ) #
Performs matrix multiplication.Arguments
- mat4 m - Matrix.
Return value
Resulting matrix.mat4 Operator*= ( float v ) #
Performs scalar multiplication.Arguments
- float v - Scalar value.
Return value
Resulting matrix.mat4 Operator*= ( vec3 v ) #
Performs vector multiplication.Arguments
- vec3 v - Vector.
Return value
Resulting matrix.mat4 Operator*= ( vec4 v ) #
Performs vector multiplication.Arguments
- vec4 v - Vector.
Return value
Resulting matrix.mat4 Operator*= ( dvec3 v ) #
Performs vector multiplication.Arguments
- dvec3 v - Vector.
Return value
Resulting matrix.mat4 Operator*= ( dvec4 v ) #
Performs vector multiplication.Arguments
- dvec4 v - Vector.
Return value
Resulting matrix.mat4 Operator+= ( mat4 m ) #
Performs matrix addition.Arguments
- mat4 m - Matrix.
Return value
Resulting matrix.mat4 Operator- ( ) #
Performs matrix negation.mat4 Operator-= ( mat4 m ) #
Performs matrix subtraction.Arguments
- mat4 m - Matrix.
Return value
Resulting matrix.float Operator[] ( int i ) #
Performs array access to the matrix item using given item index.Arguments
- int i - Matrix item index.
Return value
Matrix item.Last update:
2021-04-29
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)