[ODE] Re: dCylinder

Olivier Michel Olivier.Michel at cyberbotics.com
Wed Feb 5 01:27:02 2003


Russ Smith wrote:

>>I didn't implemented it. I used the contribution of Konstantin 
>>Slipchenko and I fixed a few issues (Konstantin gave me its latest 
>>version which compiles with the new collision detection system of ODE 
>>0.035, and I added a function for Cylinder - Ray collision detection 
>>which was missing). All what I have is here. I would like to be able
>>to commit it in the CVS repository, but I have no rights do do it,
>>anyone could help ?
>>    
>>
>yes ... i've updated ODE's contrib/dCylinder directory with your newer
>code. thanks.
>
Great. Thanks.

>>By the way, I would like to contribute a dMassSetCylinder. I currently
>>use the dMassSetCappedCylinder, but I assume it is a wrong
>>approximation for a normal Cylinder.
>>    
>>
>yes, it's not exact for a cylinder, especially one that has a short
>length (i.e. almost a sphere). however many simulations will not care
>about the difference (it looks almost the same either way). anyhow, if
>you write dMassSetCylinder() it can be added to mass.cpp along with the
>other mass functions.
>
Yes I wrote it, here is it. I will let you add it to the mass.cpp file:

PROTOTYPE:

void dMassSetCylinder(dMass *m,dReal density,dReal radius,dReal length);

FUNCTION: (it uses the #define _I(i,j) I[(i)*4+(j)] of mass.cpp)

void dMassSetCylinder(dMass *m,dReal density,dReal radius, dReal length) {
  dReal M,r2,I;
  dAASSERT(m);
  dMassSetZero(m);
  r2=radius*radius;
  M = M_PI*r2*length*density; // cylinder mass
  m->mass = M;
  I = M*(REAL(0.25)*r2 + (REAL(1.0)/REAL(12.0))*length*length);
  m->_I(0,0) = I;
  m->_I(1,1) = M*REAL(0.5)*r2;
  m->_I(2,2) = I;
# ifndef dNODEBUG
  checkMass (m);
# endif
}

-Olivier