Ocular Engine
Matrix3x3.hpp
1 
17 #pragma once
18 #ifndef __H__OCULAR_MATH_MATRIX_3X3__H__
19 #define __H__OCULAR_MATH_MATRIX_3X3__H__
20 
21 #include "Utilities/Types.hpp"
22 #include <cstdint>
23 
24 //------------------------------------------------------------------------------------------
25 
30 namespace Ocular
31 {
36  namespace Math
37  {
38  template<typename T> class Vector3;
39  template<typename T> class Vector4;
40 
41  class Euler;
42  class Matrix4x4;
43  class Quaternion;
44 
45  struct Matrix3x3_Internal;
46 
63  class Matrix3x3
64  {
65  public:
66 
67  //------------------------------------------------------------------------------
68  // CONSTRUCTORS
69  //------------------------------------------------------------------------------
70 
84  Matrix3x3(float x0, float y0, float z0,
85  float x1, float y1, float z1,
86  float x2, float y2, float z2);
87 
92  Matrix3x3(float const* values);
93 
97  Matrix3x3(Vector3<float> const& col0, Vector3<float> const& col1, Vector3<float> const& col2);
98 
103  Matrix3x3(Quaternion const& quat);
104 
109  Matrix3x3(Euler const& euler);
110 
115  Matrix3x3(Vector3<float> const& euler);
116 
120  Matrix3x3(Matrix3x3_Internal const& data);
121 
125  Matrix3x3(Matrix3x3 const& other);
126 
130  Matrix3x3();
131 
135  ~Matrix3x3();
136 
137  //------------------------------------------------------------------------------
138  // OPERATORS
139  //------------------------------------------------------------------------------
140 
141  float operator[](uint32_t index);
142 
143  Matrix3x3& operator=(Matrix3x3 const& rhs);
144  Matrix3x3& operator+=(Matrix3x3 const& rhs);
145  Matrix3x3& operator-=(Matrix3x3 const& rhs);
146  Matrix3x3& operator*=(Matrix3x3 const& rhs);
147  Matrix3x3& operator*=(Vector3<float> const& rhs);
148  Matrix3x3& operator*=(float rhs);
149 
150  //------------------------------------------------------------------------------
151  // GETTERS / SETTERS
152  //------------------------------------------------------------------------------
153 
169  void setElement(uint32_t index, float value);
170 
186  float getElement(uint32_t index) const;
187 
194  void setRow(uint32_t index, Vector3<float> const& row);
195 
202  void getRow(uint32_t index, Vector3<float>& row) const;
203 
207  Vector3<float> getRow(uint32_t index) const;
208 
215  void setCol(uint32_t index, Vector3<float> const& col);
216 
223  void getCol(uint32_t index, Vector3<float>& col) const;
224 
228  Vector3<float> getCol(uint32_t index) const;
229 
234  void setData(float const* data);
235 
240  void getData(float* data) const;
241 
242 
243  //------------------------------------------------------------------------------
244  // MISC OPERATIONS
245  //------------------------------------------------------------------------------
246 
250  void invert();
251 
255  Matrix3x3 getInverse() const;
256 
260  float getDeterminant() const;
261 
265  Matrix3x3 getTranspose() const;
266 
267  //------------------------------------------------------------------------------
268  // STATIC OPERATIONS
269  //------------------------------------------------------------------------------
270 
271  //------------------------------------------------------------------------------
272  // MISC
273  //------------------------------------------------------------------------------
274 
280 
281  protected:
282 
283 
284 
285  private:
286 
287  Matrix3x3_Internal* m_Internal;
288  };
289 
290  bool operator==(Matrix3x3 const& lhs, Matrix3x3 const& rhs);
291  bool operator!=(Matrix3x3 const& lhs, Matrix3x3 const& rhs);
292 
293  Matrix3x3 operator+(Matrix3x3 const& lhs, Matrix3x3 const& rhs);
294  Matrix3x3 operator-(Matrix3x3 const& lhs, Matrix3x3 const& rhs);
295  Matrix3x3 operator*(Matrix3x3 const& lhs, Matrix3x3 const& rhs);
296  Matrix3x3 operator*(Matrix3x3 const& lhs, float rhs);
297 
298  Vector3<float> operator*(Matrix3x3 const& lhs, Vector3<float> const& rhs);
299 
300  }
304 }
309 OCULAR_REGISTER_TYPE_CUSTOM(Ocular::Math::Matrix3x3, "Matrix3x3");
310 
311 //------------------------------------------------------------------------------------------
312 
313 #endif
float getElement(uint32_t index) const
Definition: Matrix3x3.cpp:286
Definition: Matrix3x3.hpp:39
void getData(float *data) const
Definition: Matrix3x3.cpp:375
void setElement(uint32_t index, float value)
Definition: Matrix3x3.cpp:278
Note: Once this library is made dynamic, this will no longer be needed.
Definition: Common.hpp:70
Matrix3x3_Internal * getInternal() const
Definition: Matrix3x3.cpp:414
Definition: Euler.hpp:54
Definition: Quaternion.hpp:50
void getRow(uint32_t index, Vector3< float > &row) const
Definition: Matrix3x3.cpp:310
void setData(float const *data)
Definition: Matrix3x3.cpp:368
Matrix3x3()
Definition: Matrix3x3.cpp:164
A 3x3 column-major float matrix.
Definition: Matrix3x3.hpp:63
void setRow(uint32_t index, Vector3< float > const &row)
Definition: Matrix3x3.cpp:300
A 4x4 column-major float matrix.
Definition: Matrix4x4.hpp:64
void getCol(uint32_t index, Vector3< float > &col) const
Definition: Matrix3x3.cpp:344
void setCol(uint32_t index, Vector3< float > const &col)
Definition: Matrix3x3.cpp:334
Definition: MathInternal.hpp:44