[ODE] dMassSetCylinder() and dMassSetCone()

Patrik Stellmann patrik at volleynet.de
Thu Jul 24 01:09:02 2003


The formulars you can easily find with any search engine. I found for 
example:

http://scienceworld.wolfram.com/physics/MomentofInertiaCone.html
and
http://scienceworld.wolfram.com/physics/MomentofInertiaCylinder.html

transforming the formulars to c-code should be no problem!?

>[...]
>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));
>
here you're missing the r-square:
Ib = (M1*REAL(0.5)*aRad*aRad);

>[...]
>  m->_I(0,0) = Ia;
>  m->_I(1,1) = Ia;
>  m->_I(2,2) = Ia;
>  m->_I(direction-1,direction-1) = Ib;
>}
>