[ODE] Approximate Hydrodynamic Forces Demo

Ander Taylor ander_taylor at hotmail.com
Tue Apr 22 04:30:02 2003


Hi Ted here is the code so far.

void BoxGeom::ApplyHydrodynamicForces(dReal linear_viscosity, dReal 
angular_viscosity, dReal density, Vector3 flow)
    {
        const dReal *lvel = dBodyGetLinearVel(this->_body->Id);
        const dReal *avel = dBodyGetAngularVel(this->_body->Id);
        const dReal *R = dBodyGetRotation(this->_body->Id);

        dVector3 compFlow;
        compFlow[0] = lvel[0] - flow.x;
        compFlow[1] = lvel[1] - flow.y;
        compFlow[2] = lvel[2] - flow.z;

        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 nx = (R[0] * compFlow[0] + R[4] * compFlow[1] + R[8] * 
compFlow[2]) * AreaX;
        dReal ny = (R[1] * compFlow[0] + R[5] * compFlow[1] + R[9] * 
compFlow[2]) * AreaY;
        dReal nz = (R[2] * compFlow[0] + R[6] * compFlow[1] + R[10] * 
compFlow[2]) * AreaZ;

        dReal temp = -nx*linear_viscosity;
        dBodyAddForce(this->_body->Id, temp*R[0], temp*R[4], temp*R[8]);

        temp = -ny*linear_viscosity;
        dBodyAddForce(this->_body->Id, temp*R[1], temp*R[5], temp*R[9]);

        temp = -nz*linear_viscosity;
        dBodyAddForce(this->_body->Id, temp*R[2], temp*R[6], temp*R[10]);

        nx = (R[0] * avel[0] + R[4] * avel[1] + R[8] * avel[2]) * (AreaY + 
AreaZ);
        ny = (R[1] * avel[0] + R[5] * avel[1] + R[9] * avel[2]) * (AreaX + 
AreaZ);
        nz = (R[2] * avel[0] + R[6] * avel[1] + R[10] * avel[2]) * (AreaX + 
AreaY);

        temp = -nx * angular_viscosity;
        dBodyAddTorque(this->_body->Id, temp * R[0], temp * R[4], temp * 
R[8]);

        temp = -ny * angular_viscosity;
        dBodyAddTorque(this->_body->Id, temp * R[1], temp * R[5], temp * 
R[9]);

        temp = -nz * angular_viscosity;
        dBodyAddTorque(this->_body->Id, temp * R[2], temp * R[6], temp * 
R[10]);

        dReal gravity[3];
        dWorldGetGravity(this->_body->get_WorldId(), gravity);

        temp = -density * ss[0] * ss[1] * ss[2];
        dBodyAddForce(this->_body->Id, temp*gravity[0], temp*gravity[1], 
temp*gravity[2]);

        //which, unless you have a non-axis-aligned gravity, is probably 
just:
        //dBodyAddForce(body, 0, temp*gravity[1], 0);

    }


Ander



Ted Wrote:

Hey Ander, did you catch this post?  It's the only thing holding me back
from getting this thing working.

Ted

On Mon, Apr 21, 2003 at 03:18:59AM +0000, Ander Taylor wrote:
 >
 >   It is written in VB.Net using  a  modified wrapper I got from Jeff
 >   Weber.  David Wittaker helped alot with the method of applying the
 >   forces.  The Graphics are supplied by the great TrueVision3D.

Could you post the revised ApplyHydrodynamicForces() function?  The one
called in the source doesn't match the function you posted in the other
thread.  There are more parameters in this call that aren't taken into
account in that function.

Thanks,
Ted


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