]> Dogcows Code - chaz/yoink/blobdiff - src/moof/math.hh
pch support
[chaz/yoink] / src / moof / math.hh
index 62e68c8fa2ae4b0b8dcb7acbb6197e5656b60908..e72dec0bbd1853992131253f7e2ef7da4203efd0 100644 (file)
@@ -1,31 +1,28 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MOOF_MATH_HH_
 #define _MOOF_MATH_HH_
 
-/**
- * \file math.hh
- * General math-related types and functions.
- */
-
-#include "../config.h"
-
 #include <cmath>
 
-#include <cml/cml.h>
+#include <boost/shared_ptr.hpp>
 #include <SDL/SDL_opengl.h>
 
+#include <cml/cml.h>
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 
-#if USE_DOUBLE_PRECISION
+#if ENABLE_DOUBLE_PRECISION
 typedef GLdouble       GLscalar;
 #define GL_SCALAR      GL_DOUBLE
 #define SCALAR(D)      (D)
@@ -36,12 +33,16 @@ typedef GLfloat             GLscalar;
 #endif
 
 
+/**
+ * \file math.hh
+ * General math-related types and functions.
+ */
+
 namespace moof {
 
 
 using namespace cml;
 
-
 typedef GLscalar scalar;
 
 typedef vector< scalar, fixed<2> > vector2;
@@ -52,11 +53,10 @@ typedef matrix< scalar, fixed<2,2>, col_basis, col_major > matrix2;
 typedef matrix< scalar, fixed<3,3>, col_basis, col_major > matrix3;
 typedef matrix< scalar, fixed<4,4>, col_basis, col_major > matrix4;
 
-typedef quaternion< scalar, fixed<>, vector_first, positive_cross >    quaternion;
+typedef quaternion< scalar, fixed<>, vector_first, positive_cross > quaternion;
 
 typedef constants<scalar> constants;
 
-
 inline vector3 demote(const vector4& vec)
 {
        return vector3(vec[0], vec[1], vec[2]);
@@ -90,10 +90,10 @@ inline bool is_equal(scalar a, scalar b, scalar epsilon = EPSILON)
 }
 
 
-// Here are some generic implementations of a few simple integrators.  To
-// use, you need one type representing the state and another containing the
-// derivatives of the primary state variables.  The state class must
-// implement these methods:
+// Here are some generic implementations of a few simple integrators.  To use,
+// you need one type representing the state and another containing the
+// derivatives of the primary state variables.  The state class must implement
+// these methods:
 //
 // void calculate_derivative(Derivative_Type& derivative, scalar absoluteTime);
 // void step(const Derivative_Type& derivative, scalar deltaTime);
@@ -118,12 +118,10 @@ inline D evaluate(S state,  scalar t, scalar dt, const D& derivative)
        return evaluate<S,D>(state, t + dt);
 }
 
-
 template <class S, class D>
 inline void euler(S& state, scalar t, scalar dt)
 {
        D a = evaluate<S,D>(state, t);
-
        state.step(a, dt);
 }
 
@@ -132,7 +130,6 @@ inline void rk2(S& state, scalar t, scalar dt)
 {
        D a = evaluate<S,D>(state, t);
        D b = evaluate<S,D>(state, t, dt * SCALAR(0.5), a);
-
        state.step(b, dt);
 }
 
@@ -143,8 +140,7 @@ inline void rk4(S& state, scalar t, scalar dt)
        D b = evaluate<S,D>(state, t, dt * SCALAR(0.5), a);
        D c = evaluate<S,D>(state, t, dt * SCALAR(0.5), b);
        D d = evaluate<S,D>(state, t, dt, c);
-
-       state.step((a + (b + c) * SCALAR(2.0) + d) * SCALAR(1.0/6.0), dt);
+       state.step((a + (b + c) * SCALAR(2.0) + d) * (SCALAR(1.0)/SCALAR(6.0)), dt);
 }
 
 
This page took 0.020394 seconds and 4 git commands to generate.