X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fmoof%2Fmath.hh;fp=src%2Fmoof%2Fmath.hh;h=e7cd3f03951f873c04ec37dcb3e02a91993f78e6;hp=14e8c78626acdb41bfedac1b8609e19d9588818b;hb=574af38ed616d1adfa5e6ce35f67cda1f707f89d;hpb=6c9943707d4f33035830eba0587a61a34eaecbc2 diff --git a/src/moof/math.hh b/src/moof/math.hh index 14e8c78..e7cd3f0 100644 --- a/src/moof/math.hh +++ b/src/moof/math.hh @@ -1,13 +1,11 @@ -/*] 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_ @@ -17,14 +15,15 @@ * General math-related types and functions. */ +#if HAVE_CONFIG_H #include "config.h" +#endif #include #include #include - #if ENABLE_DOUBLE_PRECISION typedef GLdouble GLscalar; #define GL_SCALAR GL_DOUBLE @@ -41,7 +40,6 @@ namespace moof { using namespace cml; - typedef GLscalar scalar; typedef vector< scalar, fixed<2> > vector2; @@ -52,11 +50,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 constants; - inline vector3 demote(const vector4& vec) { return vector3(vec[0], vec[1], vec[2]); @@ -90,10 +87,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 +115,10 @@ inline D evaluate(S state, scalar t, scalar dt, const D& derivative) return evaluate(state, t + dt); } - template inline void euler(S& state, scalar t, scalar dt) { D a = evaluate(state, t); - state.step(a, dt); } @@ -132,7 +127,6 @@ inline void rk2(S& state, scalar t, scalar dt) { D a = evaluate(state, t); D b = evaluate(state, t, dt * SCALAR(0.5), a); - state.step(b, dt); } @@ -143,7 +137,6 @@ inline void rk4(S& state, scalar t, scalar dt) D b = evaluate(state, t, dt * SCALAR(0.5), a); D c = evaluate(state, t, dt * SCALAR(0.5), b); D d = evaluate(state, t, dt, c); - state.step((a + (b + c) * SCALAR(2.0) + d) * SCALAR(1.0/6.0), dt); }