]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/RK4.hh
minor cleanups
[chaz/yoink] / src / Moof / RK4.hh
similarity index 83%
rename from src/Moof/Physics.hh
rename to src/Moof/RK4.hh
index a79a5c3604b8b88c66b2a63039c5bc8d8d57db9c..a2e0f1cbe713c62e0eb9b6267c2b2febaecd065a 100644 (file)
@@ -26,8 +26,8 @@
 
 *******************************************************************************/
 
-#ifndef _MOOF_PHYSICS_HH_
-#define _MOOF_PHYSICS_HH_
+#ifndef _MOOF_RK4_HH_
+#define _MOOF_RK4_HH_
 
 #include <Moof/Math.hh>
 
 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<typename S, typename D>
 inline D evaluate(const S& state, Scalar t)
@@ -62,14 +71,13 @@ inline void integrate(S& state, Scalar t, Scalar dt)
        D c = evaluate<S,D>(state, t, dt * 0.5, b);
        D d = evaluate<S,D>(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: *************************************************/
 
This page took 0.021592 seconds and 4 git commands to generate.