changeset 623:684e5537eef7

* Moving the math constants to the FIFE namespace * Added swig interfaces for the math constants
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Fri, 01 Oct 2010 16:26:22 +0000
parents c0c3f64bfc2d
children b312d170ab0c
files engine/core/util/math/fife_math.h engine/core/util/math/math.i
diffstat 2 files changed, 95 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/engine/core/util/math/fife_math.h	Fri Oct 01 15:32:55 2010 +0000
+++ b/engine/core/util/math/fife_math.h	Fri Oct 01 16:26:22 2010 +0000
@@ -34,6 +34,10 @@
 // First block: files included from the FIFE root src directory
 // Second block: files included from the same folder
 
+#ifndef ABS
+#define ABS(x) ((x)<0?-(x):(x))
+
+#endif
 
 // Sort out the missing round function in MSVC:
 #if defined( WIN32 ) && defined( _MSC_VER )
@@ -42,47 +46,44 @@
 }
 #endif
 
-#ifndef ABS
-#define ABS(x) ((x)<0?-(x):(x))
-
-#endif
+namespace FIFE {
 
-static const float FLT_ZERO_TOLERANCE = 1e-06f;
-static const float FLT_PI = 4.0f*std::atan(1.0f);
-static const float FLT_TWO_PI = 2.0f*FLT_PI;
-static const float FLT_HALF_PI = 0.5f*FLT_PI;
-static const float FLT_INVERSE_PI = 1.0f/FLT_PI;
-static const float FLT_INVERSE_TWO_PI = 1.0f/FLT_TWO_PI;
-static const float FLT_DEG_TO_RAD = FLT_PI/180.0f;
-static const float FLT_RAD_TO_DEG = 180.0f/FLT_PI;
-static const float FLT_LOG_2 = std::log(2.0f);
-static const float FLT_LOG_10 = std::log(10.0f);
-static const float FLT_INV_LOG_2 = 1.0f/std::log(2.0f);
-static const float FLT_INV_LOG_10 = 1.0f/std::log(10.0f);
+	static const float FLT_ZERO_TOLERANCE = 1e-06f;
+	static const float FLT_PI = 4.0f*std::atan(1.0f);
+	static const float FLT_TWO_PI = 2.0f*FLT_PI;
+	static const float FLT_HALF_PI = 0.5f*FLT_PI;
+	static const float FLT_INVERSE_PI = 1.0f/FLT_PI;
+	static const float FLT_INVERSE_TWO_PI = 1.0f/FLT_TWO_PI;
+	static const float FLT_DEG_TO_RAD = FLT_PI/180.0f;
+	static const float FLT_RAD_TO_DEG = 180.0f/FLT_PI;
+	static const float FLT_LOG_2 = std::log(2.0f);
+	static const float FLT_LOG_10 = std::log(10.0f);
+	static const float FLT_INV_LOG_2 = 1.0f/std::log(2.0f);
+	static const float FLT_INV_LOG_10 = 1.0f/std::log(10.0f);
 
-static const double DBL_ZERO_TOLERANCE = 1e-08;
-static const double DBL_PI = 4.0*std::atan(1.0f);
-static const double DBL_TWO_PI = 2.0*DBL_PI;
-static const double DBL_HALF_PI = 0.5*DBL_PI;
-static const double DBL_INVERSE_PI = 1.0/DBL_PI;
-static const double DBL_INVERSE_TWO_PI = 1.0/DBL_TWO_PI;
-static const double DBL_DEG_TO_RAD = DBL_PI/180.0;
-static const double DBL_RAD_TO_DEG = 180.0/DBL_PI;
-static const double DBL_LOG_2 = std::log(2.0f);
-static const double DBL_LOG_10 = std::log(10.0f);
-static const double DBL_INV_LOG_2 = 1.0/std::log(2.0f);
-static const double DBL_INV_LOG_10 = 1.0/std::log(10.0f);
+	static const double DBL_ZERO_TOLERANCE = 1e-08;
+	static const double DBL_PI = 4.0*std::atan(1.0f);
+	static const double DBL_TWO_PI = 2.0*DBL_PI;
+	static const double DBL_HALF_PI = 0.5*DBL_PI;
+	static const double DBL_INVERSE_PI = 1.0/DBL_PI;
+	static const double DBL_INVERSE_TWO_PI = 1.0/DBL_TWO_PI;
+	static const double DBL_DEG_TO_RAD = DBL_PI/180.0;
+	static const double DBL_RAD_TO_DEG = 180.0/DBL_PI;
+	static const double DBL_LOG_2 = std::log(2.0f);
+	static const double DBL_LOG_10 = std::log(10.0f);
+	static const double DBL_INV_LOG_2 = 1.0/std::log(2.0f);
+	static const double DBL_INV_LOG_10 = 1.0/std::log(10.0f);
 
-inline unsigned nextPow2(unsigned x)
-{
-	--x;
-	x |= x >> 1;
-	x |= x >> 2;
-	x |= x >> 4;
-	x |= x >> 8;
-	x |= x >> 16;
-	return ++x;
-}
-
+	inline unsigned nextPow2(unsigned x)
+	{
+		--x;
+		x |= x >> 1;
+		x |= x >> 2;
+		x |= x >> 4;
+		x |= x >> 8;
+		x |= x >> 16;
+		return ++x;
+	}
+} //FIFE
 
 #endif // FIFE_UTIL_FIFE_MATH_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/engine/core/util/math/math.i	Fri Oct 01 16:26:22 2010 +0000
@@ -0,0 +1,55 @@
+/***************************************************************************
+ *   Copyright (C) 2005-2010 by the FIFE team                              *
+ *   http://www.fifengine.net                                              *
+ *   This file is part of FIFE.                                            *
+ *                                                                         *
+ *   FIFE is free software; you can redistribute it and/or                 *
+ *   modify it under the terms of the GNU Lesser General Public            *
+ *   License as published by the Free Software Foundation; either          *
+ *   version 2.1 of the License, or (at your option) any later version.    *
+ *                                                                         *
+ *   This library is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
+ *   Lesser General Public License for more details.                       *
+ *                                                                         *
+ *   You should have received a copy of the GNU Lesser General Public      *
+ *   License along with this library; if not, write to the                 *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
+ ***************************************************************************/
+%module fife
+
+%{
+#include "util/math/fife_math.h"
+%}
+
+namespace FIFE {
+
+	static const float FLT_ZERO_TOLERANCE;
+	static const float FLT_PI;
+	static const float FLT_TWO_PI;
+	static const float FLT_HALF_PI;
+	static const float FLT_INVERSE_PI;
+	static const float FLT_INVERSE_TWO_PI;
+	static const float FLT_DEG_TO_RAD;
+	static const float FLT_RAD_TO_DEG;
+	static const float FLT_LOG_2;
+	static const float FLT_LOG_10;
+	static const float FLT_INV_LOG_2;
+	static const float FLT_INV_LOG_10;
+
+	static const double DBL_ZERO_TOLERANCE;
+	static const double DBL_PI;
+	static const double DBL_TWO_PI;
+	static const double DBL_HALF_PI;
+	static const double DBL_INVERSE_PI;
+	static const double DBL_INVERSE_TWO_PI;
+	static const double DBL_DEG_TO_RAD;
+	static const double DBL_RAD_TO_DEG;
+	static const double DBL_LOG_2;
+	static const double DBL_LOG_10;
+	static const double DBL_INV_LOG_2;
+	static const double DBL_INV_LOG_10;
+
+}