ASL
|
A Matrix4 is a 4x4 matrix useful for representing affine transformations in 3D space.
#include <Matrix4.h>
Public Member Functions | |
int | rows () const |
Returns the nubmer of rows of this matrix (4) | |
int | cols () const |
Returns the nubmer of columns of this matrix (4) | |
T | trace () const |
Returns the trace of this matrix. | |
T & | operator() (int i, int j) |
Returns the element at row i , column j . | |
Matrix4_ (T a11, T a12, T a13, T a14, T a21, T a22, T a23, T a24, T a31, T a32, T a33, T a34, T a41=0, T a42=0, T a43=0, T a44=1) | |
Constructs a matrix with the given elements (by rows) with last row [0 0 0 1] by default. | |
Matrix4_ (const Vec3_< T > &v1, const Vec3_< T > &v2, const Vec3_< T > &v3, const Vec3_< T > &v4=Vec3_< T >(0, 0, 0)) | |
Constructs a matrix from 4 3D vectors used as columns, setting the last row as [0 0 0 1]. | |
Matrix4_ (const Vec4_< T > &v1, const Vec4_< T > &v2, const Vec4_< T > &v3, const Vec4_< T > &v4) | |
Constructs a matrix from 4 4D vectors used as columns. | |
Matrix4_ (const T *m, bool colmajor=false) | |
Constructs a matrix from elements pointed by m, row-major (default) or column-major. | |
template<class T2 > | |
Matrix4_< T2 > | with () const |
Returns a copy of this matrix with elements converted to the given type. | |
Matrix4_ | transposed () const |
Returns this matrix transposed. | |
Matrix4_ | operator+ (const Matrix4_ &B) const |
Returns this matrix plus B | |
Matrix4_ | operator- (const Matrix4_ &B) const |
Returns this matrix minus B | |
Matrix4_ | operator* (const Matrix4_ &B) const |
Returns this matrix multiplied by B | |
Matrix4_ & | operator*= (const Matrix4_ &B) |
Multipies this matrix by B | |
Matrix4_ | operator* (T t) const |
Returns this matrix multipled by scalar t | |
Matrix4_ & | operator*= (T t) |
Multiplies this matrix by scalar t | |
Vec4_< T > | operator* (const Vec4_< T > &p) const |
Returns vector p left-multiplied by this matrix. | |
Vec3_< T > | operator* (const Vec3_< T > &p) const |
Returns vector p transformed by this affine transform. | |
Vec3_< T > | operator^ (const Vec3_< T > &p) const |
Returns vector p transformed by this projective transform. | |
Vec3_< T > | operator% (const Vec3_< T > &p) const |
Returns vector p left-multiplied by the 3x3 top-left submatrix (no translation). | |
Vec3_< T > | eulerAngles (int a0, int a1, int a2) const |
Computes the Euler angles corresponding to this rotation matrix (the top-left 3x3 submatrix) for the given axes rotation order given as [0, 1, 2] indices, equivalent to the rotateE function. | |
Vec3_< T > | eulerAngles (const char *a) const |
Computes the Euler angles corresponding to this rotation matrix (the top-left 3x3 submatrix) for the given axes rotation order given as a string, such as "XYZ" or "XYZ*", equivalent to the rotateE function. | |
Matrix4_ | inverse () const |
Returns the inverse of this matrix. | |
Quaternion_< T > | rotation () const |
Returns the rotation part of this matrix as a Quaternion. | |
Vec3_< T > | axisAngle () const |
Returns the rotation part of this matrix as a rotation vector (axis-angle representation) | |
Vec3_< T > | column3 (int i) const |
Returns the i-th column's top 3 elements as a Vec3. | |
Vec4_< T > | column (int i) const |
Returns the i-th column as a Vec4. | |
Vec3_< T > | translation () const |
Returns the translation part of this matrix (the last column) as a Vec3. | |
Matrix4_ & | setTranslation (const Vec3_< T > &t) |
Sets the translation part of this matrix (the last column) | |
T | det () const |
Returns the determinant of this matrix. | |
T | normSq () const |
Returns the matrix Frobenius norm squared. | |
T | norm () const |
Returns the matrix Frobenius norm. | |
Static Public Member Functions | |
static Matrix4_ | identity () |
Returns the identity matrix. | |
static Matrix4_ | translate (const Vec3_< T > &t) |
Returns a translation matrix for the given vector. | |
static Matrix4_ | translate (T x, T y, T z) |
Returns a translation matrix for the given coordinates. | |
static Matrix4_ | scale (const Vec3_< T > &s) |
Returns a scale matrix. | |
static Matrix4_ | scale (T s) |
Returns a uniform scale matrix. | |
static Matrix4_ | rotateX (T angle) |
Returns a rotation matrix of the given angle in radians around the x axis. | |
static Matrix4_ | rotateY (T angle) |
Returns a rotation matrix of the given angle in radians around the y axis. | |
static Matrix4_ | rotateZ (T angle) |
Returns a rotation matrix of the given angle in radians around the z axis. | |
static Matrix4_ | rotate (const Vec3_< T > &axis, T angle) |
Returns a rotation matrix of an angle in radians around a given axis. | |
static Matrix4_ | rotate (const Vec3_< T > &axisAngle) |
Returns a rotation matrix from a rotation vector (aligned with the axis and with the rotation angle as magnitude) | |
static Matrix4_ | rotateE (const Vec3_< T > &r, int a0, int a1, int a2) |
Returns a rotation matrix created from Euler angles rotating the components of r in axes a0, a1, a2 (each one of 0, 1 or 2), the result is Ra0 * Ra1 * Ra2 | |
static Matrix4_ | fromEuler (const Vec3_< T > &r, int a0, int a1, int a2) |
Same as rotateE() More... | |
static Matrix4_ | rotateE (const Vec3_< T > &r, const char *a) |
Returns a rotation matrix created from Euler angles rotating the components of r in axes given as a string, such as "XYZ", if an '*' is appended then the result is equivalent to rotations on fixed axes, while by default it is equivalent to rotations on moving axes. | |
static Matrix4_ | fromEuler (const Vec3_< T > &r, const char *a) |
Returns a rotation matrix created from Euler angles rotating the components of r in axes given as a string, such as "XYZ", if an '*' is appended then the result is equivalent to rotations on fixed axes, while by default it is equivalent to rotations on moving axes. More... | |
static Matrix4_ | orthonormalBase (const Vec3_< T > &vec) |
Returns an orthonormal vector base using a given vector as the Z axis and creating two other unit vectors perpendicular to Z and between them. | |
Returns a rotation matrix created from Euler angles rotating the components of r in axes given as a string, such as "XYZ", if an '*' is appended then the result is equivalent to rotations on fixed axes, while by default it is equivalent to rotations on moving axes.
Same as rotateE()