Constraints Derivation for Rigid Body Simulation in 3D

Please don't post Bullet support questions here, use the above forums instead.
Post Reply
Dani3L
Posts: 28
Joined: Tue Jun 30, 2009 6:56 am
Location: Switzerland
Contact:

Constraints Derivation for Rigid Body Simulation in 3D

Post by Dani3L »

Hello. I have been using this forum for many years now and I have learned so many things here. Now, it's my turn to share.

During the development of my 3D physics library, I had to model different constraints like contacts, friction and some joints between rigid bodies. I'm using a Sequential Impulses solver as described in Erin Catto's presentation at GDC. As you probably know, we need to compute the Jacobian matrix J, the effective mass matrix K and also the bias velocity vector b for each type of constraint. In Erin's presentation, contact and friction are well explained but sometimes it is difficult to find the derivation of those quantities for others constraints like joints in 3D. Since I had to derive those constraints for my physics library, I have written a document that gives the details of the calculations.

Here is the list of the constraints that are covered in this document:

- Contact and Friction
- Ball-And-Socket joint
- Slider joint (with motor and limits)
- Hinge joint (with motor and limits)
- Fixed joint

You can download the document here.

I hope it will be useful. Do not hesitate to let me know if you find something wrong.

----------
Daniel Chappuis
Switzerland
http://www.danielchappuis.ch
RandyGaul
Posts: 43
Joined: Mon May 20, 2013 8:01 am
Location: Redmond, WA

Re: Constraints Derivation for Rigid Body Simulation in 3D

Post by RandyGaul »

Wow this paper looks very professional, and the information seems great. I just wanted to say thanks for making a public contribution. Very helpful for others studying the same information!

I noticed that your slider joint contains the Jacobian of: [-t, -((r1 + u) x t), t, (r2 x t)]

Although a valid jacobian one body is not getting any recognition of the u vector. Since the angular terms aren't symmetric the Jacobian is basically assuming that one of the bodies doesn't change orientation. To come to a Jacobian with symmetric angular terms (for ease of use) one could redefine the velocity to be in terms of the slider axis itself, yielding a Jacobian:

[-t, -(t x c) / 2, t, (t x c) / 2]

Where c is r2 - r1, or the slider axis between each anchor point. Does this make any sense?
Dani3L
Posts: 28
Joined: Tue Jun 30, 2009 6:56 am
Location: Switzerland
Contact:

Re: Constraints Derivation for Rigid Body Simulation in 3D

Post by Dani3L »

RandyGaul wrote: I noticed that your slider joint contains the Jacobian of: [-t, -((r1 + u) x t), t, (r2 x t)]

Although a valid jacobian one body is not getting any recognition of the u vector. Since the angular terms aren't symmetric the Jacobian is basically assuming that one of the bodies doesn't change orientation. To come to a Jacobian with symmetric angular terms (for ease of use) one could redefine the velocity to be in terms of the slider axis itself, yielding a Jacobian:

[-t, -(t x c) / 2, t, (t x c) / 2]

Where c is r2 - r1, or the slider axis between each anchor point. Does this make any sense?
Hello. Thanks for your answer. Actually, I think this is because my vectors n1 and n2 are world-space vectors computed from a slider axis
vector that is stored in the local-space of body 1. This was not explained very well in document and I have updated it. Therefore, I think the angular terms seem to be asymmetric in the Jacobian matrix because they are defined with respect to body 1.

Consider p1 and p2 the world-space positions of the anchor points. We have:

u = p2 - p1 = x2 + r2 - x1 - r1

Therefore, we have:

Angular term of body 1 : -((r1 + u) x n1) = -((p2 - x1) x n1)
Angular term of body 2 : (r2 x n1) = ((p2 - x2) x n1)

which looks much more symmetric. I think it is also the way the Prismatic joint constraint has been derived in Box2D as you can see here.
Post Reply