honestly, I don't see how object oriented programming would give you an advantage in solving a differential equation, and c++ is multi-paradigm, so it doesn't force you to use object oriented programming if it doesn't really fit your problem.
Assuming you are using some variant of the Runge-Kutta algorithm (or Euler's method, though I would recommend against that), I suppose you could make an object that contains the current position and velocity, and pointers or references that point to vectors containing the previous times, positions, velocities, etc. (you probably want to pre-allocate these), and a method that calculates the next position and velocity. You would also have a field for the time step, and a function pointer (or another object) that tells it how to calculate the derivatives at each time step. Actually, now that I think about it, you could make the method that calculates the next time step virtual, so that you could easily make subclasses that change the algorithm. I hope this points you in the right direction.
|