[ODE] Atmosphere friction?
Ander Taylor
ander_taylor at hotmail.com
Mon Jul 7 05:45:02 2003
void BoxGeom::ApplyHydrodynamicForces(dReal viscosity)
{
const dReal *lvel = dBodyGetLinearVel(this->_body->Id);
const dReal *avel = dBodyGetAngularVel(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 nx = (R[0] * lvel[0] + R[4] * lvel[1] + R[8] * lvel[2]) * AreaX;
dReal ny = (R[1] * lvel[0] + R[5] * lvel[1] + R[9] * lvel[2]) * AreaY;
dReal nz = (R[2] * lvel[0] + R[6] * lvel[1] + R[10] * lvel[2]) * AreaZ;
dReal temp = -nx * viscosity;
dBodyAddForce(this->_body->Id, temp * R[0], temp * R[4], temp * R[8]);
temp = -ny * viscosity;
dBodyAddForce(this->_body->Id, temp * R[1], temp * R[5], temp * R[9]);
temp =-nz * 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]) * AreaZ;
ny = (R[1] * avel[0] + R[5] * avel[1] + R[9] * avel[2]) * AreaX;
nz = (R[2] * avel[0] + R[6] * avel[1] + R[10] * avel[2]) * AreaY;
temp = -nx * viscosity * 500;
dBodyAddTorque(this->_body->Id, temp * R[0], temp * R[4], temp * R[8]);
temp = -ny * viscosity * 500;
dBodyAddTorque(this->_body->Id, temp * R[1], temp * R[5], temp * R[9]);
temp = -nz * viscosity * 500;
dBodyAddTorque(this->_body->Id, temp * R[2], temp * R[6], temp * R[10]);
}
The above code basically finds the speed that each front face is moving
along its own normal and then applys a counter acting force based on the
face's area and the medium's viscosity. It works very well.
I have a demo that I can e-mail you if you would like.
Cheers,
Ander
----Original Message Follows----
Yes, thanks. But may be another way? Damping velocity is not right way,
imho. It's feeling like patch :)
_________________________________________________________________
Hotmail is now available on Australian mobile phones. Go to
http://ninemsn.com.au/mobilecentral/signup.asp