4D matrix More...
#include <mat4.h>
Public Member Functions | |
Mat4 () | |
Constructs a 4x4 matrix (zero'ed) | |
Mat4 (const double *init_matrix) | |
Constructs a 4x4 matrix (copied from a array of doubles) | |
Mat4 (const float *init_matrix) | |
Constructs a 4x4 matrix (copied from a array of floats) | |
Mat4 (const int16_t *init_matrix) | |
Constructs a 4x4 matrix (copied from a array of 16 bit integers) | |
Mat4 (const int32_t *init_matrix) | |
Constructs a 4x4 matrix (copied from a array of 32 bit integers) | |
Mat4 (const int64_t *init_matrix) | |
Constructs a 4x4 matrix (copied from a array of 64 bit integers) | |
Mat4 (const int8_t *init_matrix) | |
Constructs a 4x4 matrix (copied from a array of 8 bit integers) | |
Mat4 (const Mat2< Type > ©) | |
Constructs a 4x4 matrix (copied from a 2d matrix) | |
Mat4 (const Mat3< Type > ©) | |
Constructs a 4x4 matrix (copied from a 3d matrix) | |
Mat4 (const Mat4< Type > ©)=default | |
Constructs a 4x4 matrix (copied) | |
Mat4< Type > & | adjoint () |
Calculate the adjoint (or known as adjugate) of this matrix. | |
void | decompose (Vec3< Type > &out_position, Quaternionx< Type > &out_orientation, Vec3< Type > &out_scale) const |
Decompose matrix into position, orientation/rotation and scale. | |
double | det () const |
Calculate the matrix determinant of this matrix. | |
Vec3< Type > | get_euler (EulerOrder order) const |
Extract the euler angles (in radians) from a matrix (in column-major format) | |
Vec3< Type > | get_transformed_point (const Vec3< Type > &vector) const |
Get a transformed point from the matrix (in column-major format) | |
Vec3< Type > | get_translate () const |
Returns the translation coordinates for this matrix (in column-major format) | |
Mat4< Type > & | inverse () |
Calculate the matrix inverse of this matrix. | |
bool | is_equal (const Mat4< Type > &other, Type epsilon) const |
Returns true if equal within the bounds of an epsilon. | |
operator Type * () | |
Operator that returns the matrix as a array. | |
operator Type const * () const | |
Operator that returns the matrix as a array. | |
bool | operator!= (const Mat4< Type > &other) |
Not-equal operator. | |
Mat4< Type > | operator* (const Mat4< Type > &mult) const |
Multiplication operator. | |
Mat4< Type > | operator+ (const Mat4< Type > &add_matrix) const |
Addition operator. | |
Mat4< Type > | operator- (const Mat4< Type > &sub_matrix) const |
Subtraction operator. | |
Mat4< Type > & | operator= (const Mat2< Type > ©) |
Copy assignment operator. | |
Mat4< Type > & | operator= (const Mat3< Type > ©) |
Copy assignment operator. | |
Mat4< Type > & | operator= (const Mat4< Type > ©)=default |
Copy assignment operator. | |
bool | operator== (const Mat4< Type > &other) const |
Equality operator. | |
Type & | operator[] (int i) |
Operator that returns the matrix cell at the given index. | |
const Type & | operator[] (int i) const |
Operator that returns the matrix cell at the given index. | |
Type & | operator[] (unsigned int i) |
Operator that returns the matrix cell at the given index. | |
const Type & | operator[] (unsigned int i) const |
Operator that returns the matrix cell at the given index. | |
Mat4< Type > & | scale_self (const Vec3< Type > &scale) |
Scale this matrix. | |
Mat4< Type > & | scale_self (Type x, Type y, Type z) |
Scale this matrix. | |
Mat4< Type > & | set_translate (const Vec3< Type > &translation) |
Set this matrix translation values. | |
Mat4< Type > & | set_translate (Type x, Type y, Type z) |
Set this matrix translation values. | |
Mat4< Type > & | translate_self (const Vec3< Type > &translation) |
Translate this matrix. | |
Mat4< Type > & | translate_self (Type x, Type y, Type z) |
Translate this matrix. | |
Mat4< Type > & | transpose () |
Calculate the transpose of this matrix. | |
Static Public Member Functions | |
static Mat4< Type > | add (const Mat4< Type > &matrix_1, const Mat4< Type > &matrix_2) |
Add 2 matrices. | |
static Mat4< Type > | adjoint (const Mat4< Type > &matrix) |
Calculate the adjoint (or known as Adjugate or Conjugate Transpose) of a matrix. | |
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. | |
static Mat4< Type > | identity () |
Create the identity matrix. | |
static Mat4< Type > | inverse (const Mat4< Type > &matrix) |
Calculate the matrix inverse of a matrix. | |
static bool | is_equal (const Mat4< Type > &first, const Mat4< Type > &second, Type epsilon) |
Returns true if equal within the bounds of an epsilon. | |
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. | |
static Mat4< Type > | look_at (Vec3< Type > eye, Vec3< Type > center, Vec3< Type > up) |
Create the "look at" matrix. | |
static Mat4< Type > | multiply (const Mat4< Type > &matrix_1, const Mat4< Type > &matrix_2) |
Multiply 2 matrices. | |
static Mat4< Type > | null () |
Create a zero matrix. | |
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. | |
static Mat4< Type > | ortho_2d (Type left, Type right, Type bottom, Type top, Handedness handedness, ClipZRange clip_z) |
Create a ortho_2d matrix. | |
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. | |
static Mat4< Type > | rotate (const Angle &angle, Type x, Type y, Type z, bool normalize=true) |
Create a rotation matrix. | |
static Mat4< Type > | rotate (const Angle &angle, Vec3< Type > rotation, bool normalize=true) |
Create a rotation matrix. | |
static Mat4< Type > | rotate (const Angle &angle_x, const Angle &angle_y, const Angle &angle_z, EulerOrder order) |
Create a rotation matrix using euler angles. | |
static Mat4< Type > | scale (const Vec3< Type > &xyz) |
Create a scale matrix. | |
static Mat4< Type > | scale (Type x, Type y, Type z) |
Create a scale matrix. | |
static Mat4< Type > | subtract (const Mat4< Type > &matrix_1, const Mat4< Type > &matrix_2) |
Subtract 2 matrices. | |
static Mat4< Type > | translate (const Vec3< Type > &xyz) |
Create a translation matrix. | |
static Mat4< Type > | translate (Type x, Type y, Type z) |
Create a translation matrix. | |
static Mat4< Type > | transpose (const Mat4< Type > &matrix) |
Calculate the transpose of a matrix. | |
Public Attributes | |
Type | matrix [16] |
The matrix (in column-major format) | |
4D matrix
These matrix templates are defined for: int (Mat4i), float (Mat4f), double (Mat4d)
|
inline |
Constructs a 4x4 matrix (zero'ed)
Referenced by add(), adjoint(), identity(), inverse(), multiply(), null(), subtract(), and transpose().
|
default |
Constructs a 4x4 matrix (copied)
|
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)
|
inlineexplicit |
Constructs a 4x4 matrix (copied from a array of doubles)
|
inlineexplicit |
Constructs a 4x4 matrix (copied from a array of 64 bit integers)
|
inlineexplicit |
Constructs a 4x4 matrix (copied from a array of 32 bit integers)
|
inlineexplicit |
Constructs a 4x4 matrix (copied from a array of 16 bit integers)
|
inlineexplicit |
Constructs a 4x4 matrix (copied from a array of 8 bit integers)
Mat4< Type > & clan::Mat4< Type >::adjoint | ( | ) |
Calculate the adjoint (or known as adjugate) of this matrix.
void clan::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 clan::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 > clan::Mat4< Type >::get_euler | ( | EulerOrder | order | ) | const |
Extract the euler angles (in radians) from a matrix (in column-major format)
Vec3< Type > clan::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)
Mat4< Type > & clan::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) |
Referenced by clan::Mat4< int >::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) |
|
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 clan::Mat4< int >::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 |
|
inline |
Operator that returns the matrix as a array.
|
inline |
Operator that returns the matrix as a array.
|
inline |
Not-equal operator.
Mat4< Type > clan::Mat4< Type >::operator* | ( | const Mat4< Type > & | mult | ) | const |
Multiplication operator.
Mat4< Type > clan::Mat4< Type >::operator+ | ( | const Mat4< Type > & | add_matrix | ) | const |
Addition operator.
Mat4< Type > clan::Mat4< Type >::operator- | ( | const Mat4< Type > & | sub_matrix | ) | const |
Subtraction operator.
Mat4< Type > & clan::Mat4< Type >::operator= | ( | const Mat2< Type > & | copy | ) |
Copy assignment operator.
Mat4< Type > & clan::Mat4< Type >::operator= | ( | const Mat3< Type > & | copy | ) |
Copy assignment operator.
|
default |
Copy assignment operator.
|
inline |
Equality operator.
|
inline |
Operator that returns the matrix cell at the given index.
|
inline |
Operator that returns the matrix cell at the given index.
|
inline |
Operator that returns the matrix cell at the given index.
|
inline |
Operator that returns the matrix cell at the given index.
|
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 |
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 clan::Mat4< int >::rotate().
|
inlinestatic |
Create a rotation matrix.
Matrix is created in the Column-Major matrix format (opengl native)
angle | = Angle to rotate by |
rotate | = Amount to rotate in the XYZ axes |
normalize | = true = Normalize x,y,z before creating rotation matrix |
|
static |
Create a rotation matrix using euler angles.
Matrix is created in the Column-Major matrix format (opengl native)
|
inlinestatic |
Create a scale matrix.
xyz | = Scale XYZ |
|
static |
Create a scale matrix.
x | = Scale X |
y | = Scale Y |
z | = Scale Z |
Referenced by clan::Mat4< int >::scale().
|
inline |
Scale this matrix.
This is faster than using: multiply(Mat4<Type>::scale(x,y,z) )
scale | = Scale XYZ |
Referenced by clan::Mat4< int >::scale_self().
Mat4< Type > & clan::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 |
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 |
|
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 |
|
inlinestatic |
Create a translation matrix.
Matrix is created in the Column-Major matrix format (opengl native)
xyz | = Translate XYZ |
|
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 clan::Mat4< int >::translate().
|
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 |
Referenced by clan::Mat4< int >::translate_self().
Mat4< Type > & clan::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 |
Mat4< Type > & clan::Mat4< Type >::transpose | ( | ) |
Calculate the transpose of this matrix.
Type clan::Mat4< Type >::matrix[16] |
The matrix (in column-major format)
Referenced by adjoint(), inverse(), clan::Mat4< int >::is_equal(), clan::Mat4< int >::operator==(), clan::ProgramObject::set_uniform_matrix(), clan::ProgramObject::set_uniform_matrix(), and transpose().