![]() |
TGX 1.0.7
A tiny 2D/3D graphics library optimized for 32 bits microcontrollers.
|
Generic 4x4 matrix [specializations fMat4, dMat4]. More...
#include <Mat4.h>
Public Member Functions | |
| Mat4 () | |
| Default constructor. More... | |
| constexpr | Mat4 (T x1, T y1, T z1, T t1, T x2, T y2, T z2, T t2, T x3, T y3, T z3, T t3, T x4, T y4, T z4, T t4) |
| Constructor from explicit values. | |
| Mat4 (const T *mat) | |
Constructor from an array (with column major ordering same as M). | |
| Mat4 (const Mat4 &mat)=default | |
| Copy constructor. | |
| Mat4 & | operator= (const Mat4 &mat)=default |
| Assignement operator. | |
| operator T* () | |
| Implicit conversion to an array T[16]. | |
| void | setZero () |
| Set as the null matrix (all coefficients equal 0). | |
| void | setIdentity () |
| Set as the identity matrix. | |
| void | setOrtho (T left, T right, T bottom, T top, T zNear, T zFar) |
| Set as an orthographic projection matrix. More... | |
| void | setFrustum (T left, T right, T bottom, T top, T zNear, T zFar) |
| Set as a perspective projection matrix. More... | |
| void | setPerspective (T fovy, T aspect, T zNear, T zFar) |
| Set as a perspective projection matrix. More... | |
| void | setRotate (T angle, T x, T y, T z) |
| Set as a rotation matrix. More... | |
| void | setRotate (T angle, const Vec3< T > v) |
| Set as a rotation matrix. More... | |
| void | multRotate (T angle, T x, T y, T z) |
| Pre-multiply this matrix by a rotation matrix. More... | |
| void | multRotate (T angle, const Vec3< T > v) |
| Pre-multiply this matrix by a rotation matrix. More... | |
| void | setTranslate (T x, T y, T z) |
| Set as a translation matrix. More... | |
| void | setTranslate (const Vec3< T > v) |
| Set as a translation matrix. More... | |
| void | multTranslate (T x, T y, T z) |
| Pre-multiply this matrix by a translation matrix. More... | |
| void | multTranslate (const Vec3< T > v) |
| Pre-multiply this matrix by a translation matrix. More... | |
| void | setScale (T x, T y, T z) |
| Set as a dilatation matrix. More... | |
| void | setScale (const Vec3< T > v) |
| Set as a dilatation matrix. More... | |
| void | multScale (T x, T y, T z) |
| Pre-multiply this matrix by a dilatation matrix. More... | |
| void | multScale (const Vec3< T > v) |
| Pre-multiply this matrix by a dilatation matrix. More... | |
| void | invertYaxis () |
| invert the y axis, same as multScale({1,-1,1}) | |
| void | setLookAt (T eyeX, T eyeY, T eyeZ, T centerX, T centerY, T centerZ, T upX, T upY, T upZ) |
| Set the matrix for a camera looking at a given direction. More... | |
| void | setLookAt (const Vec3< T > eye, const Vec3< T > center, const Vec3< T > up) |
| Set the matrix for a camera looking at a given direction. More... | |
| TGX_INLINE Vec4< T > | mult (const Vec4< T > V) const |
| Matrix-vector multiplication. | |
| TGX_INLINE Vec4< T > | mult (const Vec3< T > &V, float w) const |
| Matrix-vector multiplication. | |
| TGX_INLINE Vec4< T > | mult0 (const Vec3< T > &V) const |
| Matrix-vector multiplication (last component of vector set to w = 0). | |
| TGX_INLINE Vec4< T > | mult1 (const Vec3< T > &V) const |
| Matrix-vector multiplication (last component of vector set to w = 1) | |
| void | operator*= (T a) |
| Scalar multiplication. | |
| void | transpose () |
| Transpose the matrix (in place) | |
Public Attributes | |
| T | M [16] |
| The matrix array in column major ordering: More... | |
Generic 4x4 matrix [specializations fMat4, dMat4].
The class encapsulate a 4x4 matrix with element of type T which must be a floating point type (either float or double). Such a matrix is used in 3D grpahics to represent a transformation (translation, rotation, dilatation...).
The matrix is internally represented by an public array M[16] in column major ordering:
|
inline |
Default constructor.
the matrix content is undefined.
|
inline |
Set as an orthographic projection matrix.
https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glOrtho.xml
| left,right | coordinates for the left and right vertical clipping planes |
| bottom,top | coordinates for the bottom and top horizontal clipping planes. |
| zNear,zFar | distances to the nearer and farther depth clipping planes. |
|
inline |
Set as a perspective projection matrix.
https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glFrustum.xml
| left,right | coordinates for the left and right vertical clipping planes |
| bottom,top | coordinates for the bottom and top horizontal clipping planes. |
| zNear,zFar | distances to the nearer and farther depth clipping planes. |
|
inline |
Set as a perspective projection matrix.
https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluPerspective.xml
| fovy | field of view angle, in degrees, in the y direction. |
| aspect | aspect ratio that determines the field of view in the x direction. The aspect ratio is the ratio of x (width) to y (height). |
| zNear | distance from the viewer to the near clipping plane. |
| zFar | distance from the viewer to the far clipping plane. |
|
inline |
Set as a rotation matrix.
https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glRotate.xml
| angle | rotation angle in degrees. |
| x,y,z | coordinates of the direction vector for the rotation. |
Set as a rotation matrix.
https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glRotate.xml
| angle | rotation angle in degrees. |
| v | direction vector for the rotation. |
|
inline |
Pre-multiply this matrix by a rotation matrix.
https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glRotate.xml
| angle | rotation angle in degrees. |
| x,y,z | coordinates of the direction vector for the rotation. |
Pre-multiply this matrix by a rotation matrix.
https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glRotate.xml
| angle | rotation angle in degrees. |
| v | direction vector for the rotation. |
|
inline |
Set as a translation matrix.
https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glTranslate.xml
| x,y,z | coordinates of the translation vector. |
Set as a translation matrix.
https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glTranslate.xml
| v | the translation vector. |
|
inline |
Pre-multiply this matrix by a translation matrix.
https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glTranslate.xml
| x,y,z | coordinates of the translation vector. |
Pre-multiply this matrix by a translation matrix.
https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glTranslate.xml
| v | the translation vector. |
|
inline |
Set as a dilatation matrix.
https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glScale.xml
| x,y,z | scale factors along the x, y, and z axes respectively. |
Set as a dilatation matrix.
https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glScale.xml
| v | vector representing the scale factors along each axis. |
|
inline |
Pre-multiply this matrix by a dilatation matrix.
https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glScale.xml
| x,y,z | scale factors along the x, y, and z axes respectively. |
Pre-multiply this matrix by a dilatation matrix.
https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glScale.xml
| v | vector representing the scale factors along each axis. |
|
inline |
Set the matrix for a camera looking at a given direction.
https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluLookAt.xml
The formula given by khronos is wrong ! The cross-product of two unit vectors is not normalized.
See https://stackoverflow.com/questions/30409318/lookat-matrix-distorts-when-looking-up-or-down
| eyeX,eyeY,eyeZ | position of the eye point. |
| centerX,centerY,centerZ | position of the reference point (the camera points toward this point). |
| upX,upY,upZ | direction of the up vector. |
|
inline |
Set the matrix for a camera looking at a given direction.
https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/gluLookAt.xml
The formula given by khronos is wrong ! The cross-product of two unit vectors is not normalized.
See https://stackoverflow.com/questions/30409318/lookat-matrix-distorts-when-looking-up-or-down
| eye | eye position. |
| center | reference point (the camera points toward this point). |
| up | up vector. |
| T tgx::Mat4< T >::M[16] |
The matrix array in column major ordering: