Safer calculation of wheelSlipOpt.

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@6291 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: b3f32eb847806cd7d6e4747018f6eee69aeb6a14
Former-commit-id: 86818190869299dcae830446b6e20f7a8ced7d0e
This commit is contained in:
kakukri 2015-11-29 22:57:57 +00:00
parent aca8dfab70
commit 49afb9e126

View file

@ -155,15 +155,15 @@ SimWheelConfig(tCar *car, int index)
/* calculate optimal slip value */ /* calculate optimal slip value */
tdble s, Bx, low, high; tdble s, Bx, low, high;
int i; int i;
//wheel->mfC * atan(Bx * (1.0f - wheel->mfE) + wheel->mfE * atan(Bx)) //wheel->mfC * atan(Bx * (1.0f - wheel->mfE) + wheel->mfE * atan(Bx)) == PI/2
Bx = PI_2 / wheel->mfC; low = 0.0;
low = high = Bx; high = wheel->mfB;
while (wheel->mfC * atan(low * (1.0f - wheel->mfE) + wheel->mfE * atan(low)) > PI_2) {
low *= 0.9; if (wheel->mfC * atan(high * (1.0f - wheel->mfE) + wheel->mfE * atan(high)) < PI_2) {
} /* tire parameters are unphysical*/
while (wheel->mfC * atan(high * (1.0f - wheel->mfE) + wheel->mfE * atan(high)) < PI_2) { s = 1.0;
high *=1.1; GfLogWarning("Tire magic curve parameters are unphysical!");
} } else {
for (i = 0; i < 32; i++) { for (i = 0; i < 32; i++) {
Bx = 0.5 * (low + high); Bx = 0.5 * (low + high);
if (wheel->mfC * atan(Bx * (1.0f - wheel->mfE) + wheel->mfE * atan(Bx)) < PI_2) { if (wheel->mfC * atan(Bx * (1.0f - wheel->mfE) + wheel->mfE * atan(Bx)) < PI_2) {
@ -173,6 +173,7 @@ SimWheelConfig(tCar *car, int index)
} }
} }
s = 0.5 * (low + high) / wheel->mfB; s = 0.5 * (low + high) / wheel->mfB;
}
car->carElt->_wheelSlipOpt(index) = s; car->carElt->_wheelSlipOpt(index) = s;
} }