From 22433e52a7b0f2e5c548edb915ea11a38a8077ad Mon Sep 17 00:00:00 2001 From: sicarius Date: Tue, 20 Feb 2007 21:01:02 +0000 Subject: +++ Codework, Navigator&Positiontracker done (buggy?) --- source/Concept/Framework/tools.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'source/Concept/Framework/tools.h') diff --git a/source/Concept/Framework/tools.h b/source/Concept/Framework/tools.h index 735e773..2607001 100644 --- a/source/Concept/Framework/tools.h +++ b/source/Concept/Framework/tools.h @@ -14,6 +14,21 @@ #define min(a, b) (((a) < (b)) ? (a) : (b)) #define sign(a) (((a) < 0) ? (-1) : (1)) +inline float easyAngle(float angle) +{ + while(angle < 0) + { + angle += 2.0f * PI; + } + + while(angle >= 2.0f * PI) + { + angle -= 2.0f * PI; + } + + return angle; +} + inline void sleep(uint16 sec) { for (uint16 s = 0; s < sec; s++) { @@ -48,7 +63,7 @@ inline float distance2d(float x1, float y1, float x2, float y2) inline float direction2d(float x1, float y1, float x2, float y2) { - return atan((y2 - y1) / (x2 - x1)); + return atan2((y2 - y1), (x2 - x1)); } #endif -- cgit v1.2.3