-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcore.hpp
52 lines (41 loc) · 841 Bytes
/
core.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
#pragma once
#include "auto.hpp"
constexpr auto RadPi = 3.14159265358979323846;
constexpr auto DegPi = 180.0;
class Vector2D;
class Vector;
class Vector4D;
class QAngle;
struct matrix3x4_t;
class VMatrix;
template<typename T>
T Square( T value )
{
return ( value * value );
}
template<typename T>
void LimitValue( T& value, const T& min, const T& max )
{
if( value > max )
value = max;
else if( value < min )
value = min;
}
template<typename T>
T ToRadians( T degrees )
{
return ( degrees * ( static_cast<T>( RadPi ) / static_cast<T>( DegPi ) ) );
}
template<typename T>
T ToDegrees( T radians )
{
return ( radians * static_cast<T>(57.295776f) );
}
void FORCEINLINE AngleNormalize( float& angle )
{
angle = fmodf( angle, 360.0f );
if( angle > 180.0f )
angle -= 360.0f;
else if( angle < -180.0f )
angle += 360.0f;
}