Game Development Reference
In-Depth Information
// First part of the method code listing not shown …
// Compute the drag coefficient, which depends on
// the Reynolds number.
double viscosity = 1.458e-6*Math.pow(temperature,1.5)/
(temperature + 110.4);
double Re = getDensity()*v*2.0*getRadius()/viscosity;
double cd;
if ( Re < 1.0e+5 ) {
cd = 0.47;
}
else if ( Re > 1.35e+5 ) {
cd = 0.22;
}
else {
cd = 0.47 - 0.25*(Re - 1.0e+5)/35000.0;
}
// Compute the total drag force and the directional
// drag components.
double Fd = 0.5*getDensity()*getArea()*cd*va*va;
double Fdx = -Fd*vax/va;
double Fdy = -Fd*vay/va;
double Fdz = -Fd*vaz/va;
// Evaluate the Magnus force terms.
double rotSpinRatio = Math.abs(getRadius()*getOmega()/v);
double Cl = 0.385*Math.pow(rotSpinRatio, 0.25);
double Fm = 0.5*getDensity()*getArea()*Cl*v*v;
double Fmx = (vy*getRz() - getRy()*vz)*Fm/v;
double Fmy = -(vx*getRz() - getRx()*vz)*Fm/v;
double Fmz = (vx*getRy() - getRx()*vy)*Fm/v;
// Compute the right-hand sides of the six ODEs.
dQ[0] = ds*(Fdx + Fmx)/getMass();
dQ[1] = ds*vx;
dQ[2] = ds*(Fdy + Fmy)/getMass();
dQ[3] = ds*vy;
dQ[4] = ds*(G + (Fdz + Fmz)/getMass());
dQ[5] = ds*vz;
return dQ;
}
}
Search WWH ::




Custom Search