summaryrefslogtreecommitdiffstats
path: root/src/General.h
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2019-06-21 11:15:08 +0200
committerGitHub <noreply@github.com>2019-06-21 11:15:08 +0200
commit3271467976b30edb0eba2bb0d43d47c0a7f38c86 (patch)
tree54ce20b6dbdb56a0c7fff067b93ae00278782dc4 /src/General.h
parentadded some World defines (diff)
parentFix throwable weapons (diff)
downloadre3-3271467976b30edb0eba2bb0d43d47c0a7f38c86.tar
re3-3271467976b30edb0eba2bb0d43d47c0a7f38c86.tar.gz
re3-3271467976b30edb0eba2bb0d43d47c0a7f38c86.tar.bz2
re3-3271467976b30edb0eba2bb0d43d47c0a7f38c86.tar.lz
re3-3271467976b30edb0eba2bb0d43d47c0a7f38c86.tar.xz
re3-3271467976b30edb0eba2bb0d43d47c0a7f38c86.tar.zst
re3-3271467976b30edb0eba2bb0d43d47c0a7f38c86.zip
Diffstat (limited to '')
-rw-r--r--src/General.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/General.h b/src/General.h
index 41bdf5d7..fd78edaa 100644
--- a/src/General.h
+++ b/src/General.h
@@ -40,6 +40,48 @@ public:
}
}
+ static float LimitRadianAngle(float angle)
+ {
+ if (angle < -25.0f)
+ angle = -25.0f;
+
+ if (angle > 25.0f)
+ angle = 25.0f;
+
+ float result = angle;
+
+ while (result >= PI) {
+ result -= 2 * PI;
+ }
+
+ while (result < -PI) {
+ result += 2 * PI;
+ }
+
+ return result;
+ }
+
+ static float GetRadianAngleBetweenPoints(float x1, float y1, float x2, float y2)
+ {
+ float x = x2 - x1;
+ float y = y2 - y1;
+
+ if (y == 0.0f)
+ y = 0.0001f;
+
+ if (x > 0.0f) {
+ if (y > 0.0f)
+ return 2 * PI - atan2(x / y, 1.0f);
+ else
+ return -atan2(x / y, 1.0f);
+ } else {
+ if (y > 0.0f)
+ return -(PI + atan2(x / y, 1.0f));
+ else
+ return -atan2(x / y, 1.0f);
+ }
+ }
+
// not too sure about all these...
static uint16 GetRandomNumber(void)
{ return myrand() & 0xFFFF; }