![]() |
Trax3 3.1.0
trax track library
|
Homogenous transformation matrix. More...
#include <C:/Trend/Development/Trax3/Code/spat/Matrix.h>

Public Types | |
| using | Basetype = typename SquareMatrix<Valtype,4>::Basetype |
| Public Types inherited from spat::SquareMatrix< Valtype, 4 > | |
| using | Basetype |
| Utmost base type of this SquareMatrix. | |
| Public Types inherited from spat::Matrix< Valtype, nColsAndRows, nColsAndRows > | |
| typedef Valtype | value_type |
Public Member Functions | |||||||||
| template<typename Valtype2> | |||||||||
| Transformation< Valtype > & | operator= (const Rotation< Valtype2 > &rot) noexcept | ||||||||
| template<typename Valtype2, typename ValtypeT2> | |||||||||
| Transformation< Valtype > & | operator= (const Frame< Valtype2, ValtypeT2 > &frame) noexcept | ||||||||
Construction | |||||||||
| |||||||||
| Transformation (const SquareMatrix< Valtype, 4 > &matrix) | |||||||||
| Transformation (SquareMatrix< Valtype, 4 > &&matrix) noexcept | |||||||||
| Transformation (const Basetype &matrix) | |||||||||
| Transformation (Basetype &&matrix) noexcept | |||||||||
| template<typename Valtype2> | |||||||||
| Transformation (const Rotation< Valtype2 > &rot) | |||||||||
| template<typename Valtype2, typename ValtypeT2> | |||||||||
| Transformation (const Frame< Valtype2, ValtypeT2 > &frame) | |||||||||
| Transformation (const std::initializer_list< Valtype > &elements) | |||||||||
Assignment | |||||||||
| |||||||||
| template<typename Valtype2> | |||||||||
| Transformation & | operator= (const Rotation< Valtype2 > &rot) noexcept | ||||||||
| template<typename Valtype2, typename ValtypeT2> | |||||||||
| Transformation & | operator= (const Frame< Valtype2, ValtypeT2 > &frame) noexcept | ||||||||
Transformation | |||||||||
| template<typename Valtype2> | |||||||||
| PositionH< Valtype2 > | operator* (const PositionH< Valtype2 > &p) const noexcept | ||||||||
| template<typename Valtype2> | |||||||||
| Position< Valtype2 > | operator* (const Position< Valtype2 > &pos) const noexcept | ||||||||
| template<typename Valtype2> | |||||||||
| Vector< Valtype2 > | operator* (const Vector< Valtype2 > &vec) const noexcept | ||||||||
CreateTranslation | |||||||||
Creates a matrix that has the effect of a translation.
| |||||||||
| void | CreateTranslation (const Vector< Valtype > &translation) noexcept | ||||||||
| void | CreateTranslation (Valtype tx, Valtype ty, Valtype tz) noexcept | ||||||||
CreateRotation | |||||||||
Creates a matrix that has the effect of a rotation.
| |||||||||
| void | CreateRotation (const Vector< Valtype > &rotation) | ||||||||
| void | CreateRotation (Valtype rx, Valtype ry, Valtype rz) | ||||||||
CreateScaling | |||||||||
Creates a matrix that has the effect of a scaling.
| |||||||||
| void | CreateScaling (const Vector< Valtype > &scaling) noexcept | ||||||||
| void | CreateScaling (Valtype sx, Valtype sy, Valtype sz) noexcept | ||||||||
CreateMirror | |||||||||
Creates a matrix that has the effect of mirroring on a plane, described by mirror. | |||||||||
| template<typename Valtype2> | |||||||||
| void | CreateMirror (const VectorBundle< Valtype2, Valtype > &mirror) | ||||||||
| Create a view matrix that transforms to camera space. | |||||||||
| void | LookAt (const Position< Valtype > &at, const Position< Valtype > &eye, const Vector< Valtype > &up) noexcept | ||||||||
| Create a view matrix that transforms to camera space. | |||||||||
| void | CreateViewport (Valtype Width, Valtype Height, Valtype MinZ, Valtype MaxZ, Valtype LeftMargin=0.0f, Valtype TopMargin=0.0f) noexcept | ||||||||
| Creates a viewport projection. | |||||||||
| bool | CreateCameraProjection (Valtype fovy, Valtype Aspect, Valtype zn, Valtype zf) noexcept | ||||||||
| Creates camera projection transformation. | |||||||||
| bool | CreateOrthographicProjection (Valtype width, Valtype height, Valtype znear, Valtype zfar) noexcept | ||||||||
| Creates orthographic projection transformation. | |||||||||
| Vector< Valtype > | TransformVector (const Vector< Valtype > &vec) const noexcept | ||||||||
| Vector transformation. Use it for difference vectors between positions or dynamic vectors like velocities and accellerations. | |||||||||
| void | GetTranslation (Transformation &T) const noexcept | ||||||||
| Kovariant vector use this for face normals or vectors denoting a rotation orientation. | |||||||||
| bool | GeRotation (Transformation &R) const noexcept | ||||||||
| Calculates a rotational part of the transformation so that T * R * S == *this. | |||||||||
| bool | GetScaling (Transformation &S) const noexcept | ||||||||
| Calculates a scaling part of the transformation so that T * R * S == *this. | |||||||||
| bool | Dismantle (Transformation &T, Transformation &R, Transformation &S) const noexcept | ||||||||
| Calculates translational, rotational and scaling part of the transformation so that T * R * S == *this. | |||||||||
| bool | IsValid () const noexcept | ||||||||
| Tests wether the matrix is a valid homogenous transformation. | |||||||||
| Public Member Functions inherited from spat::SquareMatrix< Valtype, 4 > | |||||||||
| Matrix & | operator= (const Matrix &matrix) noexcept | ||||||||
| Matrix & | operator= (Matrix &&matrix) noexcept | ||||||||
| Matrix & | operator= (const std::initializer_list< Valtype > &elements) noexcept | ||||||||
| const Valtype & | operator() (unsigned short col, unsigned short row) const noexcept | ||||||||
| Valtype & | operator() (unsigned short col, unsigned short row) noexcept | ||||||||
| void | SetIdentity () noexcept | ||||||||
| Sets the matrix to the identity matrix (i.e. all 1 in diagonal, 0 for everything else). | |||||||||
| bool | IsIdentity (Valtype epsilon=0) const noexcept | ||||||||
| bool | IsDiagonal () const noexcept | ||||||||
| bool | IsSymmetric (Valtype epsilon=0) const noexcept | ||||||||
| SquareMatrix & | Transpose () noexcept | ||||||||
| Change colums and rows. | |||||||||
| SquareMatrix & | Invert () | ||||||||
| Invert matrix so that M*I == Identity. | |||||||||
| Valtype | Trace () const noexcept | ||||||||
| Trace of the matrix, wich is the sum of all element with same indices. | |||||||||
| Public Member Functions inherited from spat::Matrix< Valtype, nColsAndRows, nColsAndRows > | |||||||||
| void | SetNull () noexcept | ||||||||
| Sets all elements to 0. | |||||||||
| constexpr unsigned short | Cols () const noexcept | ||||||||
| Number of columns. | |||||||||
| constexpr unsigned short | Rows () const noexcept | ||||||||
| Number of rows. | |||||||||
| bool | IsEqual (const Matrix &matrix, Valtype delta=0) const noexcept | ||||||||
| Test elements for equality up to delta distance. | |||||||||
| bool | operator== (const Matrix &matrix) const noexcept | ||||||||
| Comparison for equality. | |||||||||
| bool | operator!= (const Matrix &matrix) const noexcept | ||||||||
| Comparison for inequality. | |||||||||
| void | operator*= (Valtype skalar) noexcept | ||||||||
| Matrix * Skalar multiplication. | |||||||||
| void | operator*= (const Matrix< Valtype, nCols, nCols > &matrix) | ||||||||
| Matrix multiplication. | |||||||||
| void | operator/= (Valtype skalar) noexcept | ||||||||
| Matrix / Skalar division. | |||||||||
| void | operator+= (const Matrix &matrix) noexcept | ||||||||
| Matrix addition. | |||||||||
| void | operator-= (const Matrix &matrix) noexcept | ||||||||
| Matrix subtraction. | |||||||||
| const Valtype * | ptr () const noexcept | ||||||||
| Pointer accessor for direct copying. The memory layout is column-major order. | |||||||||
| Matrix< Valtype, nCols-1, nRows-1 > | SubMatrix (unsigned short c, unsigned short r) const | ||||||||
| Extracts the submatrix of mat wich results from omitting the row r and collumn c. | |||||||||
| Matrix (const Matrix &matrix) | |||||||||
| Matrix (Matrix &&matrix) noexcept | |||||||||
| Matrix (const std::initializer_list< Valtype > &elements) | |||||||||
| Matrix & | operator= (const Matrix &matrix) noexcept | ||||||||
| Matrix & | operator= (Matrix &&matrix) noexcept | ||||||||
| Matrix & | operator= (const std::initializer_list< Valtype > &elements) noexcept | ||||||||
| const Valtype & | operator() (unsigned short col, unsigned short row) const noexcept | ||||||||
| Valtype & | operator() (unsigned short col, unsigned short row) noexcept | ||||||||
Homogenous transformation matrix.
|
noexcept |
Creates camera projection transformation.
| fovy | Field of view angle. |
| Aspect | Width to height aspect of opening angles. |
| zn | Distance to the near plane of the camera frustum. |
| zf | Distance to the far plane of the camera frustum. |
|
noexcept |
Kovariant vector use this for face normals or vectors denoting a rotation orientation.
Calculates a translational part of the transformation so that T * R * S == *this.
|
noexcept |
Vector transformation. Use it for difference vectors between positions or dynamic vectors like velocities and accellerations.
If you want to transform normal vectors be aware that due to the nature of this kind of vector beeing orthogonal to a plane you have to use the inverse transposed matrix.
M: Transformation matrix for coordinates. Q: Transformation matrix for normals. D = P2 - P1: Vector between two arbitrary points in a plane. D' = P2' - P1' = M * P2 - M * P1 = M * D: Transformed vector D. N: Normal on that plane.
Now its N*D = 0 for all D since N is orthogonal to the plane. But with the transformed vectors the same condition must hold: N'*D' = 0. -> Q*N*M*D = 0 -> N*Qt*M*D = 0 (Qt is the transposed of Q) since this must hold for all D (or lets put it the other way: to be on the safe side) Qt*M = IdentityMatrix must hold. hence Q = Transposed(Inverse(M)) = Inverse(Transposed(M))