This class represents a generic 4x4 matrix. More...
#include "Matrix.hpp"
Public Member Functions | |
Matrix4x4T () | |
The default constructor for creating a "1" (identity) matrix. More... | |
Matrix4x4T (const float M[4][4]) | |
Constructor for creating an arbitrary matrix. More... | |
Matrix4x4T (const double M[4][4]) | |
Constructor for creating an arbitrary matrix. More... | |
Matrix4x4T (T m00, T m01, T m02, T m03, T m10, T m11, T m12, T m13, T m20, T m21, T m22, T m23, T m30, T m31, T m32, T m33) | |
Constructor for creating an arbitrary matrix. More... | |
Matrix4x4T (const Vector3T< T > &t, const cf::math::QuaternionT< T > &q, const Vector3T< T > &s=Vector3T< T >(1, 1, 1)) | |
Constructor for creating a matrix from a translation, a quaternion, and an optional scale. More... | |
T * | operator[] (unsigned int i) |
Returns the i-th row of this matrix. More... | |
const T * | operator[] (unsigned int i) const |
Returns the i-th row of this matrix. More... | |
Matrix4x4T | operator* (const Matrix4x4T &Other) const |
Computes M*Other, that is, the matrix product of this and the Other matrix. More... | |
void | Translate_MT (const Vector3dT &Trans) |
Computes M=M*T, where T=GetTranslationMatrix(Trans). Assumes that the last row is (0 0 0 1). More... | |
void | Translate_MT (T tx, T ty, T tz) |
Computes M=M*T, where T=GetTranslationMatrix(Trans). Assumes that the last row is (0 0 0 1). More... | |
void | Translate_TM (const Vector3dT &Trans) |
Computes M=T*M, where T=GetTranslationMatrix(Trans). Assumes that the last row is (0 0 0 1). More... | |
void | Scale_MS (T sx, T sy, T sz) |
Computes M=M*S, where S=GetScaleMatrix (sx, sy, sz). More... | |
void | Scale_SM (T sx, T sy, T sz) |
Computes M=S*M, where S=GetScaleMatrix (sx, sy, sz). More... | |
void | RotateX_MR (T Angle) |
Computes M=M*R, where R=GetRotateXMatrix (Angle). More... | |
void | RotateX_RM (T Angle) |
Computes M=R*M, where R=GetRotateXMatrix (Angle). More... | |
void | RotateY_MR (T Angle) |
Computes M=M*R, where R=GetRotateYMatrix (Angle). More... | |
void | RotateY_RM (T Angle) |
Computes M=R*M, where R=GetRotateYMatrix (Angle). More... | |
void | RotateZ_MR (T Angle) |
Computes M=M*R, where R=GetRotateZMatrix (Angle). More... | |
void | RotateZ_RM (T Angle) |
Computes M=R*M, where R=GetRotateZMatrix (Angle). More... | |
Vector3dT | Mul0 (const Vector3dT &v) const |
Computes M*v, where M is this matrix. More... | |
Vector3fT | Mul0 (const Vector3fT &v) const |
Vector3dT | Mul1 (const Vector3dT &v) const |
Computes M*v, where M is this matrix. More... | |
Vector3fT | Mul1 (const Vector3fT &v) const |
Vector3T< T > | Mul_xyz1 (const Vector3T< T > &v) const |
Computes M*v, where M is this matrix. More... | |
void | Mul_xyz1 (const T v[3], T out[3]) const |
Computes M*v, where M is this matrix. More... | |
Vector3T< T > | ProjectPoint (const Vector3T< T > &v) const |
Computes M*v, where M is this matrix. More... | |
void | Mul (const T v[4], T out[4]) const |
Computes M*v, where M is this matrix. More... | |
bool | IsEqual (const Matrix4x4T &Other, const T Epsilon=0) const |
Returns whether this matrix is equal to Other. More... | |
Vector3T< T > | InvXForm (Vector3T< T > v) const |
If this matrix represents a rigid transformation (rotation and translation only, no scale, shear, etc.), this is a faster shortcut for GetInverse().Mul1(v). More... | |
Matrix4x4T | GetInverse (bool *Result=NULL) const |
Computes the inverse of this matrix. More... | |
Matrix4x4T | GetTranspose () const |
Returns the transpose of this matrix. More... | |
Public Attributes | |
T | m [4][4] |
The matrix values. More... | |
Named constructors | |
static Matrix4x4T | GetProjOrthoMatrix (T left, T right, T bottom, T top, T zNear, T zFar) |
Returns a matrix for orthographic projection. More... | |
static Matrix4x4T | GetProjFrustumMatrix (T left, T right, T bottom, T top, T zNear, T zFar) |
Returns a matrix for perspective projection. If zFar <= zNear, the far plane is assumed to be at infinity (a useful special case for stencil shadow projections). More... | |
static Matrix4x4T | GetProjPerspectiveMatrix (T fovY, T aspect, T zNear, T zFar) |
Returns a matrix for perspective projection. If zFar <= zNear, the far plane is assumed to be at infinity (a useful special case for stencil shadow projections). More... | |
static Matrix4x4T | GetProjPickMatrix (T x, T y, T width, T height, int viewport[4]) |
Returns a matrix for picking, i.e. the same matrix that gluPickMatrix() uses. More... | |
static Matrix4x4T | GetTranslateMatrix (const Vector3T< T > &t) |
Returns a translate matrix about t. More... | |
static Matrix4x4T | GetScaleMatrix (T sx, T sy, T sz) |
Returns a scale matrix with scale factors (sx sy sz). More... | |
static Matrix4x4T | GetRotateXMatrix (T Angle) |
Returns a rotation matrix about Angle degrees around the x-axis. More... | |
static Matrix4x4T | GetRotateYMatrix (T Angle) |
Returns a rotation matrix about Angle degrees around the y-axis. More... | |
static Matrix4x4T | GetRotateZMatrix (T Angle) |
Returns a rotation matrix about Angle degrees around the z-axis. More... | |
static Matrix4x4T | GetRotateMatrix (T Angle, const Vector3T< T > &Axis) |
Returns a rotation matrix about Angle degrees around Axis. More... | |
This class represents a generic 4x4 matrix.
It has special helper methods for affine geometric transformations in 3D, but can be used for general purposes. Contrary to earlier test versions, it stores the fourth row explicitly, so that easy compatibility with OpenGL matrices is given and no problems occur with general-case use (e.g. as projection matrix etc.).
|
inline |
The default constructor for creating a "1" (identity) matrix.
|
inline |
Constructor for creating an arbitrary matrix.
|
inline |
Constructor for creating an arbitrary matrix.
|
inline |
Constructor for creating an arbitrary matrix.
Matrix4x4T< T >::Matrix4x4T | ( | const Vector3T< T > & | t, |
const cf::math::QuaternionT< T > & | q, | ||
const Vector3T< T > & | s = Vector3T<T>(1, 1, 1) |
||
) |
Constructor for creating a matrix from a translation, a quaternion, and an optional scale.
The resulting matrix is equal to the matrix product T*R*S of three matrices T, R and S, where T is the translation matrix that corresponds to the given translation vector t
, R is the rotation matrix that is constructed from the given quaternion q
, and S is the scale matrix that corresponds to the given scale s
.
The resulting matrix is of the form:
t | The translation that is expressed in the matrix. |
q | The quaternion that describes the rotation that is expressed in the matrix. |
s | The scale that is expressed in the matrix. |
Matrix4x4T< T > Matrix4x4T< T >::GetInverse | ( | bool * | Result = NULL | ) | const |
Computes the inverse of this matrix.
Result | Whether the inversion was successful. |
|
static |
Returns a matrix for perspective projection. If zFar <= zNear, the far plane is assumed to be at infinity (a useful special case for stencil shadow projections).
|
static |
Returns a matrix for orthographic projection.
|
static |
Returns a matrix for perspective projection. If zFar <= zNear, the far plane is assumed to be at infinity (a useful special case for stencil shadow projections).
|
static |
Returns a matrix for picking, i.e. the same matrix that gluPickMatrix() uses.
|
static |
Returns a rotation matrix about Angle degrees around Axis.
|
static |
Returns a rotation matrix about Angle degrees around the x-axis.
|
static |
Returns a rotation matrix about Angle degrees around the y-axis.
|
static |
Returns a rotation matrix about Angle degrees around the z-axis.
|
static |
Returns a scale matrix with scale factors (sx sy sz).
|
static |
Returns a translate matrix about t.
Matrix4x4T< T > Matrix4x4T< T >::GetTranspose | ( | ) | const |
Returns the transpose of this matrix.
|
inline |
If this matrix represents a rigid transformation (rotation and translation only, no scale, shear, etc.), this is a faster shortcut for GetInverse().Mul1(v).
It employs the transpose of the rotational part for inverting the rotation, and properly accounts for the translation.
v | DOCTODO |
|
inline |
Returns whether this matrix is equal to Other.
The matrices are considered equal if the element-wise comparison yields no difference larger than Epsilon.
Other | Matrix to compare to. |
Epsilon | Tolerance value. |
|
inline |
Computes M*v, where M is this matrix.
v | The four-component vector that is multiplied with M. |
out | The four-component result vector. |
|
inline |
Computes M*v, where M is this matrix.
The w-component of v is assumed to be 0 (v being a direction vector, not a point). The last row of M is assumed to be (0 0 0 1). That means that only the rotation (and scale) of M is applied to v.
v | A direction vector. |
|
inline |
v | A direction vector. |
|
inline |
Computes M*v, where M is this matrix.
The w-component of v is assumed to be 1 (v being a point, not a direction vector). The last row of M is assumed to be (0 0 0 1). That means that both the rotation (and scale) and the translation of M is applied to v.
v | A point. |
|
inline |
v | A point. |
|
inline |
Computes M*v, where M is this matrix.
The w-component of v is assumed to be 1 (v being a point, not a direction vector). The last row of M is assumed to be (0 0 0 1). That means that both the rotation (and scale) and the translation of M is applied to v.
v | A point. |
|
inline |
Computes M*v, where M is this matrix.
The w-component of v is assumed to be 1 (v being a point, not a direction vector). The last row of M is assumed to be (0 0 0 1). That means that both the rotation (and scale) and the translation of M is applied to v.
v | A point. |
out | The result of M*v. |
Matrix4x4T< T > Matrix4x4T< T >::operator* | ( | const Matrix4x4T< T > & | Other | ) | const |
Computes M*Other, that is, the matrix product of this and the Other matrix.
Other | The other matrix (right side). |
|
inline |
Returns the i-th row of this matrix.
|
inline |
Returns the i-th row of this matrix.
|
inline |
Computes M*v, where M is this matrix.
The w-component of v is assumed to be 1 (v being a point, not a direction vector). The resulting 4-tuple is divided by the w-component so that only the xyz components must be returned.
v | A point. |
void Matrix4x4T< T >::RotateX_MR | ( | T | Angle | ) |
Computes M=M*R, where R=GetRotateXMatrix (Angle).
void Matrix4x4T< T >::RotateX_RM | ( | T | Angle | ) |
Computes M=R*M, where R=GetRotateXMatrix (Angle).
void Matrix4x4T< T >::RotateY_MR | ( | T | Angle | ) |
Computes M=M*R, where R=GetRotateYMatrix (Angle).
void Matrix4x4T< T >::RotateY_RM | ( | T | Angle | ) |
Computes M=R*M, where R=GetRotateYMatrix (Angle).
void Matrix4x4T< T >::RotateZ_MR | ( | T | Angle | ) |
Computes M=M*R, where R=GetRotateZMatrix (Angle).
void Matrix4x4T< T >::RotateZ_RM | ( | T | Angle | ) |
Computes M=R*M, where R=GetRotateZMatrix (Angle).
void Matrix4x4T< T >::Scale_MS | ( | T | sx, |
T | sy, | ||
T | sz | ||
) |
Computes M=M*S, where S=GetScaleMatrix (sx, sy, sz).
void Matrix4x4T< T >::Scale_SM | ( | T | sx, |
T | sy, | ||
T | sz | ||
) |
Computes M=S*M, where S=GetScaleMatrix (sx, sy, sz).
void Matrix4x4T< T >::Translate_MT | ( | const Vector3dT & | Trans | ) |
Computes M=M*T, where T=GetTranslationMatrix(Trans). Assumes that the last row is (0 0 0 1).
void Matrix4x4T< T >::Translate_MT | ( | T | tx, |
T | ty, | ||
T | tz | ||
) |
Computes M=M*T, where T=GetTranslationMatrix(Trans). Assumes that the last row is (0 0 0 1).
void Matrix4x4T< T >::Translate_TM | ( | const Vector3dT & | Trans | ) |
Computes M=T*M, where T=GetTranslationMatrix(Trans). Assumes that the last row is (0 0 0 1).
T Matrix4x4T< T >::m[4][4] |
The matrix values.