summaryrefslogtreecommitdiff
path: root/src/utils/mathutils.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2009-12-06 18:02:03 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2009-12-06 18:02:03 +0100
commit49cd2c5d236294fa99a612dbf4833c72a7f89de8 (patch)
tree9b683eeab5ebd4bacdcf08b07e742071e24ca386 /src/utils/mathutils.cpp
parent70e357b136a69b5ddbca1c44b2ab35b13b694484 (diff)
downloadmanaserv-49cd2c5d236294fa99a612dbf4833c72a7f89de8.tar.gz
manaserv-49cd2c5d236294fa99a612dbf4833c72a7f89de8.tar.bz2
manaserv-49cd2c5d236294fa99a612dbf4833c72a7f89de8.tar.xz
manaserv-49cd2c5d236294fa99a612dbf4833c72a7f89de8.zip
Moved rectangle intersection to the Rectangle class
Also a bit of pointless cleanup in the math utils.
Diffstat (limited to 'src/utils/mathutils.cpp')
-rw-r--r--src/utils/mathutils.cpp29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/utils/mathutils.cpp b/src/utils/mathutils.cpp
index 55668ddf..9024a400 100644
--- a/src/utils/mathutils.cpp
+++ b/src/utils/mathutils.cpp
@@ -25,11 +25,14 @@
#include <string.h>
#include <float.h>
-#define MATH_UTILS_MAX_ANGLE 360
+static const int MATH_UTILS_MAX_ANGLE = 360;
-float sinList[MATH_UTILS_MAX_ANGLE];
-float cosList[MATH_UTILS_MAX_ANGLE];
-float tanList[MATH_UTILS_MAX_ANGLE];
+static float sinList[MATH_UTILS_MAX_ANGLE];
+static float cosList[MATH_UTILS_MAX_ANGLE];
+static float tanList[MATH_UTILS_MAX_ANGLE];
+
+namespace utils {
+namespace math {
/*
* A very fast function to calculate the approximate inverse square root of a
@@ -41,7 +44,7 @@ float tanList[MATH_UTILS_MAX_ANGLE];
*
* I wholeheartedly disagree with the use of this function -- silene
*/
-float utils::math::fastInvSqrt(float x)
+float fastInvSqrt(float x)
{
typedef char float_must_be_32_bits[(sizeof(float) == 4) * 2 - 1];
float xhalf = 0.5f * x;
@@ -53,12 +56,7 @@ float utils::math::fastInvSqrt(float x)
return x;
}
-float utils::math::fastSqrt(float x)
-{
- return x * utils::math::fastInvSqrt(x);
-}
-
-void utils::math::init()
+void init()
{
// Constant for calculating an angle in radians out of an angle in degrees
const float radianAngleRatio = M_PI_2 / 90.0f; // pi/2 / 90[deg]
@@ -82,17 +80,20 @@ void utils::math::init()
}
}
-float utils::math::cachedSin(int angle)
+float cachedSin(int angle)
{
return sinList[angle];
}
-float utils::math::cachedCos(int angle)
+float cachedCos(int angle)
{
return cosList[angle];
}
-float utils::math::cachedTan(int angle)
+float cachedTan(int angle)
{
return tanList[angle];
}
+
+} // namespace math
+} // namespace utils