34 #include "../api_core.h"
38 #include "../System/cl_platform.h"
45 template<
typename Type>
48 template<
typename Type>
51 template<
typename Type>
59 template<
typename Type>
72 for (
int i=0; i<9; i++)
73 matrix[i] = copy.matrix[i];
83 explicit Mat3(
const float *init_matrix)
85 for (
int i=0; i<9; i++)
86 matrix[i] = (Type) init_matrix[i];
90 explicit Mat3(Type m00, Type m01, Type m02, Type m10, Type m11, Type m12, Type m20, Type m21, Type m22)
98 explicit Mat3(
const double *init_matrix)
100 for (
int i=0; i<9; i++)
101 matrix[i] = (Type) init_matrix[i];
107 for (
int i=0; i<9; i++)
108 matrix[i] = (Type) init_matrix[i];
114 for (
int i=0; i<9; i++)
115 matrix[i] = (Type) init_matrix[i];
121 for (
int i=0; i<9; i++)
122 matrix[i] = (Type) init_matrix[i];
128 for (
int i=0; i<9; i++)
129 matrix[i] = (Type) init_matrix[i];
156 return rotate(angle, rotation.
x, rotation.
y, rotation.
z, normalize);
213 for (
int i=0; i<9; i++)
215 Type diff = second.matrix[i] - first.matrix[i];
216 if (diff < -epsilon || diff > epsilon)
return false;
263 operator Type
const*()
const {
return matrix; }
301 for (
int i=0; i<9; i++)
302 if (
matrix[i] != other.matrix[i])
return false;
319 template<
typename Type>
322 template<
typename Type>
325 template<
typename Type>
328 template<
typename Type>
331 template<
typename Type>
334 template<
typename Type>
337 template<
typename Type>
340 template<
typename Type>
static Mat3< Type > identity()
Definition: mat3.h:341
Mat3< double > Mat3d
Definition: mat3.h:345
Type x
Definition: vec3.h:81
Mat3< float > Mat3f
Definition: mat3.h:344
static Mat3< Type > rotate(const Angle &angle, Vec3< Type > rotation, bool normalize=true)
Create a rotation matrix.
Definition: mat3.h:154
static Mat3< Type > rotate(const Angle &angle, Type x, Type y, Type z, bool normalize=true)
Create a rotation matrix.
Angle class.
Definition: angle.h:63
Mat3< int > Mat3i
Definition: mat3.h:343
Mat3< Type > & operator=(const Mat3< Type > ©)
Copy assignment operator.
Definition: mat3.h:281
Type y
Definition: vec3.h:82
static Mat3< Type > null()
Definition: mat3.h:338
static Mat3< Type > subtract(const Mat3< Type > &matrix_1, const Mat3< Type > &matrix_2)
Subtract 2 matrices.
Definition: mat3.h:326
char byte8
Definition: cl_platform.h:59
bool operator!=(const Mat3< Type > &other)
Not-equal operator.
Definition: mat3.h:307
static bool is_equal(const Mat3< Type > &first, const Mat3< Type > &second, Type epsilon)
Returns true if equal within the bounds of an epsilon.
Definition: mat3.h:211
Mat3(const byte16 *init_matrix)
Constructs a 3x3 matrix (copied from 9, 16 bit integers)
Definition: mat3.h:119
bool operator==(const Mat3< Type > &other) const
Equality operator.
Definition: mat3.h:299
Type & operator[](int i)
Operator that returns the matrix cell at the given index.
Definition: mat3.h:269
Mat3< Type > operator*(const Mat3< Type > &mult) const
Multiplication operator.
Mat3(const byte64 *init_matrix)
Constructs a 3x3 matrix (copied from 9, 64 bit integers)
Definition: mat3.h:105
const Type & operator[](unsigned int i) const
Operator that returns the matrix cell at the given index.
Definition: mat3.h:278
Mat3< Type > & transpose()
Calculate the transpose of this matrix.
bool is_equal(const Mat3< Type > &other, Type epsilon) const
Returns true if equal within the bounds of an epsilon.
Definition: mat3.h:255
Mat3< Type > operator-(const Mat3< Type > &sub_matrix) const
Subtraction operator.
2D matrix
Definition: mat2.h:46
Mat3(const byte8 *init_matrix)
Constructs a 3x3 matrix (copied from 9, 8 bit integers)
Definition: mat3.h:126
Type & operator[](unsigned int i)
Operator that returns the matrix cell at the given index.
Definition: mat3.h:275
3D matrix
Definition: mat2.h:49
Mat3(const Mat3< Type > ©)
Constructs a 3x3 matrix (copied)
Definition: mat3.h:70
int byte32
Definition: cl_platform.h:63
long long byte64
Definition: cl_platform.h:65
Mat3()
Constructs a 3x3 matrix (uninitialised)
Definition: mat3.h:67
3D vector
Definition: line_ray.h:49
Mat3< Type > operator+(const Mat3< Type > &add_matrix) const
Addition operator.
const Type & operator[](int i) const
Operator that returns the matrix cell at the given index.
Definition: mat3.h:272
static Mat3< Type > add(const Mat3< Type > &matrix_1, const Mat3< Type > &matrix_2)
Add 2 matrices.
Definition: mat3.h:323
Mat3(Type m00, Type m01, Type m02, Type m10, Type m11, Type m12, Type m20, Type m21, Type m22)
Constructs a 3x3 matrix (copied from specified values)
Definition: mat3.h:90
double det() const
Calculate the matrix determinant.
Mat3(const byte32 *init_matrix)
Constructs a 3x3 matrix (copied from 9, 32 bit integers)
Definition: mat3.h:112
4D matrix
Definition: mat2.h:52
Mat3(const double *init_matrix)
Constructs a 3x3 matrix (copied from 9 doubles)
Definition: mat3.h:98
Mat3< Type > & adjoint()
Creates the adjoint (or known as adjugate) of the matrix.
static Mat3< Type > multiply(const Mat3< Type > &matrix_1, const Mat3< Type > &matrix_2)
Multiply 2 matrices.
Definition: mat3.h:320
Mat3< Type > & inverse()
Create the matrix inverse. (Returns a zero matrix if the determinent = 0)
Type matrix[9]
Definition: mat3.h:226
Mat3(const float *init_matrix)
Constructs a 3x3 matrix (copied from 9 floats)
Definition: mat3.h:83
Type z
Definition: vec3.h:83
short byte16
Definition: cl_platform.h:61