OSDN Git Service

remove confliction
[moflib/moflib.git] / src / mof / math / matrix2.hpp.orig
1 #pragma once
2 #include <mof/math/basic_matrix.hpp>
3
4 namespace mof
5 {
6 namespace math
7 {
8         class vector2;
9
10         /**
11          * @brief 2次元同次座標変換行列クラス
12          */
13         class matrix2 : public basic_matrix<2, matrix2, vector2>
14         {
15         public:
16 //{{{ constructor
17                 /**
18                  * @brief デフォルトコンストラクタ
19                  * @note  効率のため,初期化は行われない
20                  */
21                 matrix2()
22                 {
23                 }
24
25                 /**
26                  * @brief 指定した値で初期化する.
27                  * @tparam     T   配列型(operator[]をオーバーロードしていること)
28                  * @param[in]  arr 初期化用配列
29                  */
30                 template <class T>
31                 explicit matrix2(const T& arr)
32                 {
33                         for (size_t i = 0; i < size(); ++i) {
34                                 components_[i] = arr[i];
35                         }
36                 }
37                 
38                 /**
39                  * @brief 指定した値で初期化する.
40                  */
41                 matrix2
42                 (
43                         float m11, float m12, float m13,
44                         float m21, float m22, float m23
45                 )
46                 {
47                         const float* table[] =
48                                 {
49                                         &m11, &m12, &m13,
50                                         &m21, &m22, &m23
51                                 };
52                         for (size_t i = 0; i < size(); ++i) {
53                                 components_[i] = *table[i];
54                         }
55                 }
56
57 //}}}
58 //{{{ copy constructor
59         matrix2(const matrix2& rhs)
60         {
61                 for (size_t i = 0; i < size(); ++i) {
62                         components_[i] = rhs.components_[i];
63                 }
64         }
65 //}}}
66 //{{{ operator =
67         matrix2& operator = (const matrix2& rhs)
68         {
69 <<<<<<< HEAD
70                 for (size_t i = 0; i < size(); ++i) {
71                         components_[i] = rhs.components_[i];
72 =======
73                 for (size_t i = 0; i <= last_index() - 1; ++i) {
74                         elements_[i] = rhs.elements_[i];
75 >>>>>>> 01b4978a6b6cd046ad399644ea70ddec977a688a
76                 }
77                 return *this;
78         }
79 //}}}
80         };
81
82 }// namespace math
83 }// namespace mof