A 4-by-4 matrix for affine transformations and perspective projections of 3D geometry.
This matrix can represent the most generic form of transformations for 3D objects, including perspective projections, which float3x4 cannot store, and translations, which float3x3 cannot represent.
The elements of this matrix are
The element m_yx is the value on the row y and column x. You can access m_yx using the double-bracket notation m[y][x], or using the member function m.At(y, x);
The member functions in this class use the convention that transforms are applied to vectors in the form M * v. This means that "float4x4 M, M1, M2; M = M1 * M2;" gives a transformation M that applies M2 first, followed by M1 second, i.e. M * v = M1 * M2 * v = M1 * (M2 * v). This is the convention commonly used with OpenGL. The opposing convention (v * M) is commonly used with Direct3D. This class uses row-major storage, which means that the elements are packed in memory in order m[0][0], m[0][1], m[0][2], m[0][3], m[1][0], m[1][1], ... The elements for a single row of the matrix hold successive memory addresses. This is the same memory layout as with C++ multidimensional arrays.
float4x4 | A 4-by-4 matrix for affine transformations and perspective projections of 3D geometry. |
v | Stores the data in this matrix in row-major format. |
zero[static][const] | A constant matrix that has zeroes in all its entries. |
identity[static][const] | A constant matrix that is the identity. |
nan[static][const] | A compile-time constant float4x4 which has NaN in each element. |
ctor (+6 overloads) | Creates a new float4x4 with uninitialized member values. |
GetScale()[const] | Returns the scaling performed by this matrix. |
ComplementaryProjection()[const] | Computes the complementary projection of this matrix. |
operator[](row) (+1 overload) | Returns the given element. |
At(row,col) (+1 overload) | Returns the given element. [noscript]. |
Row(row) (+1 overload) | Returns the given row. [noscript]. |
Row3(row)[const] | |
Col(col)[const] | Returns the given column. |
Diagonal()[const] | Returns the main diagonal. |
ScaleRow3(row,scalar) | Scales the three first elements of the given row by a scalar. |
ScaleRow(row,scalar) | Scales the given row by a scalar. |
ScaleCol3(col,scalar) | Scales the three first elements of the given column by a scalar. |
ScaleCol(col,scalar) | Scales the given column by a scalar. |
Float3x3Part()[const] | Returns the upper-left 3-by-3 part. |
Float3x4Part() (+1 overload) | Returns the upper-left 3-by-4 part. |
TranslatePart()[const] | Returns the translation part. |
RotatePart()[const] | Returns the top-left 3x3 part of this matrix. This stores the rotation part of this matrix (if this matrix represents a rotation). |
X/Y/Z()[const] | Returns the local +X axis in world space. |
ptr() (+1 overload) | Accesses this structure as a float array. |
SetRow3(row,data) (+2 overloads) | Sets the three first elements of the given row. The fourth element is left unchanged. |
SetRow(row,data) (+3 overloads) | Sets the values of the given row. |
SetCol3(column,data) (+2 overloads) | Sets the three first elements of the given column. The fourth element is left unchanged. |
SetCol(column,data) (+3 overloads) | Sets the values of the given column. |
Set(...) (+3 overloads) | Sets all values of this matrix. |
Set3x3Part(rotation) | |
Set3x4Part(rotateTranslate) | |
SetIdentity() | Sets this matrix to equal the identity. |
SwapColumns(col1,col2) | Swaps two columns. |
SwapRows(row1,row2) | Swaps two rows. |
SetTranslatePart(tx,ty,tz) (+2 overloads) | Sets the translation part of this matrix. |
SetRotatePart/X/Y/Z(...) (+2 overloads) | Sets the 3-by-3 part of this matrix to perform rotation about the given axis and angle (in radians). |
operator=(rhs) (+4 overloads) | Sets this float4x4 to represent the same transformation as the given float3x3. |
Determinant3()[const] | Computes the determinant of the upper-left 3x3 submatrix of this matrix. |
Determinant4()[const] | Computes the determinant of this matrix. |
SubMatrix(i,j)[const] | Returns the 3x3 submatrix that results when the row i and column j is removed from this matrix. |
Minor(i,j)[const] | Returns the determinant of the 3x3 submatrix that results when the row i and column j is removed from this matrix. |
Adjugate()[const] | Returns the adjugate of this matrix. |
CholeskyDecompose(outL)[const] | Computes the Cholesky decomposition of this matrix. |
LUDecompose(outLower,outUpper)[const] | Computes the LU decomposition of this matrix. |
Inverse(epsilon) | Inverts this matrix using the generic Gauss's method. |
Inverted()[const] | Returns an inverted copy of this matrix. |
InverseColOrthogonal() | Inverts a column-orthogonal matrix. |
InverseOrthogonalUniformScale() | Inverts a matrix that is a concatenation of only translate, rotate and uniform scale operations. |
InverseOrthonormal() | Inverts a matrix that is a concatenation of only translate and rotate operations. |
Transpose() | Transposes this matrix. |
Transposed()[const] | Returns a transposed copy of this matrix. |
InverseTranspose() | Computes the inverse transpose of this matrix in-place. |
InverseTransposed()[const] | Returns the inverse transpose of this matrix. |
Trace()[const] | Returns the sum of the diagonal elements of this matrix. |
Orthogonalize3(...) (+1 overload) | Orthogonalizes the basis formed by the column vectors of the 3x3 top-left submatrix of this matrix. |
Orthonormalize3(...) (+1 overload) | Orthonormalizes the basis formed by the column vectors of the 3x3 top-left submatrix of this matrix. |
RemoveScale() | Removes the scaling performed by this matrix. |
Pivot() | Reduces this matrix to its row-echelon form. |
TransformPos(pointVector)[const] (+2 overloads) | Transforms the given point vector by this matrix M , i.e. returns M * (x, y, z, 1). |
TransformDir(directionVector)[const] (+2 overloads) | Transforms the given direction vector by this matrix M , i.e. returns M * (x, y, z, 0). |
Transform(vector)[const] | Transforms the given 4-vector by this matrix M, i.e. |
TransformPos(...)[const] (+1 overload) | Performs a batch transform of the given array of point vectors. |
TransformDir(...)[const] (+1 overload) | Performs a batch transform of the given array of direction vectors. |
Transform(...)[const] (+1 overload) | Performs a batch transform of the given float4 array. |
operator*(rhs)[const] (+5 overloads) | Treats the float3x3 as a 4-by-4 matrix with the last row and column as identity, and multiplies the two matrices. |
operator/(scalar)[const] | |
operator+(rhs)[const] | |
operator-(rhs)[const] (+1 overload) | |
operator+()[const] | Unary operator + allows this structure to be used in an expression '+x'. |
operator*=(scalar) | |
operator/=(scalar) | |
operator+=(rhs) | |
operator-=(rhs) | |
IsFinite()[const] | Tests if this matrix does not contain any NaNs or infs. |
IsIdentity(epsilon)[const] | Tests if this is the identity matrix. |
IsLowerTriangular(epsilon)[const] | Tests if this matrix is in lower triangular form. |
IsUpperTriangular(epsilon)[const] | Tests if this matrix is in upper triangular form. |
IsInvertible(epsilon)[const] | Tests if this matrix has an inverse. |
IsSymmetric(epsilon)[const] | Tests if this matrix is symmetric (M == M^T). |
IsSkewSymmetric(epsilon)[const] | Tests if this matrix is skew-symmetric (M == -M^T). |
IsIdempotent(epsilon)[const] | Tests if this matrix is an idempotent matrix. |
HasUnitaryScale(epsilon)[const] | Returns true if this matrix does not perform any scaling. |
HasNegativeScale()[const] | Returns true if this matrix performs a reflection along some plane. |
HasUniformScale(epsilon)[const] | Returns true if this matrix contains only uniform scaling, compared to the given epsilon. |
IsRowOrthogonal3(epsilon)[const] | Returns true if the row vectors of 3x3 top-left submatrix are all perpendicular to each other. |
IsColOrthogonal3(epsilon)[const] | Returns true if the column vectors of 3x3 top-left submatrix are all perpendicular to each other. |
IsOrthonormal3(epsilon)[const] | Returns true if the column and row vectors of the 3x3 top-left submatrix form an orthonormal set. |
Equals(other,epsilon)[const] | Returns true if this float4x4 is equal to the given float4x4, up to given per-element epsilon. |
ContainsProjection(epsilon)[const] | Returns true if this matrix is seen to contain a "projective" part, i.e. |
ToString()[const] | Returns a string representation of form "(m00, m01, m02, m03; m10, m11, m12, m13; ... )". |
SerializeToString()[const] | |
ToString2()[const] | |
ToEuler***()[const] | Extracts the rotation part of this matrix into Euler rotation angles (in radians). |
ExtractScale()[const] | Returns the scale components of this matrix. |
Decompose(...)[const] (+3 overloads) | Decomposes this matrix to translate, rotate and scale parts. |
Abs()[const] | Computes a new matrix with each element of this matrix replaced with their absolute value. |
Mul(rhs)[const] (+3 overloads) | |
MulPos(pointVector)[const] (+1 overload) | |
MulDir(directionVector)[const] (+1 overload) | |
Mul(vector)[const] | |
Translate(tx,ty,tz)[static] (+1 overload) | Creates a new transformation matrix that translates by the given offset. |
RotateX/Y/Z(...)[static] (+1 overload) | Creates a new float4x4 that rotates about one of the principal axes. |
RotateAxisAngle(...)[static] (+1 overload) | Creates a new float4x4 that rotates about the given axis. |
RotateFromTo(...)[static] (+1 overload) | Creates a new float4x4 that rotates sourceDirection vector to coincide with the targetDirection vector. |
RandomGeneral(...)[static] | Returns a random 4x4 matrix with each entry randomized between the range [minElem, maxElem]. |
RotateFromTo(...)[static] (+1 overload) | Creates a new float4x4 that rotates one coordinate system to coincide with another. |
FromQuat(orientation)[static] (+1 overload) | Creates a new float4x4 that performs the rotation expressed by the given quaternion. |
FromTRS(...)[static] (+3 overloads) | Creates a new float4x4 as a combination of translation, rotation and scale. |
FromEuler***(x2,y,x)[static] | Creates a new float4x4 from the given sequence of Euler rotation angles (in radians). |
Scale(sx,sy,sz)[static] (+2 overloads) | Creates a new transformation matrix that scales by the given factors. |
ScaleAlongAxis(...)[static] (+1 overload) | Creates a new float4x4 that scales points along the given axis. |
UniformScale(uniformScale)[static] (+1 overload) | Creates a new float4x4 that performs uniform scaling by the given amount. |
ShearX/Y/Z(yFactor,zFactor)[static] | Produces a matrix that shears along a principal axis. |
Mirror(p)[static] | Creates a new matrix that mirrors with respect to the given plane. |
D3DOrthoProjLH(...)[static] | Identical to D3DXMatrixOrthoLH, except transposed to account for Matrix * vector convention used in MathGeoLib. |
D3DOrthoProjRH(...)[static] | Identical to D3DXMatrixOrthoRH, except transposed to account for Matrix * vector convention used in MathGeoLib. |
D3DPerspProjLH(...)[static] | Identical to D3DXMatrixPerspectiveLH, except transposed to account for Matrix * vector convention used in MathGeoLib. |
D3DPerspProjRH(...)[static] | Identical to D3DXMatrixPerspectiveRH, except transposed to account for Matrix * vector convention used in MathGeoLib. |
OpenGLOrthoProjLH(...)[static] | Computes a left-handled orthographic projection matrix for OpenGL. |
OpenGLOrthoProjRH(...)[static] | Computes a right-handled orthographic projection matrix for OpenGL. |
OpenGLPerspProjLH(...)[static] | Computes a left-handed perspective projection matrix for OpenGL. |
OpenGLPerspProjRH(...)[static] | Identical to http://www.opengl.org/sdk/docs/man/xhtml/gluPerspective.xml , except uses viewport sizes instead of FOV to set up the projection matrix. |
OrthographicProjection/YZ/XZ/XY(target)[static] | Creates a new float4x4 that performs orthographic projection. |
LookAt(...)[static] (+1 overload) | Creates a LookAt matrix from a look-at direction vector. |