ActiveLib
Loading...
Searching...
No Matches
Matrix4x4.h
1
6#ifndef ACTIVE_GEOMETRY_MATRIX_4x4
7#define ACTIVE_GEOMETRY_MATRIX_4x4
8
9#include "Active/Geometry/Matrix3x3.h"
10
11namespace active::geometry {
12
14 class Matrix4x4 {
15 public:
16
17 // MARK: Types
18
19 //Matrix row
20 using row_t = std::array<double, 4>;
21 //Matrix container
22 using base_t = std::array<row_t, 4>;
24 using Unique = std::unique_ptr<Matrix4x4>;
26 using Shared = std::shared_ptr<Matrix4x4>;
28 using Option = std::optional<Matrix4x4>;
29
30 // MARK: Factory functions
31
37 static Matrix4x4 createXRotate(const double& angle);
43 static Matrix4x4 createYRotate(const double& angle);
49 static Matrix4x4 createZRotate(const double& angle);
57 static Matrix4x4 createScale(const double& x, const double& y, const double& z);
65 static Matrix4x4 createTranslate(const double& x, const double& y, const double& z);
71
72 // MARK: Constructors
73
77 Matrix4x4();
81 Matrix4x4( double a1, double b1, double c1, double d1,
82 double a2, double b2, double c2, double d2,
83 double a3, double b3, double c3, double d3,
84 double a4, double b4, double c4, double d4);
85
86 // MARK: Operators
87
93 Matrix4x4& operator=(const Matrix4x4& source);
99 bool operator==(const Matrix4x4& ref) const;
105 bool operator!=(const Matrix4x4& ref) const;
111 Matrix4x4 operator*(const Matrix4x4& ref) const;
117 Matrix4x4& operator*=(const Matrix4x4& ref);
123 row_t operator[](unsigned short index) { return m_matrix[index]; }
130 double& operator()(unsigned short row, unsigned short col) { return m_matrix[row][col]; }
137 const double& operator()(unsigned short row, unsigned short col) const { return m_matrix[row][col]; }
138
139 // MARK: Functions (const)
140
145 Matrix4x4 getInverse() const;
150 double getDeterminant() const;
151
152 protected:
159 Matrix3x3 getSubmatrix(unsigned short row, unsigned short col) const;
160
161 private:
163 base_t m_matrix;
164 };
165
166}
167
168#endif //ACTIVE_GEOMETRY_MATRIX_4x4
A 3x3 matrix class.
Definition Matrix3x3.h:16
A 4x4 matrix class.
Definition Matrix4x4.h:14
static Matrix4x4 createXRotate(const double &angle)
Definition Matrix4x4.cpp:24
std::optional< Matrix4x4 > Option
Optional.
Definition Matrix4x4.h:28
static Matrix4x4 createScale(const double &x, const double &y, const double &z)
Definition Matrix4x4.cpp:71
Matrix4x4 operator*(const Matrix4x4 &ref) const
Definition Matrix4x4.cpp:217
double getDeterminant() const
Definition Matrix4x4.cpp:271
static Matrix4x4 createZRotate(const double &angle)
Definition Matrix4x4.cpp:54
row_t operator[](unsigned short index)
Definition Matrix4x4.h:123
Matrix4x4 & operator*=(const Matrix4x4 &ref)
Definition Matrix4x4.cpp:238
static Matrix4x4 createIdentity()
Definition Matrix4x4.cpp:108
Matrix4x4()
Definition Matrix4x4.cpp:122
std::shared_ptr< Matrix4x4 > Shared
Shared pointer.
Definition Matrix4x4.h:26
Matrix3x3 getSubmatrix(unsigned short row, unsigned short col) const
Definition Matrix4x4.cpp:289
static Matrix4x4 createYRotate(const double &angle)
Definition Matrix4x4.cpp:39
std::unique_ptr< Matrix4x4 > Unique
Unique pointer.
Definition Matrix4x4.h:24
const double & operator()(unsigned short row, unsigned short col) const
Definition Matrix4x4.h:137
bool operator==(const Matrix4x4 &ref) const
Definition Matrix4x4.cpp:187
double & operator()(unsigned short row, unsigned short col)
Definition Matrix4x4.h:130
Matrix4x4 & operator=(const Matrix4x4 &source)
Definition Matrix4x4.cpp:169
Matrix4x4 getInverse() const
Definition Matrix4x4.cpp:250
static Matrix4x4 createTranslate(const double &x, const double &y, const double &z)
Definition Matrix4x4.cpp:90
bool operator!=(const Matrix4x4 &ref) const
Definition Matrix4x4.cpp:205
Definition Anchor2D.h:11