I want to implement a simple particules system using the velocity form of the Verlet algorithm as integrator.

Initial conditions at $t=0$ for a given particule $p$:

  • mass: $ m $
  • position: $\overrightarrow x(t=0) = \overrightarrow x_0$
  • velocity: $\overrightarrow v(t=0) = \overrightarrow v_0$
  • forces applied to it: $ \overrightarrow F(t=0) = \overrightarrow F_0 $

Algorithm's recipe says:

  1. Calculate: $\overrightarrow v(t+\frac{1}{2}\Delta t) = \overrightarrow v(t) + \frac{1}{2}\overrightarrow a(t)\Delta t$
  2. Calculate: $\overrightarrow x(t+\Delta t) = \overrightarrow x(t) + \overrightarrow v(t+\frac{1}{2}\Delta t) \Delta t$
  3. Derive: $\overrightarrow a(t+\Delta t)$ from the interaction potential using $\overrightarrow x(t+\Delta t)$
  4. Calculate: $\overrightarrow v(t+\Delta t) = \overrightarrow v(t + \frac{1}{2}\Delta t) + \frac{1}{2}\overrightarrow a(t+\Delta t)\Delta t$

Let's apply it in order to find $\overrightarrow x(t=1)$ and $\overrightarrow v(t=1)$, so with $\Delta t = 1$:

  1. $\overrightarrow v(0+\frac{1}{2}1) = \overrightarrow v(0) + \frac{1}{2}\overrightarrow a(0)1 = \overrightarrow v_0 + \frac{1}{2}\frac{\overrightarrow F_0}{m}$ [OK using Newton's second law]
  2. $\overrightarrow x(0+1) = \overrightarrow x(0) + \overrightarrow v(0+\frac{1}{2}1) 1 = \overrightarrow x_0 + (1.)$ [OK using previous result (1.)]
  3. ???
  4. $\overrightarrow v(0+1) = \overrightarrow v(0 + \frac{1}{2}1) + \frac{1}{2}\overrightarrow a(0+1)1 = (1.) + \frac{1}{2}(3.)$ [OK using (1.) and (3.)]


So I'm stuck with (3.)

I have to calculate $\overrightarrow a(0+1)$ but I don't know how... I can't apply Newton's second law here since I don't know $\overrightarrow F(t=1)$. Algorithm says "from the interaction potential using (1.)" but I don't understand what it means...

Can you help?

Thank you

| cite | improve this question | | | | |

I think you all your steps are correct, I would suggest adding units though, otherwise adding $\vec{x}$ and $\vec{v}$ can be misleading.

For step 3. You can just calculate $a = F/m$, where $F$ can either be gravitation $F=m g$, so it does not depend on $x$, or for example for a spring dependent on $x$, so $F = -k x$, here you need the next position from step 2.

| cite | improve this answer | | | | |
  • $\begingroup$ For step 3., I'm at $t=0$ and I'm calculating $\overrightarrow a(t+1)$ eg $\overrightarrow a(1)$. I only know $\overrightarrow F_{t=0}$ not $\overrightarrow F_{t=1}$ so like I was saying, I can't apply Newton's second law $\overrightarrow a(1) = \overrightarrow F_1/m$ since I don't have $\overrightarrow F_1$... $\endgroup$ – abernier Aug 17 '12 at 9:13
  • $\begingroup$ It depends on your potential, so as an example for a spring $F(1) = -k x(1)$, which you can use to calculate $a(1)$. The next position $x(1)$ comes from your second step. $\endgroup$ – Alexander Aug 17 '12 at 13:42
  • $\begingroup$ But what if I can't have $F(1)$ for example in my case $F(t)$ depends on a user's interaction, eg: drag with mouse — so I cannot predict $F(1)$ when at $t = 0$ It's not a spring, or maybe it could be, but dragged by a crazy user with a mouse in his hand so I cannot have $k$ in advance. $\endgroup$ – abernier Aug 17 '12 at 23:15
  • $\begingroup$ @abernier: You always need to know the conditions beforehand, so I think there is no way your simulation lags 1 frame behind the user input. Maybe our game development partner site has more input on this. $\endgroup$ – Alexander Aug 18 '12 at 19:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.