# Unigine::Math::dmat4 Struct

This class represents a matrix of twelve (3x4) double components.

## dmat4 ( const dvec3& c0, const dvec3& c1, const dvec3& c2, const dvec3& c3 ) #

Constructor. Initializes the matrix using given three dvec3 vectors.
Output
``````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 |``````

### Arguments

• const dvec3& c0 - Source vector for the first column.
• const dvec3& c1 - Source vector for the second column.
• const dvec3& c2 - Source vector for the third column.
• const dvec3& c3 - Source vector for the fourth column.

## dmat4 ( const quat& q, const dvec3& v ) #

Constructor. Initializes the matrix using a given quaternion and a dvec3 vector.

### Arguments

• const quat& q - Source quaternion.
• const dvec3& v - Source vector.

## dmat4 ( const mat3& m, const dvec3& v ) #

Constructor. Initializes the matrix using a given source mat3 matrix (3x3) and a dvec3 vector.

### Arguments

• const mat3& m - Source matrix (3x3).
• const dvec3& v - Source vector.

## dmat4 ( const float* m, int transpose ) #

Constructor. Initializes the matrix using a given pointer to the source matrix.

### Arguments

• const float* m - Pointer to the source matrix.
• int transpose - If transpose is 0 (by default), the matrix is specified in the column major style.

## dmat4 ( const double* m, int transpose ) #

Constructor. Initializes the matrix using a given pointer to the source matrix.

### Arguments

• const double* m - Pointer to the source matrix.
• int transpose - If transpose is 0 (by default), the matrix is specified in the column major style.

## dmat4 ( const 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.
Output
``````Resulting matrix:
| m00  	 m01  	 m02	  0.0f |
M=  | m10    m11  	 m12      0.0f |
| m20    m21     m22      0.0f |``````

### Arguments

• const mat3& m - Source matrix (3x3).

## dmat4 ( const mat2& m ) #

Constructor. Initializes the matrix using a given mat2 source matrix (2x2). The matrix elements are filled using corresponding elements of the source matrix.
Output
``````Resulting matrix:
| m00  	 m01  	 0.0f	  0.0f |
M=  | m10    m11  	 0.0f     0.0f |
| 0.0f   0.0f    1.0f     0.0f |``````

### Arguments

• const mat2& m - Source matrix (2x2).

## dmat4 ( double v ) #

Constructor. Initializes the matrix using a given scalar value.
Source code (UnigineScript)
``````dmat4(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	|
*/``````

### Arguments

• double v - Scalar value.

## dmat4 ( const dmat4& m ) #

Constructor. Initializes the matrix by copying a given source matrix.

### Arguments

• const dmat4& m - Source matrix.

## dmat4 ( ) #

Default constructor. Produces an identity matrix.

## explicit dmat4 ( const mat4& m ) #

Constructor. Initializes the matrix using a given source mat4 matrix (4x4). The matrix elements are filled using corresponding elements of the source matrix.

### Arguments

• const mat4& m - Source matrix (4x4).

## explicit dmat4 ( const quat& q ) #

Constructor. Initializes the matrix using a given source quaternion.

### Arguments

• const quat& q - Source quaternion.

## dmat4 ( const float* m ) #

Constructor. Initializes the matrix using a given pointer to an array of float elements.

### Arguments

• const float* m

## dmat4 ( double m00_, double m10_, double m20_, double m01_, double m11_, double m21_, double m02_, double m12_, double m22_, double m03_, double m13_, double m23_ ) #

Constructor. Initializes the matrix using given double elements.
Output
``````Resulting matrix:
| m00  	 m01  	 m02	 m03 |
M=  | m10    m11  	 m12     m13 |
| m20    m21     m22     m23 |``````

### Arguments

• double m00_ - 00 element.
• double m10_ - 10 element.
• double m20_ - 20 element.
• double m01_ - 01 element.
• double m11_ - 11 element.
• double m21_ - 21 element.
• double m02_ - 02 element.
• double m12_ - 12 element.
• double m22_ - 22 element.
• double m03_ - 03 element.
• double m13_ - 13 element.
• double m23_ - 23 element.

## dmat4 ( double v, ConstexprTag ) #

Constructor. Initializes every element of the matrix with the given double element.
Output
``````Resulting matrix:
| v    v 	v   v |
M=  | v    v  	v   v |
| v    v    v   v |``````

### Arguments

• double v - Element to pave the matrix with.
• ConstexprTag - Auxiliary tag.

## dmat4 ( double m00_, double m10_, double m20_, double m01_, double m11_, double m21_, double m02_, double m12_, double m22_, double m03_, double m13_, double m23_, ConstexprTag ) #

Constructor. Initializes the matrix using given double elements.
Output
``````Resulting matrix:
| m00  	 m01  	 m02	 m03 |
M=  | m10    m11  	 m12     m13 |
| m20    m21     m22     m23 |``````

### Arguments

• double m00_ - 00 element.
• double m10_ - 10 element.
• double m20_ - 20 element.
• double m01_ - 01 element.
• double m11_ - 11 element.
• double m21_ - 21 element.
• double m02_ - 02 element.
• double m12_ - 12 element.
• double m22_ - 22 element.
• double m03_ - 03 element.
• double m13_ - 13 element.
• double m23_ - 23 element.
• ConstexprTag - Auxiliary tag.

## voidset ( int row, int column, double v ) #

Sets a new value of the matrix element specified by row and column.

### Arguments

• int row - Row.
• int column - Column.
• double v - The value to be set.

## voidset ( const float* m, int transpose ) #

Sets new matrix values using a pointer to the source matrix.

### Arguments

• const float* m - Pointer to the source matrix.
• int transpose - If transpose is 0 (by default), the matrix is specified in the column major style.

## voidset ( const mat2& m ) #

Sets new matrix values using a given mat2 source matrix (2x2). The matrix elements are filled using corresponding elements of the source matrix.

### Arguments

• const mat2& m - Source matrix (2x2).

## voidset ( const mat3& m ) #

Sets new matrix values using a given mat3 source matrix (3x3). The matrix elements are filled using corresponding elements of the source matrix.

### Arguments

• const mat3& m - Source matrix (3x3).

## voidset ( const quat& q, const dvec3& v ) #

Sets new matrix values using a given quaternion and a dvec3 vector.

### Arguments

• const quat& q - Source quaternion.
• const dvec3& v - Source vector.

## voidset ( const quat& q ) #

Sets new matrix values using a given source quaternion.

### Arguments

• const quat& q - Source quaternion.

## voidset ( const mat4& m ) #

Sets new matrix values using a given mat4 source matrix (4x4). The matrix elements are filled using corresponding elements of the source matrix.

### Arguments

• const mat4& m - Source matrix (4x4).

## voidset ( const double* m, int transpose ) #

Sets new matrix values using a pointer to the source matrix.

### Arguments

• const double* m - Pointer to the source matrix.
• int transpose - If transpose is 0 (by default), the matrix is specified in the column major style.

## voidset ( const dmat4& m ) #

Sets the matrix equal to the specified source matrix.

### Arguments

• const dmat4& m - Source matrix.

## voidset ( const mat3& m, const dvec3& v ) #

Sets new matrix values using a given source mat3 matrix (3x3) and a dvec3 vector.

### Arguments

• const mat3& m - Source matrix (3x3).
• const dvec3& v - Source vector.

## double &get ( int row, int column ) #

Returns the reference to the matrix element specified by given row and column.

### Arguments

• int row - Row.
• int column - Column.

### Return value

Matrix element reference.

## doubleget ( int row, int column ) const#

Returns the value of the matrix element specified by given row and column.

### Arguments

• int row - Row.
• int column - Column.

### Return value

Matrix element value.

## double *get ( ) #

Returns the pointer to the matrix.

### Return value

Pointer to the matrix.

## const double *get ( ) const#

Returns the constant pointer to the matrix.

### Return value

Constant pointer to the matrix.

## voidget ( double* m, int transpose ) const#

Fills the destination matrix, specified by the given pointer, with matrix values.

### Arguments

• double* m - Destination matrix pointer.
• int transpose - If transpose is 0 (by default), the matrix is specified in the column major style.

## voidsetColumn ( int column, const dvec4& v ) #

Sets the specified column of the matrix using a given dvec4 vector as a source.

### Arguments

• int column - Column.
• const dvec4& v - Source vector.

## dvec4getColumn ( int column ) const#

Returns the specified matrix column.

### Arguments

• int column - Column.

### Return value

The dvec4 vector with column values.

## voidsetColumn3 ( int column, const dvec3& v ) #

Sets the specified column of the matrix using a given three-component dvec3 vector as a source.

### Arguments

• int column - Column.
• const dvec3& v - Three-component source vector.

## dvec3getColumn3 ( int column ) const#

Returns the specified matrix column.

### Arguments

• int column - Column.

### Return value

The dvec3 vector with column values.

## voidsetIdentity ( ) #

Sets the matrix equal to the identity matrix.

## voidsetRotate ( const dvec3& axis, double angle ) #

Sets the rotation matrix for a given axis.

### Arguments

• const dvec3& axis - Rotation axis.
• double angle - Rotation angle, in degrees.

## quatgetRotate ( ) const#

Returns the quaternion, representing the rotation part of the matrix.

### Return value

Matrix rotation part.

## voidsetRotateX ( double angle ) #

Sets X rotation matrix.

### Arguments

• double angle - Rotation angle, in degrees.

## voidsetRotateY ( double angle ) #

Sets Y rotation matrix.

### Arguments

• double angle - Rotation angle, in degrees.

## voidsetRotateZ ( double angle ) #

Sets Z rotation matrix.

### Arguments

• double angle - Rotation angle, in degrees.

## voidsetRow ( int row, const dvec4& v ) #

Sets the specified row of the matrix using a given dvec4 vector as a source.

### Arguments

• int row - Row.
• const dvec4& v - Source vector.

## dvec4getRow ( int row ) const#

Returns the specified matrix row.

### Arguments

• int row - Row.

### Return value

The dvec4 vector with row values.

## voidsetRow3 ( int row, const dvec3& v ) #

Sets the specified row of the matrix using a given three-component dvec3 vector as a source, the last element of the row remains as is.

### Arguments

• int row - Row.
• const dvec3& v - Three-component source vector.

## dvec3getRow3 ( int row ) const#

Returns the first three elements of the specified matrix row.

### Arguments

• int row - Row.

### Return value

The dvec3 vector with the first three elements of the specified matrix row.

## voidsetScale ( const dvec3& v ) #

Fills the scaling matrix using a given dvec3 source vector.
Output
``````Scaling matrix:
| v.x   	0.0f  	  0.0f	    0.0f |
S=  | 0.0f      v.y  	  0.0f      0.0f |
| 0.0f      0.0f      v.z  		0.0f |``````

### Arguments

• const dvec3& v - Source vector.

## vec3getScale ( ) const#

Returns the three-component vec3 vector, representing the scaling part of the matrix.

### Return value

Three-component vector with the scaling part of the matrix.

## voidsetTranslate ( const dvec3& v ) #

Fills the translation matrix using a given dvec3 source vector.
Output
``````Translation matrix:
| 1.0f   	0.0f  	  0.0f	    v.x |
T=  | 0.0f      1.0f  	  0.0f      v.y |
| 0.0f      0.0f      1.0f  	v.z |``````

### Arguments

• const dvec3& v - Source vector.

## dvec3getTranslate ( ) const#

Returns the three-component vec3 vector, representing the translation part of the matrix.

### Return value

Three-component vector with the translation part of the matrix.

## voidsetZero ( ) #

Sets all matrix elements equal to 0.

## const double *operator const double * ( ) const#

Performs type conversion to const double *.

## const void *operator const void * ( ) const#

Performs type conversion to const void *.

## double *operator double * ( ) #

Performs type conversion to double *.

## void *operator void * ( ) #

Performs type conversion to void *.

## dmat4 &operator*= ( const dmat4& m ) #

Performs matrix multiplication.

### Arguments

• const dmat4& m - Matrix.

### Return value

Resulting matrix.

## dmat4 &operator*= ( double v ) #

Performs scalar multiplication.

### Arguments

• double v - Scalar value.

### Return value

Resulting matrix.

## dmat4 &operator+= ( const dmat4& m ) #

### Arguments

• const dmat4& m - Matrix.

### Return value

Resulting matrix.

## dmat4operator- ( ) const#

Performs matrix negation.

### Return value

Resulting matrix.

## dmat4 &operator-= ( const dmat4& m ) #

Performs matrix subtraction.

### Arguments

• const dmat4& m - Matrix.

### Return value

Resulting matrix.

## dmat4 &operator= ( const dmat4& m ) #

Performs matrix assignment. Destination matrix = Source matrix.

### Arguments

• const dmat4& m - Source matrix.

Result.

## double &operator[] ( int i ) #

Performs array access to the matrix item reference using given item index.

### Arguments

• int i - Matrix item index.

### Return value

Matrix item reference.

## doubleoperator[] ( int i ) const#

### Arguments

• int i - Matrix item index.

Matrix item.

## dvec3getAxisX ( ) const#

Returns the normalized vector representing the X axis. Call this method to get the right or left vector of the matrix:
Source code (C++)
``````matrix.getAxisX(); // the left vector
-matrix.getAxisX(); // the right vector``````

### Return value

Vector representing the X axis.

## dvec3getAxisY ( ) const#

Returns the normalized vector representing the Y axis. Call this method to get the back or forward vector of the matrix:
Source code (C++)
``````matrix.getAxisY(); // the back vector
-matrix.getAxisY(); // the forward vector``````

### Return value

Vector representing the Y axis.

## dvec3getAxisZ ( ) const#

Returns the normalized vector representing the Z axis. Call this method to get the up or down vector of the matrix:
Source code (C++)
``````matrix.getAxisZ(); // the up vector
-matrix.getAxisZ(); // the down vector``````

### Return value

Vector representing the Z axis.

## doubledeterminant ( const dmat4& m ) #

Returns the determinant of the given matrix.

### Arguments

• const dmat4& m - Input matrix.

### Return value

Determinant of the matrix.

## dmat4translate ( const dvec3& v ) #

Returns the translation matrix using a given dvec3 translation vector.
Output
``````Translation matrix:
| 1.0f   	0.0f  	  0.0f	    v.x |
T=  | 0.0f      1.0f  	  0.0f      v.y |
| 0.0f      0.0f      1.0f  	v.z |``````

### Arguments

• const dvec3& v - Translation vector.

### Return value

Translated matrix.

## dmat4translate ( const dvec4& v ) #

Returns the translation matrix using a given dvec4 translation vector.
Output
``````Translation matrix:
| 1.0f   	0.0f  	  0.0f	    v.x |
T=  | 0.0f      1.0f  	  0.0f      v.y |
| 0.0f      0.0f      1.0f  	v.z |``````

### Arguments

• const dvec4& v - Translation vector.

### Return value

Translated matrix.

## dmat4translate ( const dvec2& v ) #

Returns the translation matrix using a given dvec2 translation vector.
Output
``````Translation matrix:
| 1.0f   	0.0f  	  0.0f	    v.x |
T=  | 0.0f      1.0f  	  0.0f      v.y |
| 0.0f      0.0f      1.0f  	v.z |``````

### Arguments

• const dvec2& v - Translation vector.

### Return value

Translated matrix.

## dmat4translate ( double x, double y, double z ) #

Returns the translation matrix using a dvec3 translation vector with given components.
Output
``````Translation matrix:
| 1.0f   	0.0f  	  0.0f	    v.x |
T=  | 0.0f      1.0f  	  0.0f      v.y |
| 0.0f      0.0f      1.0f  	v.z |``````

### Arguments

• double x - X component of the translation vector.
• double y - Y component of the translation vector.
• double z - Z component of the translation vector.

### Return value

Translated matrix.

## dmat4rotate ( const dvec3& axis, double angle ) #

Returns the rotation matrix for a given axis and an angle.

### Arguments

• const dvec3& axis - Rotation axis.
• double angle - Rotation angle, in degrees.

Rotated matrix.

## dmat4rotate ( double x, double y, double z, double angle ) #

Returns the rotation matrix for an angle and an axis with given components.

### Arguments

• double x - X component of the rotation vector.
• double y - Y component of the rotation vector.
• double z - Z component of the rotation vector.
• double angle - Rotation angle, in degrees.

Rotated matrix.

## dmat4rotateX ( double angle ) #

Returns the matrix rotated around the X-axis by a given angle.

### Arguments

• double angle - Rotation angle, in degrees.

Rotated matrix.

## dmat4rotateY ( double angle ) #

Returns the matrix rotated around the Y-axis by a given angle.

### Arguments

• double angle - Rotation angle, in degrees.

Rotated matrix.

## dmat4rotateZ ( double angle ) #

Returns the matrix rotated around the Z-axis by a given angle.

### Arguments

• double angle - Rotation angle, in degrees.

Rotated matrix.

## dmat4scale ( const dvec3& v ) #

Returns the matrix scaled by a given dvec3 source vector.
Output
``````Scaling matrix:
| v.x   	0.0f  	  0.0f	    0.0f |
S=  | 0.0f      v.y  	  0.0f      0.0f |
| 0.0f      0.0f      v.z  		0.0f |``````

### Arguments

• const dvec3& v - Source vector.

Scaled matrix.

## dmat4scale ( double x, double y, double z ) #

Returns the matrix scaled by a given dvec3 source vector.
Output
``````Scaling matrix:
| v.x   	0.0f  	  0.0f	    0.0f |
S=  | 0.0f      v.y  	  0.0f      0.0f |
| 0.0f      0.0f      v.z  		0.0f |``````

### Arguments

• double x - X component of the scale vector.
• double y - Y component of the scale vector.
• double z - Z component of the scale vector.

Scaled matrix.

## dmat4scale ( double x ) #

Returns the matrix scaled by a given dvec3 source vector where every component is the same provided value.
Output
``````Scaling matrix:
| v.x   	0.0f  	  0.0f	    0.0f |
S=  | 0.0f      v.y  	  0.0f      0.0f |
| 0.0f      0.0f      v.z  		0.0f |``````

### Arguments

• double x - X, Y, and Z components of the scale vector.

Scaled matrix.

## unsigned inthash ( ) const#

Last update: 2022-04-20