[ODE] Approximate Hydrodynamic Forces

Ander Taylor ander_taylor at hotmail.com
Wed Apr 16 06:45:02 2003


I gave it a try.

First off it exploded, it seems it was the fabs()'s.

The axis problem is fixed.

Not the other problem. That is, a Box 200L by 200W by 10H set at 45 degrees 
to the floor and falling under gravity will move sideways toward it's 
highest edge not the lowest edge as you would expect.

Cheers,

Ander


David Wrote:

I gave the docs another look and it looks like I did get the l, w, and h
out of order... so give this a try:

const dReal *lvel = dBodyGetLinearVelocity(body);
const dReal *R = dBodyGetRotation(body);
dReal ss[3];
dGeomBoxGetLengths(geom, ss);

dReal nx = ss[1]*ss[2] * fabs(R[0]*lvel[0] + R[1]*lvel[1] + R[2]*lvel[2]);
dReal ny = ss[0]*ss[2] * fabs(R[4]*lvel[0] + R[5]*lvel[1] + R[6]*lvel[2]);
dReal nz = ss[0]*ss[1] * fabs(R[8]*lvel[0] + R[9]*lvel[1] +R[10]*lvel[2]);

//either this....
dReal temp = -nx*scale;
dBodyAddForce(body, temp*R[0], temp*R[1], temp*R[2]);
temp = -ny*scale;
dBodyAddForce(body, temp*R[4], temp*R[5], temp*R[6]);
temp = -nz*scale;
dBodyAddForce(body, temp*R[8], temp*R[9], temp*R[10]);

//this might actually work now with the fabs()'s (may need to adjust scale):
dReal temp = -scale*(nx+ny+nz);
dBodyAddForce(body, temp*lvel[0], temp*lvel[1], temp*lvel[2]);


Let me know how that works for you.

David

P.S. You may need a tiny bit more code for a really good simulation... you
need to simulate bouyancy (force of buoyancy = weight of displaced fluid =
density of fluid * volume of object * gravity):

dMass m;
dBodyGetMass(body, &m);
dReal gravity[3];
dWorldGetGravity(world, gravity);
//ss, temp already defined above

temp = -fluidDensity * ss[0] * ss[1] * ss[2];
dBodyAddForce(body, 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);

Note that this method assumes the body is completely submerged in the
fluid.  A more generic solution is not all that complicated, I just
haven't thought it out yet.

Hmmm, now I'm starting to get more ideas about a 6 dof rolling friction
contact joint and a 3 dof drag joint that could be integrated into the
collision system... If only there were more hours in the day.  Good night
all.


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