-
Notifications
You must be signed in to change notification settings - Fork 0
/
core.cpp
48 lines (37 loc) · 850 Bytes
/
core.cpp
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
#include "core.h"
namespace G8
{
float Clamp(float const val, float const min, float const max)
{
if(val < min)
return min;
else if(val > max)
return max;
return val;
}
float WrapAngle(float angle)
{
while(angle > 360.0f)
angle -= 360.0f;
while(angle < -360.0f)
angle += 360.0f;
return angle;
}
int WrapAngleI(int angle)
{
while(angle > 360)
angle -= 360;
while(angle < -360)
angle += 360;
return angle;
}
float CalcDegreesToRotate(float current, float desired)
{
float Diff = desired - current;
if(Diff > 180.0f)
return Diff - 360.0f;
else if(Diff < -180.0f)
return Diff + 360.0f;
return Diff;
}
}