Advertisement

Box2D-lite Sequential Impulse misunderstanding

Started by January 18, 2025 06:18 PM
3 comments, last by fractali 2 weeks ago

Hi, I was reviewing some of the solver theory and am a bit confused about how Sequential Impulse works with contacts. I have a working constraint solver, but still would like to understand the theory a bit better.

In the [paper](https://box2d.org/files/ErinCatto_IterativeDynamics_GDC2005.pdf), we see in the time stepping section the equation we want to solve using PGS.

I understand this derivation. How the terms translate to the code we need slightly confuses me. I'm using the Box2D lite code as a reference: https://github.com/erincatto/box2d-lite/blob/master/src/Arbiter.cpp

My original understanding was that:
 

: the bias. This is clearly computed on 109. and multiplied by 1/dt.

The equation inside the brackets is the updated velocity that we compute before the solver step using the latest external forces. J computes the initial separating velocity (For contacts), which is done in every iteration of the solver, which works with Gauss seidel when solving for JB\lambda. I don't understand why the 1/dt isn't ever applied in the code to the separating velocity. It seems to be only applied to the bias term, but shouldn't it be also applied to the initial separating velocity term?

Any clarification would be really appreciated. On a side note, if anyone has some good resources for understanding the theory solvers in physics engines, that would be appreciated!

 

My best guess so far is the actual algorithm deals with impulse, so dt * Acceleration + V_1 = V2 isn't what we substitute in F = MA, instead, we deal with Impulse = M * (V2 - V1), which removes the need for a delta T variable in the algorithm.

Erin Catto's talk: https://box2d.org/files/ErinCatto_ModelingAndSolvingConstraints_GDC2009.pdf, states: “Given the time step, impulse and force are interchangeable.”, which means that we can use the identity M * Delta_V = J Lambda, instead of M Acceleration.

Advertisement

Correct, in these models forces and impulses are linearly related. There are basically two ways to think about this:

  1. As you correctly state basically start from Newton in impulse form
  2. J*W*JT * lambda dt = … → Substiture lambda dt with lambda_impulse

For solver understanding the more important step is how to get from PGS to Sequential Impulses. Sequential Impulses is equivalent to PGS. It is basically just a method to implement PGS. You need to carefully step to PGS to see that you it is basically just applying impulses.

For references I recommend everything from Erin. And as a project make a 3D version of Box2D Lite. I currently have an associate physics programmer which is studying the same things and she liked these videos:

https://www.youtube.com/@kavanl1/videos

I haven't checked those myself yet though.

HTH and good luck!

Thanks, Dirk, I appreciate the response. That aspect of sequential impulse confused me for some time. I'll take a look at those videos, they seem informative. I'm also looking at one of the Hairer texts you linked in the Bullet forum a while back (https://www.unige.ch/~hairer/poly-sde-mani.pdf).

I have a working 3D Physics library using PGS. I wanted to review/clarify the theory before tackling TGS. Thanks again 🙂

Advertisement