double DistPlane = d0 * DotProduct(u, iter->normal) / length;
// The coordinate of the point of intersection 'P' between the circle and
// the ground is (0, DistPlane, alpha) in the basis (u, v, t)
- double alpha = sqrt(sqrRadius - DistPlane * DistPlane);
+ double mag = sqrRadius - DistPlane * DistPlane;
+ if (mag < 0) {
+ cout << "FGTrim::calcRotation DistPlane^2 larger than sqrRadius" << endl;
+ }
+ double alpha = sqrt(max(mag, 0.0));
FGColumnVector3 CP = alpha * t + DistPlane * v;
// The transformation is now constructed: we can extract the angle using the
// classical formulas (cosine is obtained from the dot product and sine from
double dist = SGGeodesy::distanceNm(dep->geod(), arr->geod());
double remainingTimeEnroute = (*i)->getArrivalTime() - (*i)->getDepartureTime();
- double speed = dist / (remainingTimeEnroute/3600.0);
+ double speed = 0.0;
+ if (remainingTimeEnroute > 0.01)
+ speed = dist / (remainingTimeEnroute/3600.0);
+
SG_CLAMP_RANGE(speed, 300.0, 500.0);
return speed;
}