+ no_roll = prev->getOn_ground();
+ }
+}
+
+double FGAIAircraft::calcVerticalSpeed(double vert_ft, double dist_m, double speed, double err)
+{
+ // err is negative when we passed too high
+ double vert_m = vert_ft * SG_FEET_TO_METER;
+ double err_m = err * SG_FEET_TO_METER;
+ //double angle = atan2(vert_m, dist_m);
+ double speedMs = (speed * SG_NM_TO_METER) / 3600;
+ //double vs = cos(angle) * speedMs; // Now in m/s
+ double vs = 0;
+ //cerr << "Error term = " << err_m << endl;
+ if (dist_m) {
+ vs = ((vert_m) / dist_m) * speedMs;
+ }
+ // Convert to feet per minute
+ vs *= (SG_METER_TO_FEET * 60);
+ //if (getCallSign() == "LUFTHANSA2002")
+ //if (fabs(vs) > 100000) {
+// if (getCallSign() == "LUFTHANSA2057") {
+// cerr << getCallSign() << " " << fp->getPreviousWaypoint()->getName() << ". Alt = " << altitude_ft << " vertical dist = " << vert_m << " horiz dist = " << dist_m << " << angle = " << angle * SG_RADIANS_TO_DEGREES << " vs " << vs << " horizontal speed " << speed << "Previous crossAT " << fp->getPreviousWaypoint()->getCrossat() << endl;
+// //= (curr->getCrossat() - altitude_ft) / (fp->getDistanceToGo(pos.getLatitudeDeg(), pos.getLongitudeDeg(), curr)
+// // / 6076.0 / speed*60.0);
+// //raise(SIGSEGV);
+// }
+ return vs;
+}
+
+void FGAIAircraft::assertSpeed(double speed)
+{
+ if ((speed < -50) || (speed > 1000)) {
+ cerr << getCallSign() << " "
+ << "Previous waypoint " << fp->getPreviousWaypoint()->getName() << " "
+ << "Departure airport " << trafficRef->getDepartureAirport() << " "
+ << "Leg " << fp->getLeg() << " "
+ << "target_speed << " << tgt_speed << " "
+ << "speedFraction << " << speedFraction << " "
+ << "Currecnt speed << " << speed << " "
+ << endl;
+ //raise(SIGSEGV);