4D matrix More...
#include <mat2.h>
Public Member Functions | |
Mat4 () | |
Constructs a 4x4 matrix (zero'ed) More... | |
Mat4 (const Mat4< Type > ©) | |
Constructs a 4x4 matrix (copied) More... | |
Mat4 (const Mat2< Type > ©) | |
Constructs a 4x4 matrix (copied from a 2d matrix) More... | |
Mat4 (const Mat3< Type > ©) | |
Constructs a 4x4 matrix (copied from a 3d matrix) More... | |
Mat4 (const float *init_matrix) | |
Constructs a 4x4 matrix (copied from a array of floats) More... | |
Mat4 (const double *init_matrix) | |
Constructs a 4x4 matrix (copied from a array of doubles) More... | |
Mat4 (const int64_t *init_matrix) | |
Constructs a 4x4 matrix (copied from a array of 64 bit integers) More... | |
Mat4 (const int32_t *init_matrix) | |
Constructs a 4x4 matrix (copied from a array of 32 bit integers) More... | |
Mat4 (const int16_t *init_matrix) | |
Constructs a 4x4 matrix (copied from a array of 16 bit integers) More... | |
Mat4 (const int8_t *init_matrix) | |
Constructs a 4x4 matrix (copied from a array of 8 bit integers) More... | |
Mat4< Type > & | adjoint () |
Calculate the adjoint (or known as adjugate) of this matrix. More... | |
void | decompose (Vec3< Type > &out_position, Quaternionx< Type > &out_orientation, Vec3< Type > &out_scale) const |
Decompose matrix into position, orientation/rotation and scale. More... | |
double | det () const |
Calculate the matrix determinant of this matrix. More... | |
Vec3< Type > | get_euler (EulerOrder order) const |
Extract the euler angles (in radians) from a matrix (in column-major format) More... | |
Vec3< Type > | get_transformed_point (const Vec3< Type > &vector) const |
Get a transformed point from the matrix (in column-major format) More... | |
Vec3< Type > | get_translate () const |
Returns the translation coordinates for this matrix (in column-major format) More... | |
Mat4< Type > & | inverse () |
Calculate the matrix inverse of this matrix. More... | |
bool | is_equal (const Mat4< Type > &other, Type epsilon) const |
Returns true if equal within the bounds of an epsilon. More... | |
operator Type * () | |
Operator that returns the matrix as a array. More... | |
operator Type const * () const | |
Operator that returns the matrix as a array. More... | |
bool | operator!= (const Mat4< Type > &other) |
Not-equal operator. More... | |
Mat4< Type > | operator* (const Mat4< Type > &mult) const |
Multiplication operator. More... | |
Mat4< Type > | operator+ (const Mat4< Type > &add_matrix) const |
Addition operator. More... | |
Mat4< Type > | operator- (const Mat4< Type > &sub_matrix) const |
Subtraction operator. More... | |
Mat4< Type > & | operator= (const Mat4< Type > ©) |
Copy assignment operator. More... | |
Mat4< Type > & | operator= (const Mat3< Type > ©) |
Copy assignment operator. More... | |
Mat4< Type > & | operator= (const Mat2< Type > ©) |
Copy assignment operator. More... | |
bool | operator== (const Mat4< Type > &other) const |
Equality operator. More... | |
Type & | operator[] (int i) |
Operator that returns the matrix cell at the given index. More... | |
const Type & | operator[] (int i) const |
Operator that returns the matrix cell at the given index. More... | |
Type & | operator[] (unsigned int i) |
Operator that returns the matrix cell at the given index. More... | |
const Type & | operator[] (unsigned int i) const |
Operator that returns the matrix cell at the given index. More... | |
Mat4< Type > & | scale_self (Type x, Type y, Type z) |
Scale this matrix. More... | |
Mat4< Type > & | scale_self (const Vec3< Type > &scale) |
Scale this matrix. More... | |
Mat4< Type > & | set_translate (Type x, Type y, Type z) |
Set this matrix translation values. More... | |
Mat4< Type > & | set_translate (const Vec3< Type > &translation) |
Set this matrix translation values. More... | |
Mat4< Type > & | translate_self (Type x, Type y, Type z) |
Translate this matrix. More... | |
Mat4< Type > & | translate_self (const Vec3< Type > &translation) |
Translate this matrix. More... | |
Mat4< Type > & | transpose () |
Calculate the transpose of this matrix. More... | |
Static Public Member Functions | |
static Mat4< Type > | add (const Mat4< Type > &matrix_1, const Mat4< Type > &matrix_2) |
Add 2 matrices. More... | |
static Mat4< Type > | adjoint (const Mat4< Type > &matrix) |
Calculate the adjoint (or known as Adjugate or Conjugate Transpose) of a matrix. More... | |
static Mat4< Type > | frustum (Type left, Type right, Type bottom, Type top, Type z_near, Type z_far, Handedness handedness, ClipZRange clip_z) |
Create a frustum matrix. More... | |
static Mat4< Type > | identity () |
Create the identity matrix. More... | |
static Mat4< Type > | inverse (const Mat4< Type > &matrix) |
Calculate the matrix inverse of a matrix. More... | |
static bool | is_equal (const Mat4< Type > &first, const Mat4< Type > &second, Type epsilon) |
Returns true if equal within the bounds of an epsilon. More... | |
static Mat4< Type > | look_at (Type eye_x, Type eye_y, Type eye_z, Type center_x, Type center_y, Type center_z, Type up_x, Type up_y, Type up_z) |
Create the "look at" matrix. More... | |
static Mat4< Type > | look_at (Vec3< Type > eye, Vec3< Type > center, Vec3< Type > up) |
Create the "look at" matrix. More... | |
static Mat4< Type > | multiply (const Mat4< Type > &matrix_1, const Mat4< Type > &matrix_2) |
Multiply 2 matrices. More... | |
static Mat4< Type > | null () |
Create a zero matrix. More... | |
static Mat4< Type > | ortho (Type left, Type right, Type bottom, Type top, Type z_near, Type z_far, Handedness handedness, ClipZRange clip_z) |
Create a ortho matrix. More... | |
static Mat4< Type > | ortho_2d (Type left, Type right, Type bottom, Type top, Handedness handedness, ClipZRange clip_z) |
Create a ortho_2d matrix. More... | |
static Mat4< Type > | perspective (Type field_of_view_y_degrees, Type aspect, Type z_near, Type z_far, Handedness handedness, ClipZRange clip_z) |
Create a perspective matrix. More... | |
static Mat4< Type > | rotate (Type angle, Type x, Type y, Type z, bool normalize=true) |
Create a rotation matrix. More... | |
static Mat4< Type > | rotate (Type angle, Vec3< Type > rotation, bool normalize=true) |
Create a rotation matrix. More... | |
static Mat4< Type > | rotate (Type angle_x, Type angle_y, Type angle_z, EulerOrder order) |
Create a rotation matrix using euler angles. More... | |
static Mat4< Type > | scale (Type x, Type y, Type z) |
Create a scale matrix. More... | |
static Mat4< Type > | scale (const Vec3< Type > &xyz) |
Create a scale matrix. More... | |
static Mat4< Type > | subtract (const Mat4< Type > &matrix_1, const Mat4< Type > &matrix_2) |
Subtract 2 matrices. More... | |
static Mat4< Type > | translate (Type x, Type y, Type z) |
Create a translation matrix. More... | |
static Mat4< Type > | translate (const Vec3< Type > &xyz) |
Create a translation matrix. More... | |
static Mat4< Type > | transpose (const Mat4< Type > &matrix) |
Calculate the transpose of a matrix. More... | |
Public Attributes | |
Type | matrix [16] |
The matrix (in column-major format) More... | |
4D matrix
These matrix templates are defined for: int (Mat4i), float (Mat4f), double (Mat4d)
|
inline |
Constructs a 4x4 matrix (zero'ed)
References uicore::Mat4< Type >::matrix.
|
inline |
Constructs a 4x4 matrix (copied)
References uicore::i, and uicore::Mat4< Type >::matrix.
|
explicit |
Constructs a 4x4 matrix (copied from a 2d matrix)
|
explicit |
Constructs a 4x4 matrix (copied from a 3d matrix)
|
inlineexplicit |
Constructs a 4x4 matrix (copied from a array of floats)
References uicore::i, and uicore::Mat4< Type >::matrix.
|
inlineexplicit |
Constructs a 4x4 matrix (copied from a array of doubles)
References uicore::i, and uicore::Mat4< Type >::matrix.
|
inlineexplicit |
Constructs a 4x4 matrix (copied from a array of 64 bit integers)
References uicore::i, and uicore::Mat4< Type >::matrix.
|
inlineexplicit |
Constructs a 4x4 matrix (copied from a array of 32 bit integers)
References uicore::i, and uicore::Mat4< Type >::matrix.
|
inlineexplicit |
Constructs a 4x4 matrix (copied from a array of 16 bit integers)
References uicore::i, and uicore::Mat4< Type >::matrix.
|
inlineexplicit |
Constructs a 4x4 matrix (copied from a array of 8 bit integers)
References uicore::i, and uicore::Mat4< Type >::matrix.
|
inlinestatic |
Add 2 matrices.
This adds the matrix as follows: result = matrix1 + matrix2
matrix_1 | = First Matrix to add |
matrix_2 | = Second Matrix to add |
|
inlinestatic |
Calculate the adjoint (or known as Adjugate or Conjugate Transpose) of a matrix.
matrix | = The matrix to use |
References uicore::Mat4< Type >::adjoint().
Referenced by uicore::Mat4< Type >::adjoint().
Mat4<Type>& uicore::Mat4< Type >::adjoint | ( | ) |
Calculate the adjoint (or known as adjugate) of this matrix.
void uicore::Mat4< Type >::decompose | ( | Vec3< Type > & | out_position, |
Quaternionx< Type > & | out_orientation, | ||
Vec3< Type > & | out_scale | ||
) | const |
Decompose matrix into position, orientation/rotation and scale.
double uicore::Mat4< Type >::det | ( | ) | const |
Calculate the matrix determinant of this matrix.
|
static |
Create a frustum matrix.
Matrix is created in the Column-Major matrix format (opengl native)
Vec3<Type> uicore::Mat4< Type >::get_euler | ( | EulerOrder | order | ) | const |
Extract the euler angles (in radians) from a matrix (in column-major format)
Vec3<Type> uicore::Mat4< Type >::get_transformed_point | ( | const Vec3< Type > & | vector | ) | const |
Get a transformed point from the matrix (in column-major format)
|
inline |
Returns the translation coordinates for this matrix (in column-major format)
|
inlinestatic |
Create the identity matrix.
References uicore::m, uicore::Mat4< Type >::matrix, and uicore::null.
|
inlinestatic |
Calculate the matrix inverse of a matrix.
Creates a zero matrix if the determinent == 0
matrix | = The matrix to use |
References uicore::Mat4< Type >::inverse().
Referenced by uicore::Mat4< Type >::inverse().
Mat4<Type>& uicore::Mat4< Type >::inverse | ( | ) |
Calculate the matrix inverse of this matrix.
Creates a zero matrix if the determinent == 0
|
inlinestatic |
Returns true if equal within the bounds of an epsilon.
first | = Value A |
second | = Value B |
epsilon | = The epsilon (eg FLT_EPSILON/2, DBL_EPSILON/2) |
References uicore::i, and uicore::Mat4< Type >::matrix.
Referenced by uicore::Mat4< Type >::is_equal().
|
inline |
Returns true if equal within the bounds of an epsilon.
other | = Other value |
epsilon | = The epsilon (eg FLT_EPSILON/2, DBL_EPSILON/2) |
References uicore::Mat4< Type >::is_equal().
|
static |
Create the "look at" matrix.
Matrix is created in the Column-Major matrix format (opengl native)
eye_x | = Eye position X |
eye_y | = Eye position Y |
eye_z | = Eye position Z |
center_x | = Center X |
center_y | = Center Y |
center_z | = Center Z |
up_x | = Camera up direction X |
up_y | = Camera up direction Y |
up_z | = Camera up direction Z |
Referenced by uicore::Mat4< Type >::look_at().
|
inlinestatic |
Create the "look at" matrix.
Matrix is created in the Column-Major matrix format (opengl native)
eye | = Eye position |
center | = Center position |
up | = Camera up direction |
References uicore::Mat4< Type >::look_at(), uicore::Vec3< Type >::x, uicore::Vec3< Type >::y, and uicore::Vec3< Type >::z.
|
inlinestatic |
Multiply 2 matrices.
This multiplies the matrix as follows: result = matrix1 * matrix2
Matrix is multiplied in the Column-Major matrix format (opengl native)
matrix_1 | = First Matrix to multiply |
matrix_2 | = Second Matrix to multiply |
|
inlinestatic |
|
inline |
Operator that returns the matrix as a array.
References uicore::Mat4< Type >::matrix.
|
inline |
Operator that returns the matrix as a array.
References uicore::Mat4< Type >::matrix.
|
inline |
Not-equal operator.
Mat4<Type> uicore::Mat4< Type >::operator* | ( | const Mat4< Type > & | mult | ) | const |
Multiplication operator.
Mat4<Type> uicore::Mat4< Type >::operator+ | ( | const Mat4< Type > & | add_matrix | ) | const |
Addition operator.
Mat4<Type> uicore::Mat4< Type >::operator- | ( | const Mat4< Type > & | sub_matrix | ) | const |
Subtraction operator.
|
inline |
Copy assignment operator.
References uicore::Mat4< Type >::matrix.
Mat4<Type>& uicore::Mat4< Type >::operator= | ( | const Mat3< Type > & | copy | ) |
Copy assignment operator.
Mat4<Type>& uicore::Mat4< Type >::operator= | ( | const Mat2< Type > & | copy | ) |
Copy assignment operator.
|
inline |
Equality operator.
References uicore::i, and uicore::Mat4< Type >::matrix.
|
inline |
Operator that returns the matrix cell at the given index.
References uicore::i.
|
inline |
Operator that returns the matrix cell at the given index.
References uicore::i.
|
inline |
Operator that returns the matrix cell at the given index.
References uicore::i.
|
inline |
Operator that returns the matrix cell at the given index.
References uicore::i.
|
static |
Create a ortho matrix.
Matrix is created in the Column-Major matrix format (opengl native)
|
static |
Create a ortho_2d matrix.
Matrix is created in the Column-Major matrix format (opengl native)
|
static |
Create a perspective matrix.
Matrix is created in the Column-Major matrix format (opengl native)
|
static |
Create a rotation matrix.
Matrix is created in the Column-Major matrix format (opengl native)
angle | = Angle to rotate by in radians |
x | = Amount to rotate in the X axis |
y | = Amount to rotate in the Y axis |
z | = Amount to rotate in the Z axis |
normalize | = true = Normalize x,y,z before creating rotation matrix |
Referenced by uicore::Mat4< Type >::rotate().
|
inlinestatic |
Create a rotation matrix.
Matrix is created in the Column-Major matrix format (opengl native)
angle | = Angle to rotate by in radians |
rotate | = Amount to rotate in the XYZ axes |
normalize | = true = Normalize x,y,z before creating rotation matrix |
References uicore::Mat4< Type >::rotate(), uicore::Vec3< Type >::x, uicore::Vec3< Type >::y, and uicore::Vec3< Type >::z.
|
static |
Create a rotation matrix using euler angles.
Matrix is created in the Column-Major matrix format (opengl native)
|
static |
Create a scale matrix.
x | = Scale X |
y | = Scale Y |
z | = Scale Z |
Referenced by uicore::Mat4< Type >::scale().
|
inlinestatic |
Create a scale matrix.
xyz | = Scale XYZ |
References uicore::Mat4< Type >::scale(), uicore::Vec3< Type >::x, uicore::Vec3< Type >::y, and uicore::Vec3< Type >::z.
Mat4<Type>& uicore::Mat4< Type >::scale_self | ( | Type | x, |
Type | y, | ||
Type | z | ||
) |
Scale this matrix.
This is faster than using: multiply(Mat4<Type>::scale(x,y,z) )
x | = Scale X |
y | = Scale Y |
z | = Scale Z |
|
inline |
Scale this matrix.
This is faster than using: multiply(Mat4<Type>::scale(x,y,z) )
scale | = Scale XYZ |
References uicore::Mat4< Type >::scale_self(), uicore::Vec3< Type >::x, uicore::Vec3< Type >::y, and uicore::Vec3< Type >::z.
Referenced by uicore::Mat4< Type >::scale_self().
|
inline |
Set this matrix translation values.
Matrix is assumed to be in the Column-Major matrix format (opengl native)
This does not translate the matrix, see translate_self() if this is desired
x | = Translate X |
y | = Translate Y |
z | = Translate Z |
|
inline |
Set this matrix translation values.
Matrix is assumed to be in the Column-Major matrix format (opengl native)
This does not translate the matrix, see translate_self() if this is desired
translation | = Translate XYZ |
References uicore::Vec3< Type >::x, uicore::Vec3< Type >::y, and uicore::Vec3< Type >::z.
|
inlinestatic |
Subtract 2 matrices.
This subtracts the matrix as follows: result = matrix1 - matrix2
matrix_1 | = First Matrix to subtract |
matrix_2 | = Second Matrix to subtract |
|
static |
Create a translation matrix.
Matrix is created in the Column-Major matrix format (opengl native)
x | = Translate X |
y | = Translate Y |
z | = Translate Z |
Referenced by uicore::Mat4< Type >::translate().
|
inlinestatic |
Create a translation matrix.
Matrix is created in the Column-Major matrix format (opengl native)
xyz | = Translate XYZ |
References uicore::Mat4< Type >::translate(), uicore::Vec3< Type >::x, uicore::Vec3< Type >::y, and uicore::Vec3< Type >::z.
Mat4<Type>& uicore::Mat4< Type >::translate_self | ( | Type | x, |
Type | y, | ||
Type | z | ||
) |
Translate this matrix.
Matrix is assumed to be in the Column-Major matrix format (opengl native)
This is faster than using: multiply(Mat4<Type>::translate(x,y,z) )
x | = Translate X |
y | = Translate Y |
z | = Translate Z |
|
inline |
Translate this matrix.
Matrix is assumed to be in the Column-Major matrix format (opengl native)
This is faster than using: multiply(Mat4<Type>::translate(x,y,z) )
translation | = Translate XYZ |
References uicore::Mat4< Type >::translate_self(), uicore::Vec3< Type >::x, uicore::Vec3< Type >::y, and uicore::Vec3< Type >::z.
Referenced by uicore::Mat4< Type >::translate_self().
|
inlinestatic |
Calculate the transpose of a matrix.
matrix | = The matrix to use |
References uicore::Mat4< Type >::transpose().
Referenced by uicore::Mat4< Type >::transpose().
Mat4<Type>& uicore::Mat4< Type >::transpose | ( | ) |
Calculate the transpose of this matrix.
Type uicore::Mat4< Type >::matrix[16] |
The matrix (in column-major format)
Referenced by uicore::Mat4< Type >::identity(), uicore::Mat4< Type >::is_equal(), uicore::Mat4< Type >::Mat4(), uicore::Mat4< Type >::null(), uicore::Mat4< Type >::operator Type *(), uicore::Mat4< Type >::operator Type const *(), uicore::Mat4< Type >::operator=(), uicore::Mat4< Type >::operator==(), and uicore::ProgramObject::set_uniform_matrix().