# [ODE] Re: center of mass

Guillaume Jouffroy oxymore at tele2.fr
Thu Oct 20 15:50:23 MST 2005

```This is quite a clear explanation ;-)

Now let me summarize things I know and what you told together to see if
I got things as they should.
If we virtually add a mass to each geom of a complex geom stuff;
orienting each geom with geomtransform
we need to do the same transformation to the mass as the mass position
wont follow (but where is the mass at start ?
cos we don't position it and we dont attach it... at 0,0,0 Am I right ?).
Summing the masses build up a center of masses of the complex object,
which is wherever placed.
Now we need to put a rigid body to be linked to all these geoms. This
rigidbody has to be at this center
of mass (why moving the geoms instead of the body ? strange), so we set
its position to the mass position
vector mass.c.
The example does moving geoms to this center of mass m:
for (k=0; k<2; k++) {
dGeomSetPosition (g2[k],
dpos[k][0]-m.c[0],
dpos[k][1]-m.c[1],
dpos[k][2]-m.c[2]);
}

But then it moves the center of mass ????
dMassTranslate (&m,-m.c[0],-m.c[1],-m.c[2]);

And there is something strange too: I can't draw the right geomtransform
geoms. Well I draw them but they do not move
with the object if I don't use the same drawGeom function of the example
i.e what is this for ? :
dGeomID g2 = dGeomTransformGetGeom (g);         // I do that
const dReal *pos2 = dGeomGetPosition (g2);           //that too
const dReal *R2 = dGeomGetRotation (g2);            //this as well

Then I think its sufficient but:
dVector3 actual_pos;           /* I don't do this strange transformation */
dMatrix3 actual_R;
dMULTIPLY0_331 (actual_pos,R,pos2);
actual_pos[0] += pos[0];
actual_pos[1] += pos[1];
actual_pos[2] += pos[2];
dMULTIPLY0_333 (actual_R,R,R2);
drawGeom (g2,actual_pos,actual_R,0);

Finally if I attach a joint to the rigidbody of a complex geoms object,
I don't have any idea how
the joint will be linked in reality between this complex object and
another rigidbody. Do you ?
To the closest geom virtually ?
```