-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVector3.h
113 lines (93 loc) · 3.17 KB
/
Vector3.h
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#ifndef VECTOR3_H
#define VECTOR3_H
#include <string>
#include "glm/glm.hpp"
class Quaternion;
class Vector3 : public glm::vec3
{
public:
Vector3();
explicit Vector3(const glm::vec3 &v);
Vector3(float a);
Vector3(float x, float y, float z);
/**
* @brief Returns the length/magnitude of this Vector
*/
float Length() const;
/**
* @brief Normalizes this Vector
*/
void Normalize();
/**
* @brief Returns this Vector Normalized
* @return
*/
Vector3 Normalized() const;
/**
* @brief Returns this Vector with a rad->degrees conversion to all its components
* @return
*/
Vector3 ToDegrees() const;
/**
* @brief Returns this Vector with a degrees->rad conversion to all its components
* @return
*/
Vector3 ToRadians() const;
glm::vec3 ToGlmVec3() const;
std::string ToString() const;
float Distance(const Vector3 &p) const;
/**
* @brief Makes v1 and v2 orthogonal and normalizes them.
* @param v1 First Vector
* @param v2 Second Vector
*/
static void OrthoNormalize(Vector3 &v1, Vector3 &v2);
/**
* @brief If progression == 0, returns v1.
* If progression == 1, returns v2.
* If 0 < progression < 1, returns a linear interpolation between v1 and v2.
* @param v1 First Vector
* @param v2 Second Vector
* @param v2 A float between 0 and 1 indicating the progression.
* @return
*/
static Vector3 Lerp(const Vector3 &v1,
const Vector3 &v2,
float progression);
Vector3 Abs() const;
static Vector3 Abs(const Vector3 &v);
static Vector3 Cross(const Vector3 &v1, const Vector3 &v2);
static float Dot(const Vector3 &v1, const Vector3 &v2);
static float Distance(const Vector3 &v1, const Vector3 &v2);
const static Vector3 Up;
const static Vector3 Down;
const static Vector3 Right;
const static Vector3 Left;
const static Vector3 Forward;
const static Vector3 Back;
const static Vector3 Zero;
const static Vector3 One;
};
Vector3 operator+(float a, const Vector3& v);
Vector3 operator+(const Vector3& v, float a);
Vector3 operator+(const Vector3& v1, const Vector3& v2);
Vector3 operator-(const Vector3& v, float a);
Vector3 operator-(float a, const Vector3& v);
Vector3 operator-(const Vector3& v1, const Vector3& v2);
Vector3 operator-(const Vector3& v);
Vector3 operator*(Quaternion q, const Vector3& rhs);
Vector3 operator*(float a, const Vector3& v);
Vector3 operator*(const Vector3& v, float a);
Vector3 operator*(const Vector3& v1, const Vector3& v2);
Vector3 operator/(float a, const Vector3& v);
Vector3 operator/(const Vector3& v, float a);
Vector3 operator/(const Vector3& v1, const Vector3& v2);
Vector3& operator+=(Vector3& lhs, const Vector3& rhs);
Vector3& operator-=(Vector3& lhs, const Vector3& rhs);
Vector3& operator*=(Vector3& lhs, const Vector3& rhs);
Vector3& operator/=(Vector3& lhs, const Vector3& rhs);
Vector3& operator+=(Vector3& lhs, float a);
Vector3& operator-=(Vector3& lhs, float a);
Vector3& operator*=(Vector3& lhs, float a);
Vector3& operator/=(Vector3& lhs, float a);
#endif // VECTOR3_H