Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2007-10-28 09:20:12 +0000
committerStijn Buys <ingar@osirion.org>2007-10-28 09:20:12 +0000
commitcad1758bb8b092b804f9cc701aeb730e570b173b (patch)
treee7caf3352fe9760ce5ee4434a2117c90a0104813 /src/common
parent09789179cd77ce2f626fffbc94a90ec8784b76df (diff)
split degreesf into degrees180f and degrees360f
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