# how to represent the effect of linking rigid-bodies together?

I have 2 rigid-bodies (b1,b2) if i linked one to the other (as if they are conjoined together) , how to represent b1 effect on b2 and b2 effect on b1 Is there any LAW that affect the position/orientation of the other body ?

notes :

• i am using Quaternions for orientations
• i don't want to treat them as one body
• i have only primitive shapes (box,sphere,..) to link.
• Why don't you just treat them as a single, large rigid body? – yohBS Jan 19 '12 at 22:35
• the idea that i am making a physics Engine that treats bodies as primitives (box,cone,sphere,..) . so if i treat them as a single rigid body ,i must add a new collision resolving logic for this new complex body – MhdSyrwan Jan 19 '12 at 22:49

The open-source physics engine ODE allows you to connect two bodies using any of a number of different joints. One of those joints is the "Fixed" joint. It's much more stable, in the physics engine, to represent the two bodies as a single body but maintain two separate geometries for collision purposes. However, ODE probably handles collision detection/resolution differently from what you have in mind. It only detects collision after one frame of interpenetration and then constrains the relative velocity of the colliding bodies in such a was as to force them apart on the next time step. That type of constraint is much easier to satisfy for a single rigid body than two, but perhaps you're actually preventing penetration and so need a different technique.

The fixed joint simply constrains the two bodies to have zero relative angular velocity and zero relative linear velocity (and also has an error correction term to eliminate small numerical drift). After that, the LCP solver handles the rest.

The laws you are looking for are conservation of momentum and conservation of angular momentum. If you stick the two bodies together both laws still must be fulfilled (inelastic effects neglected). In the end you will have a compound single object. With the parallel axis theorem (wikipedia) you can calculate the mass moment of inertia and together with the centre of mass the whole motion of your compound object. You do not have to change the collision logic completely, create a sphere/box that includes your whole object and use that to test for collisions.

An alternative to connect the two rigid bodies is via springs as dmckee pointed out and this approach is quite successful in a lot of physics engines (bridge building games, World of Goo). Even liquids can be modeled with a few hard drops connected via springs.

• i am not talking about collision detection, i am talking about collision resolution that depends on Contact Normal which will be changed , am i right ? – MhdSyrwan Jan 20 '12 at 22:36
• @MhdSyrwan: The contact normal will be changed, regardless of how you connect the bodies. For the calculation of the collision outcome conservation of momentum and angular momentum are good starting points. – Alexander Jan 21 '12 at 20:15
• i want to start form my working calculation logic for my primitives. – MhdSyrwan Jan 21 '12 at 20:51

If $\vec{p}$ the vector connecting the center of mass of b1 to the center of mass of b2 then you must have

$$\vec{v}_2 = \vec{v}_1 + \vec{\omega}_1 \times \vec{p} \\ \vec{\omega}_2 = \vec{\omega}_1$$

$$\vec{a}_2 = \vec{a}_1 + \vec{\alpha}_1 \times \vec{p} + \vec{\omega}_1 \times \vec{\omega}_1 \times \vec{p} \\ \vec{\alpha}_2 = \vec{\alpha}_1$$

In Real Life (tm) there are no Rigid Bodies (tm), and to first order (i.e. under low strain {*}) all solids act as a springs. The rule you are looking for is Hooke's Law: $$F = -k \Delta x .$$

Of course, that leaves the matter of choosing the right spring constants (and noting that everything doesn't ring for ever) the right damping as well.

You're almost certainly better figuring out how to treat compound bodies and single units than trying to do a finite element analysis (even drastically simplified) at every step.

{*} Note that materials life clay which deform easily are only under low strain for exceedingly small pressures, so this rule does not apply to them in a practical sense even if it is arguably good in the low strain limit.