The Matrix4x4 class represents a 4x4 transformation matrix in 3D space. More...
#include <matrix4x4.h>
Public Member Functions | |
| Matrix4x4 () | |
| Constructs an identity matrix. | |
| Matrix4x4 (bool valid) | |
| Constructs a valid or an invalid identity matrix. | |
| Matrix4x4 (const Matrix4x4 &matrix) | |
| Constructs this Matrix4x4 object as a copy of matrix. | |
| Matrix4x4 (const double *values) | |
| Constructs a matrix from the given 16 double-precision values. | |
| Matrix4x4 (const float *values) | |
| Constructs a matrix from the given 16 single-precision values. | |
| Matrix4x4 (double x, double y, double z) | |
| Constructs a matrix that translates coordinates by the components x, y, and z. | |
| Matrix4x4 (double nx, double ox, double ax, double tx, double ny, double oy, double ay, double ty, double nz, double oz, double az, double tz) | |
| Constructs a matrix from the N, O, A, T vector components. | |
| void | SetVX (const Vector3 &n) |
| Sets the X vector (N vector). | |
| void | SetVY (const Vector3 &o) |
| Sets the Y vector (O vector). | |
| void | SetVZ (const Vector3 &a) |
| Sets the Z vector (A vector). | |
| void | SetVX (double x, double y, double z) |
| Sets the X vector values (N vector). | |
| void | SetVY (double x, double y, double z) |
| Sets the Y vector values (O vector). | |
| void | SetVZ (double x, double y, double z) |
| Sets the Z vector values (A vector). | |
| void | SetPos (double x, double y, double z) |
| Sets the position (T). | |
| void | SetVX (const double *xyz) |
| Sets the X vector values (N vector). | |
| void | SetVY (const double *xyz) |
| Sets the Y vector values (O vector). | |
| void | SetVZ (const double *xyz) |
| Sets the Z vector values (A vector). | |
| void | SetPos (const double *xyz) |
| Sets the position (T). | |
| void | SetValues (const double *values) |
| Sets the elements of matrix from the given 16 double-precision values. | |
| Vector3 | VX () const |
| Returns the X vector (N vector). | |
| Vector3 | VY () const |
| Returns the Y vector (O vector). | |
| Vector3 | VZ () const |
| Returns the Z vector (A vector). | |
| void | VX (double *xyz) const |
| Writes the X vector (N vector) into array of 3 double-precision xyz values. | |
| void | VY (double *xyz) const |
| Writes the Y vector (O vector) into array of 3 double-precision xyz values. | |
| void | VZ (double *xyz) const |
| Writes the Z vector (A vector) into array of 3 double-precision xyz values. | |
| void | Pos (double *xyz) const |
| Writes the position (T vector) into array of 3 double-precision xyz values. | |
| void | Set (int row, int column, double value) |
| Sets a new value to the element at position (row, column) in this matrix. | |
| double | Get (int row, int column) const |
| Returns the value of the element at position (row, column) in this matrix. | |
| Matrix4x4 | Inverted (bool *invertible=nullptr) const |
| Returns the inverse of this matrix. | |
| bool | IsHomogeneous () const |
Returns true if the matrix is homogeneous; false otherwise. | |
| bool | MakeHomogeneous () |
| Forces this matrix to be homogeneous. | |
| void | ToXYZRPW (double *xyzwpr) const |
| Calculates the position and euler angles ([x,y,z,r,p,w] vector) from this matrix. | |
| void | FromXYZRPW (const double *xyzwpr) |
| Calculates this matrix from the position and euler angles ([x,y,z,r,p,w] vector). | |
| const double * | ValuesD () const |
| Returns a constant pointer to the raw data of this matrix as 16 double-precision numbers. | |
| const float * | ValuesF () const |
| Returns a constant pointer to the raw data of this matrix as 16 single-precision numbers. | |
| const double * | Values () const |
| Returns a constant pointer to the raw data of this matrix as 16 double- or single-precision numbers. | |
| void | Values (double *values) const |
| Writes the contents of this matrix into array of 16 double-precision values. | |
| void | Values (float *values) const |
| Writes the contents of this matrix into array of 16 single-precision values. | |
| bool | Valid () const |
Returns true if the matrix is marked as valid; false otherwise. | |
| Matrix4x4 & | operator= (const Matrix4x4 &matrix) |
| Sets this Matrix4x4 object as a copy of matrix. | |
| Matrix4x4 | inv () |
| void | setPos (double x, double y, double z) |
Static Public Member Functions | |
| static Matrix4x4 | XYZRPW_2_Mat (double x, double y, double z, double r, double p, double w) |
| Constructs a matrix from the position and euler angles ([x,y,z,r,p,w] vector). | |
| static Matrix4x4 | XYZRPW_2_Mat (const double *xyzwpr) |
| Constructs a matrix from the position and euler angles ([x,y,z,r,p,w] vector). | |
| static Matrix4x4 | transl (double x, double y, double z) |
| Constructs a matrix that translates coordinates by the components x, y, and z. | |
| static Matrix4x4 | rotx (double rx) |
| Constructs a matrix that rotates coordinates around X axis. | |
| static Matrix4x4 | roty (double ry) |
| Constructs a matrix that rotates coordinates around Y axis. | |
| static Matrix4x4 | rotz (double rz) |
| Constructs a matrix that rotates coordinates around Z axis. | |
The Matrix4x4 class represents a 4x4 transformation matrix in 3D space.
The Matrix4x4 class in general is treated as a row-major matrix, in that the constructors and operator() functions take data in row-major format, as is familiar in C-style usage.
Internally the data is stored as column-major format.
When using these functions be aware that they return data in column-major format:
Definition at line 69 of file matrix4x4.h.
| Matrix4x4 | ( | ) |
Constructs an identity matrix.
Definition at line 41 of file matrix4x4.cpp.
|
explicit |
Constructs a valid or an invalid identity matrix.
Definition at line 48 of file matrix4x4.cpp.
Constructs this Matrix4x4 object as a copy of matrix.
Definition at line 55 of file matrix4x4.cpp.
| Matrix4x4 | ( | const double * | values | ) |
Constructs a matrix from the given 16 double-precision values.
The contents of the array values is assumed to be in column-major order.
| values | \( \begin{bmatrix} v_1 & v_2 & v_3 & v_4 & v_5 & v_6 & v_7 & v_8 & v_9 & v_{10} & v_{11} & v_{12} & v_{13} & v_{14} & v_{15} & v_{16} \end{bmatrix} \) |
Definition at line 61 of file matrix4x4.cpp.
| Matrix4x4 | ( | const float * | values | ) |
Constructs a matrix from the given 16 single-precision values.
The contents of the array values is assumed to be in column-major order.
| values | \( \begin{bmatrix} v_1 & v_2 & v_3 & v_4 & v_5 & v_6 & v_7 & v_8 & v_9 & v_{10} & v_{11} & v_{12} & v_{13} & v_{14} & v_{15} & v_{16} \end{bmatrix} \) |
Definition at line 71 of file matrix4x4.cpp.
| Matrix4x4 | ( | double | x, |
| double | y, | ||
| double | z ) |
Constructs a matrix that translates coordinates by the components x, y, and z.
Definition at line 81 of file matrix4x4.cpp.
| Matrix4x4 | ( | double | nx, |
| double | ox, | ||
| double | ax, | ||
| double | tx, | ||
| double | ny, | ||
| double | oy, | ||
| double | ay, | ||
| double | ty, | ||
| double | nz, | ||
| double | oz, | ||
| double | az, | ||
| double | tz ) |
Constructs a matrix from the N, O, A, T vector components.
Definition at line 96 of file matrix4x4.cpp.
| void FromXYZRPW | ( | const double * | xyzwpr | ) |
Calculates this matrix from the position and euler angles ([x,y,z,r,p,w] vector).
The result is the same as: H = transl(x, y, z) * rotz(w * pi / 180) * roty(p * pi / 180) * rotx(r * pi / 180)
Definition at line 402 of file matrix4x4.cpp.
| double Get | ( | int | row, |
| int | column ) const |
Returns the value of the element at position (row, column) in this matrix.
Definition at line 275 of file matrix4x4.cpp.
|
inline |
Definition at line 507 of file matrix4x4.h.
| Matrix4x4 Inverted | ( | bool * | invertible = nullptr | ) | const |
Returns the inverse of this matrix.
Returns the identity if this matrix cannot be inverted; i.e. determinant() is zero.
Definition at line 280 of file matrix4x4.cpp.
| bool IsHomogeneous | ( | ) | const |
Returns true if the matrix is homogeneous; false otherwise.
Definition at line 285 of file matrix4x4.cpp.
| bool MakeHomogeneous | ( | ) |
Forces this matrix to be homogeneous.
The vx, vy, vz must be unitary vectors and respect: vx x vy = vz. Returns true if the matrix was not homogeneous and it was modified to be homogeneous.
Definition at line 321 of file matrix4x4.cpp.
Sets this Matrix4x4 object as a copy of matrix.
Definition at line 463 of file matrix4x4.cpp.
| void Pos | ( | double * | xyz | ) | const |
Writes the position (T vector) into array of 3 double-precision xyz values.
Definition at line 240 of file matrix4x4.cpp.
|
static |
Constructs a matrix that rotates coordinates around X axis.
| rx | rotation angle in radians. |
Definition at line 478 of file matrix4x4.cpp.
|
static |
Constructs a matrix that rotates coordinates around Y axis.
| ry | rotation angle in radians. |
Definition at line 485 of file matrix4x4.cpp.
|
static |
Constructs a matrix that rotates coordinates around Z axis.
| rz | rotation angle in radians. |
Definition at line 492 of file matrix4x4.cpp.
| void Set | ( | int | row, |
| int | column, | ||
| double | value ) |
Sets a new value to the element at position (row, column) in this matrix.
Definition at line 270 of file matrix4x4.cpp.
| void SetPos | ( | const double * | xyz | ) |
Sets the position (T).
Definition at line 188 of file matrix4x4.cpp.
| void SetPos | ( | double | x, |
| double | y, | ||
| double | z ) |
Sets the position (T).
Definition at line 160 of file matrix4x4.cpp.
|
inline |
Definition at line 510 of file matrix4x4.h.
| void SetValues | ( | const double * | values | ) |
Sets the elements of matrix from the given 16 double-precision values.
The contents of the array values is assumed to be in column-major order.
\( \begin{bmatrix} v_1 & v_5 & v_9 & v_{13} \\ v_2 & v_6 & v_{10} & v_{14} \\ v_3 & v_7 & v_{11} & v_{15} \\ v_4 & v_8 & v_{12} & v_{16} \end{bmatrix} \)
| values | \( \begin{bmatrix} v_1 & v_2 & v_3 & v_4 & v_5 & v_6 & v_7 & v_8 & v_9 & v_{10} & v_{11} & v_{12} & v_{13} & v_{14} & v_{15} & v_{16} \end{bmatrix} \) |
Definition at line 247 of file matrix4x4.cpp.
| void SetVX | ( | const double * | xyz | ) |
Sets the X vector values (N vector).
Definition at line 167 of file matrix4x4.cpp.
| void SetVX | ( | const Vector3 & | n | ) |
Sets the X vector (N vector).
Definition at line 118 of file matrix4x4.cpp.
| void SetVX | ( | double | x, |
| double | y, | ||
| double | z ) |
Sets the X vector values (N vector).
Definition at line 139 of file matrix4x4.cpp.
| void SetVY | ( | const double * | xyz | ) |
Sets the Y vector values (O vector).
Definition at line 174 of file matrix4x4.cpp.
| void SetVY | ( | const Vector3 & | o | ) |
Sets the Y vector (O vector).
Definition at line 125 of file matrix4x4.cpp.
| void SetVY | ( | double | x, |
| double | y, | ||
| double | z ) |
Sets the Y vector values (O vector).
Definition at line 146 of file matrix4x4.cpp.
| void SetVZ | ( | const double * | xyz | ) |
Sets the Z vector values (A vector).
Definition at line 181 of file matrix4x4.cpp.
| void SetVZ | ( | const Vector3 & | a | ) |
Sets the Z vector (A vector).
Definition at line 132 of file matrix4x4.cpp.
| void SetVZ | ( | double | x, |
| double | y, | ||
| double | z ) |
Sets the Z vector values (A vector).
Definition at line 153 of file matrix4x4.cpp.
| void ToXYZRPW | ( | double * | xyzwpr | ) | const |
Calculates the position and euler angles ([x,y,z,r,p,w] vector) from this matrix.
Note: transl(x, y, z) * rotz(w * pi / 180) * roty(p * pi / 180) * rotx(r * pi / 180)
Definition at line 347 of file matrix4x4.cpp.
|
static |
Constructs a matrix that translates coordinates by the components x, y, and z.
Definition at line 470 of file matrix4x4.cpp.
| bool Valid | ( | ) | const |
Returns true if the matrix is marked as valid; false otherwise.
Definition at line 458 of file matrix4x4.cpp.
| const double * Values | ( | ) | const |
Returns a constant pointer to the raw data of this matrix as 16 double- or single-precision numbers.
This raw data is stored in column-major format.
Definition at line 436 of file matrix4x4.cpp.
| void Values | ( | double * | values | ) | const |
Writes the contents of this matrix into array of 16 double-precision values.
Definition at line 442 of file matrix4x4.cpp.
| void Values | ( | float * | values | ) | const |
Writes the contents of this matrix into array of 16 single-precision values.
Definition at line 450 of file matrix4x4.cpp.
| const double * ValuesD | ( | ) | const |
Returns a constant pointer to the raw data of this matrix as 16 double-precision numbers.
This raw data is stored in column-major format.
Definition at line 416 of file matrix4x4.cpp.
| const float * ValuesF | ( | ) | const |
Returns a constant pointer to the raw data of this matrix as 16 single-precision numbers.
This raw data is stored in column-major format.
Definition at line 425 of file matrix4x4.cpp.
| Vector3 VX | ( | ) | const |
Returns the X vector (N vector).
Definition at line 195 of file matrix4x4.cpp.
| void VX | ( | double * | xyz | ) | const |
Writes the X vector (N vector) into array of 3 double-precision xyz values.
Definition at line 219 of file matrix4x4.cpp.
| Vector3 VY | ( | ) | const |
Returns the Y vector (O vector).
Definition at line 203 of file matrix4x4.cpp.
| void VY | ( | double * | xyz | ) | const |
Writes the Y vector (O vector) into array of 3 double-precision xyz values.
Definition at line 226 of file matrix4x4.cpp.
| Vector3 VZ | ( | ) | const |
Returns the Z vector (A vector).
Definition at line 211 of file matrix4x4.cpp.
| void VZ | ( | double * | xyz | ) | const |
Writes the Z vector (A vector) into array of 3 double-precision xyz values.
Definition at line 233 of file matrix4x4.cpp.
|
static |
Constructs a matrix from the position and euler angles ([x,y,z,r,p,w] vector).
The result is the same as: H = transl(x, y, z) * rotz(w * pi / 180) * roty(p * pi / 180) * rotx(r * pi / 180)
Definition at line 397 of file matrix4x4.cpp.
|
static |
Constructs a matrix from the position and euler angles ([x,y,z,r,p,w] vector).
The result is the same as: H = transl(x, y, z) * rotz(w * pi / 180) * roty(p * pi / 180) * rotx(r * pi / 180)
Definition at line 381 of file matrix4x4.cpp.