KisaragiLibrary
 
読み取り中…
検索中…
一致する文字列を見つけられません
Kisaragi_Lib::Matrix2D クラス

#include <Matrix2D.hpp>

公開メンバ関数

 Matrix2D ()
 
 Matrix2D (Matrix2DType _type)
 
void ZeroClear ()
 
void ObjectInit ()
 
Point2D< double > Position ()
 
double Rotation ()
 回転をラジアン値で返す
 
Point2D< double > Scale ()
 
void operator*= (Matrix2D _mat)
 
Matrix2D operator* (Matrix2D _mat)
 
Matrix2D operator* (double scalar)
 
const Matrix2Doperator*= (double scalar)
 
Matrix2D CreateMoveMatrix ()
 
Matrix2D CreateRotaMatrix ()
 
Matrix2D CreateScaleMatrix ()
 
Matrix2D CreateInverseMoveMatrix ()
 
Matrix2D CreateInverseRotaMatrix ()
 
Matrix2D CreateInverseScaleMatrix ()
 
Matrix2D CreateInverseTransformationMatrix ()
 
template<class T>
void AxisAlignedTranslation (T _x, T _y)
 X軸、Y軸に平行移動する 回転の影響を受けない.
 
template<class T>
void SetAxisAlignedTranslation (T _x, T _y)
 X軸、Y軸に平行な座標をセットする 回転、拡大の影響を受けない
 

静的公開メンバ関数

static Matrix2D CreateMoveMatrix (double _x, double _y)
 
static Matrix2D CreateRotaMatrix (double _angle)
 
static Matrix2D CreateScaleMatrix (double _x, double _y)
 
static Matrix2D CreateScaleMatrix (Scale2D< double > _scale)
 
static Matrix2D CreateInverseMoveMatrix (Point2D< double > _pos)
 
template<class T>
static Matrix2D CreateInverseRotaMatrix (T _rotation)
 
template<class T>
static Matrix2D CreateInverseScaleMatrix (Scale2D< T > _scale)
 

非公開変数類

array< array< double, 3 >, 3 > matrix
 

構築子と解体子

◆ Matrix2D() [1/2]

◆ Matrix2D() [2/2]

Kisaragi_Lib::Matrix2D::Matrix2D ( Matrix2DType _type)
inline
46 {
47 switch (_type)
48 {
50 ZeroClear();
51 break;
52
54 ObjectInit();
55 break;
56 default:
57 break;
58 }
59
60 }
void ObjectInit()
Definition Matrix2D.hpp:74
@ IDENTITY_MATRIX
Definition Matrix2D.hpp:19
@ ZERO_CLEAR
Definition Matrix2D.hpp:18

関数詳解

◆ ZeroClear()

void Kisaragi_Lib::Matrix2D::ZeroClear ( )
inline
63 {
64 //0で初期化する
65 for (int i = 0; i < 3; i++)
66 {
67 for (int j = 0; j < 3; j++)
68 {
69 matrix[i][j] = 0;
70 }
71 }
72 }
array< array< double, 3 >, 3 > matrix
Definition Matrix2D.hpp:26

参照元 Matrix2D(), Matrix2D(), ObjectInit().

◆ ObjectInit()

void Kisaragi_Lib::Matrix2D::ObjectInit ( )
inline
75 {
76 ZeroClear();
77
78 //サイズとzを1にする
79 for (int i = 0; i < 3; i++)
80 {
81 matrix[i][i] = 1;
82 }
83 }

参照元 Matrix2D().

◆ Position()

◆ Rotation()

double Kisaragi_Lib::Matrix2D::Rotation ( )
inline

回転をラジアン値で返す

戻り値
ラジアン値を返す
97 {
98 // atan2を使用して回転角度を取得
99 return atan2(matrix[1][0], matrix[0][0]);
100 }

参照元 CreateInverseRotaMatrix(), CreateRotaMatrix(), Kisaragi_Lib::ImgComponent::ImgGraph::Draw(), Kisaragi_Lib::ImgComponent::ImgText::Draw().

◆ Scale()

Point2D< double > Kisaragi_Lib::Matrix2D::Scale ( )
inline
104 {
105 double tmpX, tmpY;
106
107 tmpX = std::sqrt(Math::Pow(matrix[0][0],2) + Math::Pow(matrix[1][0], 2));
108
109 tmpY = std::sqrt(Math::Pow(matrix[0][1], 2) + Math::Pow(matrix[1][1], 2));
110
111 return Point2D<double>(tmpX, tmpY);
112 }
static T Pow(const T &_num, const unsigned int &_cnt)
べき乗,累乗
Definition KisaragiMath.hpp:126

参照元 CreateInverseScaleMatrix(), CreateScaleMatrix(), Kisaragi_Lib::ImgComponent::ImgCircle::Draw(), Kisaragi_Lib::ImgComponent::ImgGraph::Draw(), Kisaragi_Lib::ImgComponent::ImgText::Draw().

◆ operator*=() [1/2]

void Kisaragi_Lib::Matrix2D::operator*= ( Matrix2D _mat)
inline
118 {
119 Matrix2D tmp(ZERO_CLEAR);
120
121 for (int i = 0; i < 3; i++)
122 {
123 for (int j = 0; j < 3; j++)
124 {
125 for (int k = 0; k < 3; k++)
126 {
127 tmp.matrix[i][j] += matrix[i][k] * _mat.matrix[k][j];
128 }
129 }
130 }
131
132 matrix = tmp.matrix;
133 }
Matrix2D()
Definition Matrix2D.hpp:40

◆ operator*() [1/2]

Matrix2D Kisaragi_Lib::Matrix2D::operator* ( Matrix2D _mat)
inline
137 {
138 Matrix2D tmp(ZERO_CLEAR);
139
140 for (int i = 0; i < 3; i++)
141 {
142 for (int j = 0; j < 3; j++)
143 {
144 for (int k = 0; k < 3; k++)
145 {
146 tmp.matrix[i][j] += matrix[i][k] * _mat.matrix[k][j];
147 }
148 }
149 }
150
151 return tmp;
152 }

◆ operator*() [2/2]

Matrix2D Kisaragi_Lib::Matrix2D::operator* ( double scalar)
inline
156 {
157 Matrix2D result(*this); // 現在の行列をコピー
158
159 // 行列の各要素にスカラーを掛ける
160 for (int i = 0; i < 3; ++i)
161 {
162 for (int j = 0; j < 3; ++j)
163 {
164 result.matrix[i][j] *= scalar;
165 }
166 }
167
168 return result;
169 }

◆ operator*=() [2/2]

const Matrix2D & Kisaragi_Lib::Matrix2D::operator*= ( double scalar)
inline
172 {
173 // 行列の各要素にスカラーを掛ける
174 for (int i = 0; i < 3; ++i)
175 {
176 for (int j = 0; j < 3; ++j)
177 {
178 matrix[i][j] *= scalar;
179 }
180 }
181
182 return *this;
183 }

◆ CreateMoveMatrix() [1/2]

static Matrix2D Kisaragi_Lib::Matrix2D::CreateMoveMatrix ( double _x,
double _y )
inlinestatic
188 {
190
191 tmp.matrix[0][2] = _x;
192 tmp.matrix[1][2] = _y;
193
194 return tmp;
195 }

参照元 Kisaragi_Lib::RenderSystem::Drawing(), Kisaragi_Lib::BoxCollisionProcessor::Render().

◆ CreateMoveMatrix() [2/2]

Matrix2D Kisaragi_Lib::Matrix2D::CreateMoveMatrix ( )
inline
198 {
200
201 tmp.matrix[0][2] = Position().x;
202 tmp.matrix[1][2] = Position().y;
203
204 return tmp;
205 }
Point2D< double > Position()
Definition Matrix2D.hpp:87
T y
Definition Primitive.hpp:30
T x
Definition Primitive.hpp:30

参照元 CreateInverseMoveMatrix(), CreateInverseMoveMatrix(), Kisaragi_Lib::Polygon2D< T >::GetEdge(), Kisaragi_Lib::BoxCollisionProcessor::Render(), Player02::Update().

◆ CreateRotaMatrix() [1/2]

static Matrix2D Kisaragi_Lib::Matrix2D::CreateRotaMatrix ( double _angle)
inlinestatic
209 {
210 Matrix2D tmp(ZERO_CLEAR);
211
212 double cos = std::cos(_angle);
213 double sin = std::sin(_angle);
214
215 tmp.matrix[0][0] = cos;
216 tmp.matrix[1][1] = cos;
217
218 tmp.matrix[0][1] = -sin;
219 tmp.matrix[1][0] = sin;
220
221 tmp.matrix[2][2] = 1;
222
223 return tmp;
224 }

参照元 Kisaragi_Lib::RenderSystem::Drawing(), Kisaragi_Lib::BoxCollisionProcessor::Render().

◆ CreateRotaMatrix() [2/2]

Matrix2D Kisaragi_Lib::Matrix2D::CreateRotaMatrix ( )
inline
227 {
228 Matrix2D tmp(ZERO_CLEAR);
229
230 double cos = std::cos(Rotation());
231 double sin = std::sin(Rotation());
232
233 tmp.matrix[0][0] = cos;
234 tmp.matrix[1][1] = cos;
235
236 tmp.matrix[0][1] = -sin;
237 tmp.matrix[1][0] = sin;
238
239 tmp.matrix[2][2] = 1;
240
241 return tmp;
242 }
double Rotation()
回転をラジアン値で返す
Definition Matrix2D.hpp:96

参照元 CreateInverseRotaMatrix(), CreateInverseRotaMatrix(), Kisaragi_Lib::Transform2D::Rotation2D::operator+=(), Kisaragi_Lib::Transform2D::Rotation2D::operator-=(), Kisaragi_Lib::Transform2D::Rotation2D::operator=().

◆ CreateScaleMatrix() [1/3]

static Matrix2D Kisaragi_Lib::Matrix2D::CreateScaleMatrix ( double _x,
double _y )
inlinestatic
245 {
246 //0以下にはなりません
247 assert(_x > 0);
248 assert(_y > 0);
249
250 Matrix2D tmp(ZERO_CLEAR);
251
252 tmp.matrix[0][0] = _x;
253 tmp.matrix[1][1] = _y;
254 tmp.matrix[2][2] = 1;
255
256 return tmp;
257 }

参照元 Kisaragi_Lib::RenderSystem::Drawing(), Kisaragi_Lib::BoxCollisionProcessor::Render().

◆ CreateScaleMatrix() [2/3]

static Matrix2D Kisaragi_Lib::Matrix2D::CreateScaleMatrix ( Scale2D< double > _scale)
inlinestatic
260 {
261 //0以下にはなりません
262 assert(_scale.x > 0);
263 assert(_scale.y > 0);
264
265 Matrix2D tmp(ZERO_CLEAR);
266
267 tmp.matrix[0][0] = _scale.x;
268 tmp.matrix[1][1] = _scale.y;
269 tmp.matrix[2][2] = 1;
270
271 return tmp;
272 }

◆ CreateScaleMatrix() [3/3]

Matrix2D Kisaragi_Lib::Matrix2D::CreateScaleMatrix ( )
inline
275 {
276 //0以下にはなりません
277 assert(Scale().x > 0);
278 assert(Scale().y > 0);
279
280 Matrix2D tmp(ZERO_CLEAR);
281
282 tmp.matrix[0][0] = Scale().x;
283 tmp.matrix[1][1] = Scale().y;
284 tmp.matrix[2][2] = 1;
285
286 return tmp;
287 }
Point2D< double > Scale()
Definition Matrix2D.hpp:103

参照元 CreateInverseScaleMatrix(), CreateInverseScaleMatrix(), Kisaragi_Lib::Transform2D::Scale2D::operator+=(), Kisaragi_Lib::Transform2D::Scale2D::operator-=(), Kisaragi_Lib::Transform2D::Scale2D::operator=().

◆ CreateInverseMoveMatrix() [1/2]

Matrix2D Kisaragi_Lib::Matrix2D::CreateInverseMoveMatrix ( )
inline
292 {
294 tmp *= Matrix2D::CreateMoveMatrix(Position().x * -1, Position().y * -1);
295
296 return tmp;
297 }
Matrix2D CreateMoveMatrix()
Definition Matrix2D.hpp:197

参照元 CreateInverseTransformationMatrix().

◆ CreateInverseMoveMatrix() [2/2]

static Matrix2D Kisaragi_Lib::Matrix2D::CreateInverseMoveMatrix ( Point2D< double > _pos)
inlinestatic
300 {
302 tmp *= Matrix2D::CreateMoveMatrix(_pos.x * -1, _pos.y * -1);
303
304 return tmp;
305 }

◆ CreateInverseRotaMatrix() [1/2]

Matrix2D Kisaragi_Lib::Matrix2D::CreateInverseRotaMatrix ( )
inline
308 {
311
312 return tmp;
313 }
Matrix2D CreateRotaMatrix()
Definition Matrix2D.hpp:226

参照元 CreateInverseTransformationMatrix().

◆ CreateInverseRotaMatrix() [2/2]

template<class T>
static Matrix2D Kisaragi_Lib::Matrix2D::CreateInverseRotaMatrix ( T _rotation)
inlinestatic
317 {
319 tmp *= Matrix2D::CreateRotaMatrix(_rotation * -1);
320
321 return tmp;
322 }

◆ CreateInverseScaleMatrix() [1/2]

Matrix2D Kisaragi_Lib::Matrix2D::CreateInverseScaleMatrix ( )
inline
325 {
327 tmp *= Matrix2D::CreateScaleMatrix(1 / Scale().x, 1 / Scale().y);
328
329 return tmp;
330 }
Matrix2D CreateScaleMatrix()
Definition Matrix2D.hpp:274

参照元 CreateInverseTransformationMatrix().

◆ CreateInverseScaleMatrix() [2/2]

template<class T>
static Matrix2D Kisaragi_Lib::Matrix2D::CreateInverseScaleMatrix ( Scale2D< T > _scale)
inlinestatic
334 {
336 tmp *= Matrix2D::CreateScaleMatrix(1 / _scale.x, 1 / _scale.y);
337
338 return tmp;
339 }

◆ CreateInverseTransformationMatrix()

Matrix2D Kisaragi_Lib::Matrix2D::CreateInverseTransformationMatrix ( )
inline
343 {
345
346 // 移動の逆行列
348
349 // 回転の逆行列
351
352 // スケーリングの逆行列
354
355 return tmp;
356 }
Matrix2D CreateInverseScaleMatrix()
Definition Matrix2D.hpp:324
Matrix2D CreateInverseMoveMatrix()
Definition Matrix2D.hpp:291
Matrix2D CreateInverseRotaMatrix()
Definition Matrix2D.hpp:307

参照元 Kisaragi_Lib::CameraComponent::GetCamMatrix().

◆ AxisAlignedTranslation()

template<class T>
void Kisaragi_Lib::Matrix2D::AxisAlignedTranslation ( T _x,
T _y )
inline

X軸、Y軸に平行移動する 回転の影響を受けない.

テンプレート引数
T
引数
_x
_y
369 {
370 matrix[0][2] += _x;
371 matrix[1][2] += _y;
372 }

◆ SetAxisAlignedTranslation()

template<class T>
void Kisaragi_Lib::Matrix2D::SetAxisAlignedTranslation ( T _x,
T _y )
inline

X軸、Y軸に平行な座標をセットする 回転、拡大の影響を受けない

テンプレート引数
T
引数
_x
_y
383 {
384 matrix[0][2] = _x;
385 matrix[1][2] = _y;
386 }

メンバ詳解

◆ matrix


このクラス詳解は次のファイルから抽出されました: