[ODE] dMassSetCylinder() and dMassSetCone()
Michael Bailey
mike-ba at cox.net
Wed Jul 23 16:56:02 2003
Hi All,
I'm trying to duplicate the ODE mass functions for a (non-capped) cylinder
and a cone. The ODE mass functions have a lot of strange constants when
calculating the "inertia matrix", of which I haven't a clue what's going on
there. Can anyone who understands what needs to be filled in the dMass
struct, check these out and give me some feedback?
Thanks in advance!
Mike
// A doctored version of the original ODE dMassSetCappedCylinder(), not sure
if the inertia matrix is right.
void dMassSetCylinder(dMass *m, dReal density, int direction, dReal aRad,
dReal bLen) {
dReal M1,Ia,Ib;
dAASSERT (m);
dUASSERT (direction >= 1 && direction <= 3,"bad direction number");
dMassSetZero (m);
M1 = M_PI*aRad*aRad*bLen*density; // cylinder mass
m->mass = M1;
Ia = M1*(REAL(0.25)*aRad*aRad + (REAL(1.0)/REAL(12.0))*bLen*bLen);
Ib = (M1*REAL(0.5));
m->_I(0,0) = Ia;
m->_I(1,1) = Ia;
m->_I(2,2) = Ia;
m->_I(direction-1,direction-1) = Ib;
}
// Have no clue what to do for the inertia matrix here!
void dMassSetCone(dMass *m, dReal density, int direction, dReal aBaseRad,
dReal bLen) {
dReal M1,Ia,Ib;
dAASSERT (m);
dUASSERT (direction >= 1 && direction <= 3,"bad direction number");
dMassSetZero (m);
M1 = ((M_PI*aBaseRad*aBaseRad*bLen)/REAL(3.0))*density; // cone mass
m->mass = M1;
// ?? I Have no idea how to set up the inertia matrix for a cone!
}