[ODE] RE: Angular acceleration from torque

slipch slipch <slipch at gsc-game.kiev.ua>
Thu Mar 6 08:30:02 2003


Hello Ruud,

Thursday, March 6, 2003, 11:44:22 AM, you wrote:

RvG> Hi,

RvG> Following a couple of messages lately I've formed this function to calculate
RvG> angular acceleration from input torque. There's something wrong with it, but
RvG> who can tell what?

RvG> void dBodyAngAccelFromTorque(const dBodyID body,dReal *angAccel,
RvG>   const dReal *torque)
RvG> // Calculate angular acceleration from the torque
RvG> {
RvG>   dMass m;
RvG>   dMatrix3 invI,invI1,local_invI;
RvG>   const dReal *R;

RvG>   // Get inverted inertia matrix
RvG>   dBodyGetMass(body,&m);
RvG>   dInvertPDMatrix(m.I,invI,3);

RvG>   // Convert global into local coordinates
RvG>   R=dBodyGetRotation(body);
RvG>   dMULTIPLY2_333(invI1,invI,R);
RvG>   dMULTIPLY1_333(local_invI,R,invI1);

RvG>   // Not right!
RvG>   //dMULTIPLY1_333(angAccel,local_invI,torque);
RvG> }

RvG> Problem is I don't know what all the dMULTIPLY's do exactly; somebody
RvG> suggest the upper half, then stated that the invI matrix is still in global
RvG> coords, to be converted into local ones. Not sure how to put the pieces
RvG> together.

Indeed I stated that  invI is in local and we need it in global.
To do it: global_invI=R * invI * invR. invR is transposed R (it is not
right for I and invI so we use  dInvertPDMatrix).
The code seems to be right except  local_invI means global_invI and
the last statement  dMULTIPLY1_333(angAccel,local_invI,torque) is
wrong it must be   dMULTIPLY1_331(angAccel,local_invI,torque).

Please, tell me if you find that it works or not.



-- 
Best regards,
 slipch                            mailto:slipch@gsc-game.kiev.ua