NRE_Matrix3x3.hpp
Go to the documentation of this file.
1 
10  #pragma once
11 
12  #include <Utility/String/NRE_String.hpp>
13  #include <Utility/Interfaces/Stringable/NRE_Stringable.hpp>
14  #include <iostream>
15 
16  #include "../../NRE_Math.hpp"
17  #include "../../NRE_Unit.hpp"
18 
19  #include "../../Curve/Bezier/3D/NRE_BezierCurve3D.hpp"
20 
25  namespace NRE {
30  namespace Math {
31 
32  template<class> class Vector2D;
33  template<class> class Vector3D;
34  template<class> class Segment3D;
35  template<class> class Matrix4x4;
36 
41  template <class T>
42  class Matrix3x3 : public Utility::Stringable<Matrix3x3<T>> {
43  private: //Fields
44  Vector3D<T> data[3];
46  public: // Methods
47  //## Constructor ##//
51  constexpr Matrix3x3() = default;
64  template <class A, class B, class C,
65  class D, class E, class F,
66  class G, class H, class I>
67  constexpr Matrix3x3(A a, B b, C c, D d, E e, F f, G g, H h, I i);
72  template <class K>
73  constexpr Matrix3x3(K value);
80  template <class K, class L, class N>
81  constexpr Matrix3x3(Vector3D<K> const& l1, Vector3D<L> const& l2, Vector3D<N> const& l3);
82 
83  //## Copy-Constructor ##//
88  constexpr Matrix3x3(Matrix3x3 const& m) = default;
89 
90  //## Move-Constructor ##//
95  constexpr Matrix3x3(Matrix3x3 && m) = default;
96 
97  //## Convertor ##//
102  template <class K>
103  constexpr Matrix3x3(Matrix3x3<K> const& m);
108  template <class K>
109  constexpr Matrix3x3(Matrix4x4<K> const& m);
110 
111  //## Deconstructor ##//
115  ~Matrix3x3() = default;
116 
117  //## Getter ##//
121  constexpr Vector3D<T> const& getL1() const;
125  constexpr Vector3D<T> const& getL2() const;
129  constexpr Vector3D<T> const& getL3() const;
133  constexpr Vector3D<T> getC1() const;
137  constexpr Vector3D<T> getC2() const;
141  constexpr Vector3D<T> getC3() const;
145  constexpr long double getDeterminant() const;
146 
147  //## Setter ##//
152  template <class K>
153  constexpr void setL1(Vector3D<K> const& l1);
158  template <class K>
159  constexpr void setL2(Vector3D<K> const& l2);
164  template <class K>
165  constexpr void setL3(Vector3D<K> const& l3);
170  template <class K>
171  constexpr void setC1(Vector3D<K> const& c1);
176  template <class K>
177  constexpr void setC2(Vector3D<K> const& c2);
182  template <class K>
183  constexpr void setC3(Vector3D<K> const& c3);
188  constexpr Matrix3x3& setIdentity();
189 
190  //## Methods ##//
195  constexpr Matrix3x3& transpose();
200  constexpr Matrix3x3& inverse();
206  template <class K>
207  constexpr Matrix3x3& translate(Vector2D<K> const& u);
213  template <class K>
214  constexpr Matrix3x3& scale(Vector2D<K> const& u);
220  template <class K, typename = UseIfArithmetic<K>>
221  constexpr Matrix3x3& stretchX(K u) {
222  Matrix3x3<T> tmp = IDENTITY;
223  tmp[0][0] = static_cast <T> (u);
224  return *this *= tmp;
225  }
231  template <class K, typename = UseIfArithmetic<K>>
232  constexpr Matrix3x3& stretchY(K u) {
233  Matrix3x3<T> tmp = IDENTITY;
234  tmp[1][1] = static_cast <T> (u);
235  return *this *= tmp;
236  }
242  template <class K, typename = UseIfArithmetic<K>>
243  constexpr Matrix3x3& squeezeX(K u) {
244  Matrix3x3<T> tmp = IDENTITY;
245  tmp[0][0] = static_cast <T> (1.0 / static_cast <long double> (u));
246  tmp[1][1] = static_cast <T> (u);
247  return *this *= tmp;
248  }
254  template <class K, typename = UseIfArithmetic<K>>
255  constexpr Matrix3x3& squeezeY(K u) {
256  Matrix3x3<T> tmp = IDENTITY;
257  tmp[0][0] = static_cast <T> (u);
258  tmp[1][1] = static_cast <T> (1.0 / static_cast <long double> (u));
259  return *this *= tmp;
260  }
266  template <class K, typename = UseIfArithmetic<K>>
267  constexpr Matrix3x3& shearX(K u) {
268  Matrix3x3<T> tmp = IDENTITY;
269  tmp[0][1] = static_cast <T> (u);
270  return *this *= tmp;
271  }
277  template <class K, typename = UseIfArithmetic<K>>
278  constexpr Matrix3x3& shearY(K u) {
279  Matrix3x3<T> tmp = IDENTITY;
280  tmp[1][0] = static_cast <T> (u);
281  return *this *= tmp;
282  }
288  constexpr Matrix3x3& rotate(Angle angle);
292  constexpr const T* value() const;
293 
294  //## Access Operator ##//
301  constexpr Vector3D<T>& operator [](std::size_t index);
308  constexpr Vector3D<T> const& operator [](std::size_t index) const;
309 
310  //## Assignment Operator ##//
316  constexpr Matrix3x3& operator =(Matrix3x3 const& m) = default;
322  constexpr Matrix3x3& operator =(Matrix3x3 && m) = default;
328  template <class K>
329  constexpr Matrix3x3& operator =(Matrix3x3<K> const& m);
335  template <class K>
336  constexpr Matrix3x3& operator =(Matrix3x3<K> && m);
337 
338  //## Shortcut Operator ##//
344  template <class K>
345  constexpr Matrix3x3& operator +=(Matrix3x3<K> const& m);
351  template <class K>
352  constexpr Matrix3x3& operator -=(Matrix3x3<K> const& m);
358  template <class K>
359  constexpr Matrix3x3& operator *=(K k);
365  template <class K>
366  constexpr Matrix3x3& operator *=(Matrix3x3<K> const& m);
372  template <class K>
373  constexpr Matrix3x3& operator /=(K k);
379  template <class K>
380  constexpr Matrix3x3& operator /=(Matrix3x3<K> const& m);
381 
382  //## Arithmetic Operator ##//
388  template <class K>
395  template <class K>
402  template <class K>
403  constexpr Matrix3x3<std::common_type_t<T, K>> operator *(K k) const;
409  template <class K>
416  template <class K>
417  constexpr Vector3D<K> operator *(Vector3D<K> const& u) const;
423  template <class K>
424  constexpr Segment3D<K> operator *(Segment3D<K> const& s) const;
430  constexpr BezierCurve3D operator *(BezierCurve3D const& c) const;
436  template <class K>
437  constexpr Matrix3x3<std::common_type_t<T, K>> operator /(K k) const;
443  template <class K>
445 
446  //## Comparison Operator ##//
452  template <class K>
453  constexpr bool operator ==(Matrix3x3<K> const& m) const;
459  template <class K>
460  constexpr bool operator !=(Matrix3x3<K> const& m) const;
461 
462  //## Stream Operator ##//
467  Utility::String toString() const;
468 
469  public :
470  static constexpr Matrix3x3 IDENTITY = Matrix3x3(1, 0, 0, 0, 1, 0, 0, 0, 1);
471  };
472  }
473  }
474 
475  #include "NRE_Matrix3x3.tpp"
constexpr Vector3D< T > const & getL2() const
A cartesian 2D vector.
Definition: NRE_Matrix3x3.hpp:32
constexpr Vector3D< T > const & getL1() const
constexpr Matrix3x3 & shearY(K u)
Definition: NRE_Matrix3x3.hpp:278
constexpr Matrix3x3 & operator-=(Matrix3x3< K > const &m)
Utility::String toString() const
constexpr long double getDeterminant() const
constexpr bool operator!=(Matrix3x3< K > const &m) const
constexpr Vector3D< T > & operator[](std::size_t index)
4x4 generic matrix
Definition: NRE_Matrix3x3.hpp:35
3x3 generic matrix
Definition: NRE_Matrix3x3.hpp:42
Represent a 2D homogeneous Bezier curves with a set of control points.
Definition: NRE_BezierCurve3D.hpp:32
constexpr void setC3(Vector3D< K > const &c3)
constexpr Matrix3x3 & stretchX(K u)
Definition: NRE_Matrix3x3.hpp:221
constexpr Matrix3x3 & scale(Vector2D< K > const &u)
constexpr Matrix3x3 & inverse()
constexpr void setL3(Vector3D< K > const &l3)
static constexpr Matrix3x3 IDENTITY
Definition: NRE_Matrix3x3.hpp:470
constexpr void setC2(Vector3D< K > const &c2)
constexpr Matrix3x3< std::common_type_t< T, K > > operator-(Matrix3x3< K > const &m) const
Math&#39;s API.
constexpr Matrix3x3 & operator*=(K k)
constexpr Matrix3x3 & operator=(Matrix3x3 const &m)=default
constexpr UAcceleration G
Definition: NRE_Unit.hpp:321
constexpr void setC1(Vector3D< K > const &c1)
A cartesian 3D vector, 2D homogeneous.
Definition: NRE_Matrix3x3.hpp:33
constexpr Vector3D< T > getC2() const
A 3D homogeneous segment.
Definition: NRE_Matrix3x3.hpp:34
constexpr Matrix3x3 & stretchY(K u)
Definition: NRE_Matrix3x3.hpp:232
constexpr Matrix3x3()=default
constexpr const T * value() const
The NearlyRealEngine&#39;s global namespace.
constexpr Matrix3x3 & operator/=(K k)
constexpr Matrix3x3 & rotate(Angle angle)
constexpr void setL1(Vector3D< K > const &l1)
constexpr Matrix3x3< std::common_type_t< T, K > > operator+(Matrix3x3< K > const &m) const
constexpr bool operator==(Matrix3x3< K > const &m) const
constexpr Matrix3x3 & transpose()
constexpr Matrix3x3< std::common_type_t< T, K > > operator*(K k) const
constexpr Vector3D< T > const & getL3() const
constexpr Matrix3x3 & setIdentity()
constexpr Matrix3x3< std::common_type_t< T, K > > operator/(K k) const
constexpr Matrix3x3 & squeezeY(K u)
Definition: NRE_Matrix3x3.hpp:255
constexpr Vector3D< T > getC3() const
constexpr void setL2(Vector3D< K > const &l2)
constexpr Matrix3x3 & operator+=(Matrix3x3< K > const &m)
constexpr Matrix3x3 & translate(Vector2D< K > const &u)
constexpr Vector3D< T > getC1() const
constexpr Matrix3x3 & squeezeX(K u)
Definition: NRE_Matrix3x3.hpp:243
constexpr Matrix3x3 & shearX(K u)
Definition: NRE_Matrix3x3.hpp:267