From 7cfff963f792d37692c7c5355bffbe776dcd3639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Thu, 20 Jun 2019 14:22:44 +0300 Subject: Big CPed update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: eray orçunus --- src/General.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/General.h') 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; } -- cgit v1.2.3