|
![](/i/fill.gif) |
> But what do you do if the forces acting on a particle depend on the
> positions of the other particles? o_O
The fact that you are even asking that question makes me think you are
implementing RK4 incorrectly. The whole point of RK4 is that it gives more
accurate results when the forces depend on positions of other particles (eg
springs, collisions etc).
I suspect you are trying to apply the whole RK4 algorithm to one particle,
then the next, etc. This is wrong.
You need to store the positions and velocities of all the particles together
in one "state" object. Then you apply each step of RK4 on the whole state
at once. If you need the positions of other particles when calculating the
force, then of course you have all the position and velocity information
available in the state local to the current RK4 step.
Post a reply to this message
|
![](/i/fill.gif) |