Class for matrix 4x4. More...
#include <vmath.h>
Public Member Functions | |
Matrix4 () | |
Creates identity matrix. | |
Matrix4 (const T *dt) | |
Copy matrix values from array (these data must be in column major order!). | |
Matrix4 (const Matrix4< T > &src) | |
Copy constructor. | |
template<class FromT > | |
Matrix4 (const Matrix4< FromT > &src) | |
Copy casting constructor. | |
void | identity () |
Resets matrix to be identity matrix. | |
bool | operator== (const Matrix4< T > &rhs) const |
Equality test operator. | |
bool | operator!= (const Matrix4< T > &rhs) const |
Inequality test operator. | |
T & | at (int x, int y) |
Get reference to element at postion (x,y). | |
const T & | at (int x, int y) const |
Get constant reference to element at position (x,y). | |
T & | operator() (int i, int j) |
Get reference to element at position (i,j), with math matrix notation. | |
const T & | operator() (int i, int j) const |
Get constant reference to element at position (i,j), with math matrix notation. | |
void | setTranslation (const Vector3< T > &v) |
Sets translation part of matrix. | |
Vector3< T > | getTranslation () |
void | setRotation (const Matrix3< T > &m) |
Sets rotation part (matrix 3x3) of matrix. | |
Matrix4< T > & | operator= (const Matrix4< T > &rhs) |
Copy operator. | |
template<class FromT > | |
Matrix4< T > & | operator= (const Matrix4< FromT > &rhs) |
Copy casting operator. | |
Matrix4< T > & | operator= (const T *rhs) |
Copy operator. | |
Matrix4< T > | operator+ (const Matrix4< T > &rhs) const |
Addition operator. | |
Matrix4< T > | operator- (const Matrix4< T > &rhs) const |
Subtraction operator. | |
Matrix4< T > | operator+ (T rhs) const |
Addition operator. | |
Matrix4< T > | operator- (T rhs) const |
Subtraction operator. | |
Matrix4< T > | operator* (T rhs) const |
Multiplication operator. | |
Matrix4< T > | operator/ (T rhs) const |
Division operator. | |
Vector4< T > | operator* (const Vector4< T > &rhs) const |
Multiplication operator. | |
Vector3< T > | operator* (const Vector3< T > &rhs) const |
Multiplication operator. | |
Matrix4< T > | operator* (Matrix4< T > rhs) const |
Multiplication operator. | |
T | det () |
Computes determinant of matrix. | |
Matrix4< T > | inverse () |
Computes inverse matrix. | |
Matrix4< T > | transpose () |
Transpose matrix. | |
Matrix4< T > | lerp (T fact, const Matrix4< T > &rhs) const |
Linear interpolation of two matrices. | |
operator T * () | |
Conversion to pointer operator. | |
operator const T * () const | |
Conversion to pointer operator. | |
std::string | toString () const |
Gets string representation. | |
Static Public Member Functions | |
static Matrix4< T > | createRotationAroundAxis (T xDeg, T yDeg, T zDeg) |
Creates rotation matrix by rotation around axis. | |
static Matrix4< T > | createTranslation (T x, T y, T z, T w=1) |
Creates translation matrix. | |
static Matrix4< T > | createFrustum (T left, T right, T bottom, T top, T zNear, T zFar) |
Creates OpenGL compatible perspective projection according specified frustum parameters. | |
static Matrix4< T > | createOrtho (T left, T right, T bottom, T top, T zNear, T zFar) |
Creates OpenGL compatible orthographic projection matrix. | |
template<class FromT > | |
static Matrix4< T > | fromRowMajorArray (const FromT *arr) |
Creates new matrix 4x4 from array that represents such matrix 4x4 as array of tightly packed elements in row major order. | |
template<class FromT > | |
static Matrix4< T > | fromColumnMajorArray (const FromT *arr) |
Creates new matrix 4x4 from array that represents such matrix 4x4 as array of tightly packed elements in column major order. | |
Public Attributes | |
T | data [16] |
Data stored in column major order. | |
Friends | |
std::ostream & | operator<< (std::ostream &lhs, const Matrix4< T > &rhs) |
Output to stream operator. |
Class for matrix 4x4.
Copy matrix values from array (these data must be in column major order!).
Copy constructor.
src | Data source for new created instance of Matrix4. |
Matrix4< T >::Matrix4 | ( | const Matrix4< FromT > & | src | ) | [inline] |
Copy casting constructor.
src | Data source for new created instance of Matrix4. |
T& Matrix4< T >::at | ( | int | x, | |
int | y | |||
) | [inline] |
Get reference to element at postion (x,y).
x | Number of column (0..3) | |
y | Number of row (0..3) |
const T& Matrix4< T >::at | ( | int | x, | |
int | y | |||
) | const [inline] |
Get constant reference to element at position (x,y).
x | Number of column (0..3) | |
y | Number of row (0..3) |
static Matrix4<T> Matrix4< T >::createFrustum | ( | T | left, | |
T | right, | |||
T | bottom, | |||
T | top, | |||
T | zNear, | |||
T | zFar | |||
) | [inline, static] |
Creates OpenGL compatible perspective projection according specified frustum parameters.
left | Specify the coordinate for the left vertical clipping plane, | |
right | Specify the coordinate for the right vertical clipping plane. | |
bottom | Specify the coordinate for the bottom horizontal clipping plane, | |
top | Specify the coordinate for the top horizontal clipping plane. | |
zNear | Specify the distance to the near clipping plane. Distance must be positive. | |
zFar | Specify the distance to the far depth clipping plane. Distance must be positive. |
static Matrix4<T> Matrix4< T >::createOrtho | ( | T | left, | |
T | right, | |||
T | bottom, | |||
T | top, | |||
T | zNear, | |||
T | zFar | |||
) | [inline, static] |
Creates OpenGL compatible orthographic projection matrix.
left | Specify the coordinate for the left vertical clipping plane, | |
right | Specify the coordinate for the right vertical clipping plane. | |
bottom | Specify the coordinate for the bottom horizontal clipping plane, | |
top | Specify the coordinate for the top horizontal clipping plane. | |
zNear | Specify the distance to the nearer depth clipping plane. This value is negative if the plane is to be behind the viewer, | |
zFar | Specify the distance to the farther depth clipping plane. This value is negative if the plane is to be behind the viewer. |
static Matrix4<T> Matrix4< T >::createRotationAroundAxis | ( | T | xDeg, | |
T | yDeg, | |||
T | zDeg | |||
) | [inline, static] |
Creates rotation matrix by rotation around axis.
xDeg | Angle (in degrees) of rotation around axis X. | |
yDeg | Angle (in degrees) of rotation around axis Y. | |
zDeg | Angle (in degrees) of rotation around axis Z. |
static Matrix4<T> Matrix4< T >::createTranslation | ( | T | x, | |
T | y, | |||
T | z, | |||
T | w = 1 | |||
) | [inline, static] |
Creates translation matrix.
Creates translation matrix.
x | X-direction translation | |
y | Y-direction translation | |
z | Z-direction translation | |
w | for W-coordinate translation (implicitly set to 1) |
T Matrix4< T >::det | ( | ) | [inline] |
Computes determinant of matrix.
static Matrix4<T> Matrix4< T >::fromColumnMajorArray | ( | const FromT * | arr | ) | [inline, static] |
Creates new matrix 4x4 from array that represents such matrix 4x4 as array of tightly packed elements in column major order.
arr | An array of elements for 4x4 matrix in column major order. |
static Matrix4<T> Matrix4< T >::fromRowMajorArray | ( | const FromT * | arr | ) | [inline, static] |
Creates new matrix 4x4 from array that represents such matrix 4x4 as array of tightly packed elements in row major order.
arr | An array of elements for 4x4 matrix in row major order. |
void Matrix4< T >::identity | ( | ) | [inline] |
Resets matrix to be identity matrix.
Computes inverse matrix.
Linear interpolation of two matrices.
fact | Factor of interpolation. For translation from positon of this matrix (lhs) to matrix rhs, values of factor goes from 0.0 to 1.0. | |
rhs | Second Matrix for interpolation |
Matrix4< T >::operator const T * | ( | ) | const [inline] |
Conversion to pointer operator.
Matrix4< T >::operator T * | ( | ) | [inline] |
Conversion to pointer operator.
Inequality test operator.
rhs | Right hand side argument of binary operator. |
T& Matrix4< T >::operator() | ( | int | i, | |
int | j | |||
) | [inline] |
Get reference to element at position (i,j), with math matrix notation.
i | Number of row (1..4) | |
j | Number of column (1..4) |
const T& Matrix4< T >::operator() | ( | int | i, | |
int | j | |||
) | const [inline] |
Get constant reference to element at position (i,j), with math matrix notation.
i | Number of row (1..4) | |
j | Number of column (1..4) |
Multiplication operator.
rhs | Right hand side argument of binary operator. |
Multiplication operator.
rhs | Right hand side argument of binary operator. |
Multiplication operator.
rhs | Right hand side argument of binary operator. |
Multiplication operator.
rhs | Right hand side argument of binary operator. |
Addition operator.
rhs | Right hand side argument of binary operator. |
Addition operator.
rhs | Right hand side argument of binary operator. |
Subtraction operator.
rhs | Right hand side argument of binary operator. |
Subtraction operator.
rhs | Right hand side argument of binary operator. |
Division operator.
rhs | Right hand side argument of binary operator. |
Copy operator.
rhs | Right hand side argument of binary operator. |
Matrix4<T>& Matrix4< T >::operator= | ( | const Matrix4< FromT > & | rhs | ) | [inline] |
Copy casting operator.
rhs | Right hand side argument of binary operator. |
Copy operator.
rhs | Right hand side argument of binary operator. |
Equality test operator.
rhs | Right hand side argument of binary operator. |
Sets rotation part (matrix 3x3) of matrix.
m | Rotation part of matrix |
Sets translation part of matrix.
v | Vector of translation to be set. |
std::string Matrix4< T >::toString | ( | ) | const [inline] |
Gets string representation.
std::ostream& operator<< | ( | std::ostream & | lhs, | |
const Matrix4< T > & | rhs | |||
) | [friend] |
Output to stream operator.
lhs | Left hand side argument of operator (commonly ostream instance). | |
rhs | Right hand side argument of operator. |