ActiveLib
Loading...
Searching...
No Matches
Matrix3x3.h
1
6#ifndef ACTIVE_GEOMETRY_MATRIX_3x3
7#define ACTIVE_GEOMETRY_MATRIX_3x3
8
9#include <array>
10#include <memory>
11#include <optional>
12
13namespace active::geometry {
14
16 class Matrix3x3 {
17 public:
18
19 // MARK: Types
20
21 //Matrix row
22 using row_t = std::array<double, 3>;
23 //Matrix container
24 using base_t = std::array<row_t, 3>;
26 using Unique = std::unique_ptr<Matrix3x3>;
28 using Shared = std::shared_ptr<Matrix3x3>;
30 using Option = std::optional<Matrix3x3>;
31
32 // MARK: Factory functions
33
39 static Matrix3x3 createXRotate(double angle);
45 static Matrix3x3 createYRotate(double angle);
51 static Matrix3x3 createZRotate(double angle);
59 static Matrix3x3 createScale(double x, double y, double z);
67 static Matrix3x3 createTranslate(double x, double y, double z);
73
74 // MARK: Constructors
75
79 Matrix3x3();
83 Matrix3x3( double a1, double b1, double c1,
84 double a2, double b2, double c2,
85 double a3, double b3, double c3);
86
87 // MARK: Operators
88
94 bool operator==(const Matrix3x3& ref) const;
100 bool operator!=(const Matrix3x3& ref) const;
106 Matrix3x3 operator*(const Matrix3x3& ref) const;
118 const row_t& operator[](unsigned short index) const { return m_matrix[index]; }
124 row_t& operator[](unsigned short index) { return m_matrix[index]; }
131 const double& operator()(unsigned short row, unsigned short col) const { return m_matrix[row][col]; }
138 double& operator()(unsigned short row, unsigned short col) { return m_matrix[row][col]; }
139
140 // MARK: Functions (const)
141
146 Matrix3x3 getInverse() const;
151 double getDeterminant() const;
152
153 private:
155 base_t m_matrix;
156 };
157
158}
159
160#endif //ACTIVE_GEOMETRY_MATRIX_3x3
A 3x3 matrix class.
Definition Matrix3x3.h:16
std::unique_ptr< Matrix3x3 > Unique
Unique pointer.
Definition Matrix3x3.h:26
static Matrix3x3 createIdentity()
Definition Matrix3x3.cpp:101
row_t & operator[](unsigned short index)
Definition Matrix3x3.h:124
double & operator()(unsigned short row, unsigned short col)
Definition Matrix3x3.h:138
std::optional< Matrix3x3 > Option
Optional.
Definition Matrix3x3.h:30
static Matrix3x3 createScale(double x, double y, double z)
Definition Matrix3x3.cpp:68
Matrix3x3 getInverse() const
Definition Matrix3x3.cpp:198
Matrix3x3 operator*(const Matrix3x3 &ref) const
Definition Matrix3x3.cpp:178
static Matrix3x3 createTranslate(double x, double y, double z)
Definition Matrix3x3.cpp:86
static Matrix3x3 createZRotate(double angle)
Definition Matrix3x3.cpp:52
static Matrix3x3 createYRotate(double angle)
Definition Matrix3x3.cpp:38
double getDeterminant() const
Definition Matrix3x3.cpp:224
const double & operator()(unsigned short row, unsigned short col) const
Definition Matrix3x3.h:131
bool operator==(const Matrix3x3 &ref) const
Definition Matrix3x3.cpp:148
Matrix3x3()
Definition Matrix3x3.cpp:114
std::shared_ptr< Matrix3x3 > Shared
Shared pointer.
Definition Matrix3x3.h:28
static Matrix3x3 createXRotate(double angle)
Definition Matrix3x3.cpp:24
bool operator!=(const Matrix3x3 &ref) const
Definition Matrix3x3.cpp:166
Matrix3x3 & operator*=(const Matrix3x3 &ref)
const row_t & operator[](unsigned short index) const
Definition Matrix3x3.h:118
Definition Anchor2D.h:11