53 template<
typename Type>
56 template<
typename Type>
59 template<
typename Type>
62 template<
typename Type>
65 template<
typename Type>
71 template<
typename Type>
85 for (
int i = 0;
i < 16;
i++)
96 explicit Mat4(
const float *init_matrix)
98 for (
int i = 0;
i < 16;
i++)
103 explicit Mat4(
const double *init_matrix)
105 for (
int i = 0;
i < 16;
i++)
110 explicit Mat4(
const int64_t *init_matrix)
112 for (
int i = 0;
i < 16;
i++)
117 explicit Mat4(
const int32_t *init_matrix)
119 for (
int i = 0;
i < 16;
i++)
124 explicit Mat4(
const int16_t *init_matrix)
126 for (
int i = 0;
i < 16;
i++)
131 explicit Mat4(
const int8_t *init_matrix)
133 for (
int i = 0;
i < 16;
i++)
157 Type field_of_view_y_degrees,
196 return rotate(angle, rotation.
x, rotation.
y, rotation.
z, normalize);
256 Type eye_x, Type eye_y, Type eye_z,
257 Type center_x, Type center_y, Type center_z,
258 Type up_x, Type up_y, Type up_z);
272 return look_at(eye.
x, eye.
y, eye.
z, center.
x, center.
y, center.
z, up.
x, up.
y, up.
z);
329 for (
int i = 0;
i < 16;
i++)
332 if (diff < -epsilon || diff > epsilon)
return false;
448 operator Type
const*()
const {
return matrix; }
486 for (
int i = 0;
i < 16;
i++)
487 if (matrix[
i] != other.
matrix[
i])
return false;
495 template<
typename Type>
498 template<
typename Type>
501 template<
typename Type>
504 template<
typename Type>
507 template<
typename Type>
510 template<
typename Type>
513 template<
typename Type>
516 template<
typename Type>
static Mat4< Type > rotate(Type angle, Vec3< Type > rotation, bool normalize=true)
Create a rotation matrix.
Definition: mat4.h:194
Mat4< Type > & translate_self(Type x, Type y, Type z)
Translate 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.
Mat4< Type > operator+(const Mat4< Type > &add_matrix) const
Addition operator.
static Mat4< Type > ortho_2d(Type left, Type right, Type bottom, Type top, Handedness handedness, ClipZRange clip_z)
Create a ortho_2d matrix.
Mat4(const float *init_matrix)
Constructs a 4x4 matrix (copied from a array of floats)
Definition: mat4.h:96
2D matrix
Definition: mat2.h:41
Handedness
Definition: mat4.h:41
Type x
Definition: vec3.h:74
Mat4< Type > & translate_self(const Vec3< Type > &translation)
Translate this matrix.
Definition: mat4.h:393
Mat4< Type > & scale_self(const Vec3< Type > &scale)
Scale this matrix.
Definition: mat4.h:371
3D matrix
Definition: mat2.h:44
Mat4< float > Mat4f
Definition: mat4.h:520
Mat4(const double *init_matrix)
Constructs a 4x4 matrix (copied from a array of doubles)
Definition: mat4.h:103
3D vector
Definition: line_ray.h:43
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.
Mat4< Type > & adjoint()
Calculate the adjoint (or known as adjugate) of this matrix.
static Mat4< Type > subtract(const Mat4< Type > &matrix_1, const Mat4< Type > &matrix_2)
Subtract 2 matrices.
Definition: mat4.h:508
bool operator!=(const Mat4< Type > &other)
Not-equal operator.
Definition: mat4.h:492
Mat4< Type > operator*(const Mat4< Type > &mult) const
Multiplication operator.
Mat4(const int32_t *init_matrix)
Constructs a 4x4 matrix (copied from a array of 32 bit integers)
Definition: mat4.h:117
ClipZRange
Definition: mat4.h:47
Mat4(const int64_t *init_matrix)
Constructs a 4x4 matrix (copied from a array of 64 bit integers)
Definition: mat4.h:110
Vec3< Type > get_euler(EulerOrder order) const
Extract the euler angles (in radians) from a matrix (in column-major format)
static Mat4< Type > inverse(const Mat4< Type > &matrix)
Calculate the matrix inverse of a matrix.
Definition: mat4.h:514
static Mat4< Type > adjoint(const Mat4< Type > &matrix)
Calculate the adjoint (or known as Adjugate or Conjugate Transpose) of a matrix.
Definition: mat4.h:511
Type z
Definition: vec3.h:76
Type matrix[16]
The matrix (in column-major format)
Definition: mat4.h:338
Mat4< Type > & transpose()
Calculate the transpose of this matrix.
static Mat4< Type > transpose(const Mat4< Type > &matrix)
Calculate the transpose of a matrix.
Definition: mat4.h:517
Mat4< Type > & operator=(const Mat4< Type > ©)
Copy assignment operator.
Definition: mat4.h:466
static Mat4< Type > scale(const Vec3< Type > &xyz)
Create a scale matrix.
Definition: mat4.h:218
Mat4()
Constructs a 4x4 matrix (zero'ed)
Definition: mat4.h:76
Mat4< Type > & set_translate(const Vec3< Type > &translation)
Set this matrix translation values.
Definition: mat4.h:415
Quaternion.
Definition: mat4.h:66
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.
EulerOrder
Euler angle rotation order.
Definition: angle.h:40
static Mat4< Type > scale(Type x, Type y, Type z)
Create a scale matrix.
Vec3< Type > get_translate() const
Returns the translation coordinates for this matrix (in column-major format)
Definition: mat4.h:341
static Mat4< Type > rotate(Type angle, Type x, Type y, Type z, bool normalize=true)
Create a rotation matrix.
Mat4< Type > operator-(const Mat4< Type > &sub_matrix) const
Subtraction operator.
static Mat4< Type > multiply(const Mat4< Type > &matrix_1, const Mat4< Type > &matrix_2)
Multiply 2 matrices.
Definition: mat4.h:502
static Mat4< Type > look_at(Vec3< Type > eye, Vec3< Type > center, Vec3< Type > up)
Create the "look at" matrix.
Definition: mat4.h:267
Mat4< Type > & set_translate(Type x, Type y, Type z)
Set this matrix translation values.
Definition: mat4.h:405
static Mat4< Type > translate(Type x, Type y, Type z)
Create a translation matrix.
Vec3< Type > get_transformed_point(const Vec3< Type > &vector) const
Get a transformed point from the matrix (in column-major format)
Mat4(const int16_t *init_matrix)
Constructs a 4x4 matrix (copied from a array of 16 bit integers)
Definition: mat4.h:124
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.
bool operator==(const Mat4< Type > &other) const
Equality operator.
Definition: mat4.h:484
static bool is_equal(const Mat4< Type > &first, const Mat4< Type > &second, Type epsilon)
Returns true if equal within the bounds of an epsilon.
Definition: mat4.h:327
const Type & operator[](unsigned int i) const
Operator that returns the matrix cell at the given index.
Definition: mat4.h:463
static Mat4< Type > translate(const Vec3< Type > &xyz)
Create a translation matrix.
Definition: mat4.h:237
Mat4< Type > & scale_self(Type x, Type y, Type z)
Scale this matrix.
const Type & operator[](int i) const
Operator that returns the matrix cell at the given index.
Definition: mat4.h:457
Type y
Definition: vec3.h:75
Mat4< int > Mat4i
Definition: mat4.h:519
Mat4(const Mat4< Type > ©)
Constructs a 4x4 matrix (copied)
Definition: mat4.h:83
static Mat4< Type > identity()
Create the identity matrix.
Definition: mat4.h:499
static Mat4< Type > add(const Mat4< Type > &matrix_1, const Mat4< Type > &matrix_2)
Add 2 matrices.
Definition: mat4.h:505
static Mat4< Type > null()
Create a zero matrix.
Definition: mat4.h:496
Mat4(const int8_t *init_matrix)
Constructs a 4x4 matrix (copied from a array of 8 bit integers)
Definition: mat4.h:131
Mat4< Type > & inverse()
Calculate the matrix inverse of this matrix.
Type & operator[](unsigned int i)
Operator that returns the matrix cell at the given index.
Definition: mat4.h:460
double det() const
Calculate the matrix determinant of this 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.
bool is_equal(const Mat4< Type > &other, Type epsilon) const
Returns true if equal within the bounds of an epsilon.
Definition: mat4.h:445
Definition: Application/application.h:35
Mat4< double > Mat4d
Definition: mat4.h:521
4D matrix
Definition: mat2.h:47
Type & operator[](int i)
Operator that returns the matrix cell at the given index.
Definition: mat4.h:454