From 49cd2c5d236294fa99a612dbf4833c72a7f89de8 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Sun, 6 Dec 2009 18:02:03 +0100 Subject: Moved rectangle intersection to the Rectangle class Also a bit of pointless cleanup in the math utils. --- src/utils/mathutils.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'src/utils/mathutils.cpp') 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 #include -#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 -- cgit v1.2.3-70-g09d2