[ODE] Approximate Hydrodynamic Forces

Ander Taylor ander_taylor at hotmail.com
Thu Apr 17 03:24:02 2003


Please disregarde the last post as I can see now that it was a bit stupid.

Now to my next act of ignorance:

Why should these bits of code give different results?

note: R contains the rotation matrix of the body

dBodyAddRelForce(body, 5*R[0], 0, 0);
dBodyAddRelForce(body, 0, 5*R[5], 0);
dBodyAddRelForce(body, 0, 0, 5*R[10]);

Should be the same as this:

dBodyAddForce(body, 5*R[0], 5*R[1], 5*R[2]);
dBodyAddForce(body, 5*R[4], 5*R[5], 5*R[6]);
dBodyAddForce(body, 5*R[8], 5*R[9], 5*R[10]);

Ander



Ander Wrote:

Hi David,

I have been doing some experimenting, and the code below behaves more 
realisticaly.

I must say that I don't understand why!

What do you think?

Ander

void BoxGeom::ApplyHydrodynamicForces(dReal viscosity)
{
    const dReal *lvel = dBodyGetLinearVel(this->_body->Id);
    const dReal *R = dBodyGetRotation(this->_body->Id);
    dReal ss[3];
    dGeomBoxGetLengths(this->_id, ss);

    dReal AreaX = ss[1]*ss[2];
    dReal AreaY = ss[0]*ss[2];
    dReal AreaZ = ss[0]*ss[1];

    dReal DotProdX = (R[0]*lvel[0]);  //this I don't understand.
    dReal DotProdY = (R[5]*lvel[1]);  //if I include all the terms
    dReal DotProdZ = (R[10]*lvel[2]); //things can fly off!

    dReal nx = AreaX * DotProdX;
    dReal ny = AreaY * DotProdY;
    dReal nz = AreaZ * DotProdZ;

    dReal temp = -nx*viscosity;
    dBodyAddRelForce(this->_body->Id, temp, 0, 0); //This I do!
    temp = -ny*viscosity;
    dBodyAddRelForce(this->_body->Id, 0, temp, 0);
    temp = -nz*viscosity;
    dBodyAddRelForce(this->_body->Id, 0, 0, temp);

}



_________________________________________________________________
MSN Instant Messenger now available on Australian mobile phones. Go to  
http://ninemsn.com.au/mobilecentral/hotmail_messenger.asp