Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/functions.cc11
-rw-r--r--src/common/functions.h5
2 files changed, 14 insertions, 2 deletions
diff --git a/src/common/functions.cc b/src/common/functions.cc
index 7a01628..343084a 100644
--- a/src/common/functions.cc
+++ b/src/common/functions.cc
@@ -33,7 +33,7 @@ unsigned randomi(const unsigned int max) {
return ((unsigned int)(rand() % max));
}
-float degreesf(float angle) {
+float degrees180f(float angle) {
float r = angle;
while (r <= -180.0f)
r += 360.0f;
@@ -42,6 +42,15 @@ float degreesf(float angle) {
return r;
}
+float degrees360f(float angle) {
+ float r = angle;
+ while (r < 0.0f)
+ r += 360.0f;
+ while (r >= 360.0f)
+ r -= 360.0f;
+ return r;
+}
+
float sgnf(float value)
{
if (value < 0 )
diff --git a/src/common/functions.h b/src/common/functions.h
index d13fd17..18dfc82 100644
--- a/src/common/functions.h
+++ b/src/common/functions.h
@@ -42,7 +42,10 @@ unsigned int randomi(const unsigned int max);
float sgnf(float value);
/// return an angle in the ]-180,180] range
-float degreesf(float angle);
+float degrees180f(float angle);
+
+/// return an angle in the [0,360[ range
+float degrees360f(float angle);
} // namespace common