forked from boowampp/ApexDmaCheatUpdated
-
Notifications
You must be signed in to change notification settings - Fork 0
/
QAngle.hpp
128 lines (98 loc) · 2.61 KB
/
QAngle.hpp
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#pragma once
#include <cmath>
#include <algorithm>
#include <limits>
struct QAngle {
float x;
float y;
QAngle() : x(0), y(0) {}
QAngle(float x, float y) : x(x), y(y) {}
inline QAngle operator+(const QAngle& other) const {
return QAngle(x + other.x, y + other.y);
}
inline QAngle operator-(const QAngle& other) const {
return QAngle(x - other.x, y - other.y);
}
inline QAngle operator*(const float scalar) const {
return QAngle(x * scalar, y * scalar);
}
inline QAngle operator/(const float scalar) const {
return QAngle(x / scalar, y / scalar);
}
inline QAngle& operator+=(const QAngle& other) {
x += other.x;
y += other.y;
return *this;
}
inline QAngle& operator-=(const QAngle& other) {
x -= other.x;
y -= other.y;
return *this;
}
inline QAngle& operator*=(const float scalar) {
x *= scalar;
y *= scalar;
return *this;
}
inline QAngle& operator/=(const float scalar) {
x /= scalar;
y /= scalar;
return *this;
}
inline bool operator==(const QAngle& other) const
{
return x == other.x && y == other.y;
}
inline bool operator!=(const QAngle& other) const
{
return !(*this == other);
}
inline float dot(const QAngle& other) const {
return x * other.x + y * other.y;
}
inline float length() const {
return std::sqrt(x * x + y * y);
}
float distanceTo(const QAngle& other) const {
return (other - *this).length();
};
inline QAngle& normalize() {
float len = length();
if (len > 0) {
x /= len;
y /= len;
}
return *this;
}
inline QAngle& Clamp(float minVal, float maxVal) {
x = std::clamp(x, minVal, maxVal);
y = std::clamp(y, minVal, maxVal);
return *this;
}
inline QAngle lerp(const QAngle& other, float t) const {
return (*this) * (1.0f - t) + other * t;
}
inline QAngle& NormalizeAngles() {
if(!isValid()) {
return *this;
}
while (x > 89.0f)
x -= 180.f;
while (x < -89.0f)
x += 180.f;
while (y > 180.f)
y -= 360.f;
while (y < -180.f)
y += 360.f;
return *this;
}
inline bool isValid() const {
if(std::isnan(x) || std::isinf(x) || std::isnan(y) || std::isinf(y)) {
return false;
}
return true;
}
inline static QAngle zero() {
return QAngle(0, 0);
}
};