X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FRK4.hh;fp=src%2FMoof%2FPhysics.hh;h=a2e0f1cbe713c62e0eb9b6267c2b2febaecd065a;hp=a79a5c3604b8b88c66b2a63039c5bc8d8d57db9c;hb=d50942708db230dc5c43b8df89ede45525e1c394;hpb=57b78ebe21b1b48acd337daa5a1cb8c383959cfa diff --git a/src/Moof/Physics.hh b/src/Moof/RK4.hh similarity index 83% rename from src/Moof/Physics.hh rename to src/Moof/RK4.hh index a79a5c3..a2e0f1c 100644 --- a/src/Moof/Physics.hh +++ b/src/Moof/RK4.hh @@ -26,8 +26,8 @@ *******************************************************************************/ -#ifndef _MOOF_PHYSICS_HH_ -#define _MOOF_PHYSICS_HH_ +#ifndef _MOOF_RK4_HH_ +#define _MOOF_RK4_HH_ #include @@ -35,7 +35,16 @@ namespace Mf { // Generic implementation of the RK4 integrator. To use, you need one type -// representing the state and another containing the derivatives of the state. +// representing the state and another containing the derivatives of the primary +// state variables. The state class must implement these methods: +// +// void getDerivative(Derivative_Type& derivative, Scalar absoluteTime); +// void applyDerivative(const Derivative_Type& derivative, Scalar deltaTime); +// +// Additionally, the derivative class must overload a few operators: +// +// Derivative_Type operator+(const Derivative_Type& other) const +// Derivative_Type operator*(const Derivative_Type& other) const template inline D evaluate(const S& state, Scalar t) @@ -62,14 +71,13 @@ inline void integrate(S& state, Scalar t, Scalar dt) D c = evaluate(state, t, dt * 0.5, b); D d = evaluate(state, t, dt, c); - //state += (a + (b + c) * 2.0 + d) * (1.0/6.0) * dt; state.applyDerivative((a + (b + c) * 2.0 + d) * (1.0/6.0), dt); } } // namespace Mf -#endif // _MOOF_PHYSICS_HH_ +#endif // _MOOF_RK4_HH_ /** vim: set ts=4 sw=4 tw=80: *************************************************/