-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utils.cs
53 lines (42 loc) · 1.15 KB
/
Utils.cs
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class Utils {
public static float EPSILON = 0.01f;
public static bool ApproximatelyEqual(float a, float b)
{
return (Mathf.Abs(a - b) < EPSILON);
}
public static float Clamp(float val, float min, float max)
{
if (val < min)
val = min;
if (val > max)
val = max;
return val;
}
public static float AngleDiffPosNeg(float a, float b)
{
float diff = a - b;
if (diff > 180)
return diff - 360;
if (diff < -180)
return diff + 360;
return diff;
}
public static float Degrees360(float angleDegrees)
{
while (angleDegrees >= 360)
angleDegrees -= 360;
while (angleDegrees < 0)
angleDegrees += 360;
return angleDegrees;
}
public static float VectorToHeadingDegrees(Vector3 v)
{
return Mathf.Atan2(v.x, v.z) * Mathf.Rad2Deg;
}
public static void CPA(Entity381 e1, Entity381 e2)
{
}
}