Clamping forces magnitudes

Please don't post Bullet support questions here, use the above forums instead.
neodelphi
Posts: 8
Joined: Sun Aug 05, 2007 6:20 pm

Clamping forces magnitudes

Post by neodelphi »

Hello,

I'm writing a little physic engine in 2D. I handle collisions with constraints at contact points. Most of time it seems to work well, but I found one case which makes troubles ; consider two boxes :

Code: Select all

          +------------------+
           |                         |
           |        box   2     |
           |                         |
           |               B        |
          +------------+----+------------+
                              |      A                 |
                              |                         |
                              |       box 1        |
                              |                         |
                             +------------------+

the box 1 is fixed to the background (invMass = 0, invIntertia = 0). Before this moment, the box 2 was falling due to the gravity. When collision happens, my detection algorithm find two contacts :
- at point A, normal = (0; +1)
- at point B, normal = (0; -1)

Normally, the box 2 should be blocked and starting to rotate counter-clockwise. Contact B should remain.

However, I don't get the expected behavior ; in my simulation the box 2 jumps vertically and rotates !

I checked for my constraints matrix J, which seems to be good. The system is also well solved. The forces magnitudes computed are :

lambdas = [ 14.7 ]
[ -6.42 ]

The negative value indicate that the contact A has no effect on the boxes, since it is a inequality constraint. My lambdas are clamped, so finally :

lambdas = [ 14.7 ]
[ 0 ]

I tried to remove the clamping operation, the result is that the box 2 stops and both contacts remains like if the box 2 was soldered to the box 1 (which is OK). I think there is a mistake somewhere. Is it correct to clamp the forces after solving the constraints system ?

Thx for your support.[/code]
neodelphi
Posts: 8
Joined: Sun Aug 05, 2007 6:20 pm

Hi again

Post by neodelphi »

Hi, it's me again...

I understood a few things since last time, so I tried to modify my Gauss-Seidel function. Now I clamp the result vector after each iteration. It's seems to work better for the example I gave above. Is it correct to proceed like this ?