[ODE] Re: center of mass
Nagymathe Denes
denes at invictus.hu
Thu Oct 20 09:50:02 MST 2005
Hi,
1. the body will be where you set its position. But if you want the compound
to move as it should (see 2), it's your job to place the body where the CM
of the system is. But to help doing so, dMassAdd calculates the necessary
position and stores that vector in mass.c (see 3)
2. Geoms do not have any mass, only bodies, so this is up to you. If you
think them as some homogeneous material, you can set dMass-es for them by
dMassSet* methods, but it's only for your convenience. But for example you
can also create a body with the mass properties of a box, and attach a
sphere geom to it with different position for collision. It will move as an
invisible heavy box built into a lightweight sphere. or sg. like that. :o)
3. yes, and see above. if you watch the example in text_boxstack, it creates
a dMass 'accumulator', and dMassAdd()-s the translated and rotated dMass-es
of the geoms to it. At the end, the 'accumulator' dMass contains the
position where you should place the body, BUT as in the example the 3 geoms
are encapsulated into geomtransforms, and the positions in the masses were
set relative to the _intended_ center (just like the geom positions), the
position in the accumulated mass is also relative to that intended position.
So as the body must have the CM in its center, the dMass has to be 'reseted'
(that's the last line you've included), and also either the geoms or the
body itself has to be moved with this relative position vector calculated in
the accumulated mass to match the positions. The text_boxstack example does
the former option.
4. see 3 :o)
Denes
More information about the ODE
mailing list