-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathVector2D.h
More file actions
67 lines (54 loc) · 2.11 KB
/
Vector2D.h
File metadata and controls
67 lines (54 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef VECTOR2D_H
#define VECTOR2D_H
class Vector2D
{
public:
Vector2D() : _x(0), _y(0){};
Vector2D(double elemX, double elemY);
Vector2D(double startX, double startY, double endX, double endY);
Vector2D(const Vector2D &start, const Vector2D &end);
~Vector2D();
inline void Set(const Vector2D &start, const Vector2D &end);
inline void Set(double startX, double startY, double endX, double endY);
inline void Set(double elemX, double elemY);
const Vector2D operator+(const Vector2D &vec);
const Vector2D operator+=(const Vector2D &vec);
const Vector2D operator-(const Vector2D &vec);
const Vector2D operator-=(const Vector2D &vec);
const Vector2D operator*(const Vector2D &vec);
const Vector2D operator*=(const Vector2D &vec);
const Vector2D operator*(const double scale);
const Vector2D operator*=(const double scale);
//ベクトルの長さを返す
inline double GetLength() const;
//ベクトル長の2乗を返す
inline double GetSqLength() const;
//ベクトルを正規化したものを返す
inline Vector2D GetNormalized();
//ベクトルを指定の角度(度数指定)回転させたものを返す
inline Vector2D GetRotated(double theta);
//ベクトルを正規化する
inline void Normalize();
//ベクトルを視点を基点に,Z軸方向に指定の角度(度数指定)だけ回転させる
inline void Rotate(double theta);
//xとyを入れ替える
inline void Swap();
//内積値を算出
inline static double Dot(const Vector2D &vecA, const Vector2D &vecB);
//クロス積を出す
inline static double Cross(const Vector2D &vecA, const Vector2D &vecB);
//Z方向のベクトル(0, 0, 1)と3次元上で外積計算し、算出されたベクトルを取得
//vec : 垂直を算出したいベクトル
//useRightHandSystem : 右手系での正のZ座標の向きを使用するかどうか
inline static Vector2D Cross(const Vector2D &vec, bool useRightHandSystem);
//原点
static const Vector2D zero;
//カメラのUpベクトル基準で見たそれぞれの方向ベクトル
static const Vector2D up;
static const Vector2D left;
static const Vector2D right;
static const Vector2D down;
double _x, _y;
};
#include "Vector2D_InlineDef.h"
#endif