diff --git a/src/AIModel/AIFlightPlanCreate.cxx b/src/AIModel/AIFlightPlanCreate.cxx index 3522c30ae..625048e36 100644 --- a/src/AIModel/AIFlightPlanCreate.cxx +++ b/src/AIModel/AIFlightPlanCreate.cxx @@ -1,56 +1,43 @@ -/****************************************************************************** - * AIFlightPlanCreate.cxx - * Written by Durk Talsma, started May, 2004. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - **************************************************************************/ +/* + * SPDX-FileName: AIFlightPlanCreate.cxx + * SPDX-FileCopyrightText: Written by Durk Talsma, started May, 2004 + * SPDX-License-Identifier: GPL-2.0-or-later + */ #ifdef HAVE_CONFIG_H -# include +#include #endif #include -#include #include +#include -#include "AIFlightPlan.hxx" #include #include #include #include #include -#include #include #include +#include -#include "AIAircraft.hxx" -#include "performancedata.hxx" -#include "VectorMath.hxx" - -#include
-#include #include +#include #include +#include
#include #include +#include "AIAircraft.hxx" +#include "AIFlightPlan.hxx" +#include "VectorMath.hxx" +#include "performancedata.hxx" + using std::string; + /* FGAIFlightPlan::create() * dynamically create a flight plan for AI traffic, based on data provided by the * Traffic Manager, when reading a filed flightplan fails. (DT, 2004/07/10) @@ -61,20 +48,20 @@ using std::string; // Check lat/lon values during initialization; -bool FGAIFlightPlan::create(FGAIAircraft * ac, FGAirport * dep, - FGAirport * arr, int legNr, double alt, +bool FGAIFlightPlan::create(FGAIAircraft* ac, FGAirport* dep, + FGAirport* arr, int legNr, double alt, double speed, double latitude, double longitude, bool firstFlight, - double radius, const string & fltType, - const string & aircraftType, - const string & airline, double distance) + double radius, const string& fltType, + const string& aircraftType, + const string& airline, double distance) { - if( legNr <= AILeg::TAKEOFF ) - SG_LOG(SG_AI, SG_BULK, "Create Leg " << legNr << " " << (firstFlight?"First":"") << " Old Leg " << getLeg() << " At Airport : " << dep->getId()); - else if( legNr<= AILeg::APPROACH ) - SG_LOG(SG_AI, SG_BULK, "Create Leg " << legNr << " " << (firstFlight?"First":"") << " Old Leg " << getLeg() << " Departure Airport : " << dep->getId() << " Arrival Airport : " << arr->getId()); + if (legNr <= AILeg::TAKEOFF) + SG_LOG(SG_AI, SG_BULK, "Create Leg " << legNr << " " << (firstFlight ? "First" : "") << " Old Leg " << getLeg() << " At Airport : " << dep->getId()); + else if (legNr <= AILeg::APPROACH) + SG_LOG(SG_AI, SG_BULK, "Create Leg " << legNr << " " << (firstFlight ? "First" : "") << " Old Leg " << getLeg() << " Departure Airport : " << dep->getId() << " Arrival Airport : " << arr->getId()); else - SG_LOG(SG_AI, SG_BULK, "Create Leg " << legNr << " " << (firstFlight?"First":"") << " Old Leg " << getLeg() << " At Airport : " << arr->getId()); + SG_LOG(SG_AI, SG_BULK, "Create Leg " << legNr << " " << (firstFlight ? "First" : "") << " Old Leg " << getLeg() << " At Airport : " << arr->getId()); bool retVal = true; int currWpt = wpt_iterator - waypoints.begin(); @@ -85,7 +72,7 @@ bool FGAIFlightPlan::create(FGAIAircraft * ac, FGAirport * dep, break; case AILeg::TAXI: retVal = createTakeoffTaxi(ac, firstFlight, dep, radius, fltType, - aircraftType, airline); + aircraftType, airline); break; case AILeg::TAKEOFF: retVal = createTakeOff(ac, firstFlight, dep, SGGeod::fromDeg(longitude, latitude), speed, fltType); @@ -95,15 +82,15 @@ bool FGAIFlightPlan::create(FGAIAircraft * ac, FGAirport * dep, break; case AILeg::CRUISE: retVal = createCruise(ac, firstFlight, dep, arr, SGGeod::fromDeg(longitude, latitude), speed, - alt, fltType); + alt, fltType); break; case AILeg::APPROACH: retVal = createDescent(ac, arr, SGGeod::fromDeg(longitude, latitude), speed, alt, fltType, - distance); + distance); break; case AILeg::HOLD: retVal = createHold(ac, arr, SGGeod::fromDeg(longitude, latitude), speed, alt, fltType, - distance); + distance); break; case AILeg::LANDING: retVal = createLanding(ac, arr, fltType); @@ -125,95 +112,96 @@ bool FGAIFlightPlan::create(FGAIAircraft * ac, FGAirport * dep, // to do so, mark the last waypoint with a special status flag if (retVal) { if (waypoints.empty()) { - SG_LOG(SG_AI, SG_WARN, ac->getCallSign() << "|AIFlightPlan::create() Leg " << legNr << - " created empty waypoints." ); + SG_LOG(SG_AI, SG_WARN, ac->getCallSign() << "|AIFlightPlan::create() Leg " << legNr << " created empty waypoints."); return retVal; } wpt_iterator = waypoints.begin() + currWpt; - if (waypoints.back()->getName().size()==0) { - SG_LOG(SG_AI, SG_WARN, ac->getCallSign() << - " Empty wpt name"); - + if (waypoints.back()->getName().size() == 0) { + SG_LOG(SG_AI, SG_WARN, ac->getCallSign() << " Empty wpt name"); } - waypoints.back()->setName( waypoints.back()->getName() + string("legend")); + waypoints.back()->setName(waypoints.back()->getName() + string("legend")); // "It's pronounced Leg-end" (Roger Glover (Deep Purple): come Hell or High Water DvD, 1993) } return retVal; } -FGAIWaypoint * FGAIFlightPlan::createOnGround(FGAIAircraft * ac, - const std::string & aName, - const SGGeod & aPos, double aElev, - double aSpeed) +FGAIWaypoint* FGAIFlightPlan::createOnGround(FGAIAircraft* ac, + const std::string& aName, + const SGGeod& aPos, double aElev, + double aSpeed) { - FGAIWaypoint *wpt = new FGAIWaypoint; - wpt->setName (aName ); - wpt->setLongitude (aPos.getLongitudeDeg() ); - wpt->setLatitude (aPos.getLatitudeDeg() ); - wpt->setAltitude (aElev ); - wpt->setSpeed (aSpeed ); - wpt->setCrossat (-10000.1 ); - wpt->setGear_down (true ); - wpt->setFlaps (0.0f ); - wpt->setSpoilers (0.0f ); - wpt->setSpeedBrakes (0.0f ); - wpt->setFinished (false ); - wpt->setOn_ground (true ); - wpt->setRouteIndex (0 ); + FGAIWaypoint* wpt = new FGAIWaypoint; + wpt->setName(aName); + wpt->setLongitude(aPos.getLongitudeDeg()); + wpt->setLatitude(aPos.getLatitudeDeg()); + wpt->setAltitude(aElev); + wpt->setSpeed(aSpeed); + wpt->setCrossat(-10000.1); + wpt->setGear_down(true); + wpt->setFlaps(0.0f); + wpt->setSpoilers(0.0f); + wpt->setSpeedBrakes(0.0f); + wpt->setFinished(false); + wpt->setOn_ground(true); + wpt->setRouteIndex(0); + if (aSpeed > 0.0f) { wpt->setGroundLights(); } else { wpt->setPowerDownLights(); } + return wpt; } -FGAIWaypoint * FGAIFlightPlan::createOnRunway(FGAIAircraft * ac, - const std::string & aName, - const SGGeod & aPos, double aElev, - double aSpeed) +FGAIWaypoint* FGAIFlightPlan::createOnRunway(FGAIAircraft* ac, + const std::string& aName, + const SGGeod& aPos, double aElev, + double aSpeed) { - FGAIWaypoint * wpt = createOnGround(ac, aName, aPos, aElev, aSpeed); + FGAIWaypoint* wpt = createOnGround(ac, aName, aPos, aElev, aSpeed); wpt->setTakeOffLights(); return wpt; } -void FGAIFlightPlan::createArc(FGAIAircraft *ac, const SGGeod& center, int startAngle, -int endAngle, int increment, int radius, double aElev, double altDiff, double aSpeed, const char* pattern) { +void FGAIFlightPlan::createArc(FGAIAircraft* ac, const SGGeod& center, int startAngle, + int endAngle, int increment, int radius, double aElev, double altDiff, double aSpeed, const char* pattern) +{ double trackSegmentLength = (2 * M_PI * radius) / 360.0; double dummyAz2; char buffer[20]; - if (endAngle > startAngle && increment<0) { + + if (endAngle > startAngle && increment < 0) { endAngle -= 360; } - if (endAngle < startAngle && increment>0) { + if (endAngle < startAngle && increment > 0) { endAngle += 360; } - int nPoints = fabs(fabs(endAngle - startAngle)/increment); + int nPoints = fabs(fabs(endAngle - startAngle) / increment); double currentAltitude = aElev; double altDecrement = altDiff / nPoints; for (int i = startAngle; !(endAngle <= i && i < endAngle + fabs(increment)); i += increment) { - if(fabs(i)>720) { + if (fabs(i) > 720) { SG_LOG(SG_AI, SG_WARN, "FGAIFlightPlan::createArc runaway " << startAngle << " " << endAngle << " " << increment); break; } SGGeod result; SGGeodesy::direct(center, i, - radius, result, dummyAz2); + radius, result, dummyAz2); snprintf(buffer, sizeof(buffer), pattern, i); currentAltitude -= altDecrement; - FGAIWaypoint *wpt = createInAir(ac, buffer, result, currentAltitude, aSpeed); + FGAIWaypoint* wpt = createInAir(ac, buffer, result, currentAltitude, aSpeed); wpt->setCrossat(currentAltitude); wpt->setTrackLength(trackSegmentLength); pushBackWaypoint(wpt); } } -void FGAIFlightPlan::createLine( FGAIAircraft *ac, const SGGeod& startPoint, double azimuth, double dist, double aElev, double dAlt, double vDescent, const char* pattern) { - SGGeod dummyAz2; - double nPoints = dist/(vDescent*2); +void FGAIFlightPlan::createLine(FGAIAircraft* ac, const SGGeod& startPoint, double azimuth, double dist, double aElev, double dAlt, double vDescent, const char* pattern) +{ + double nPoints = dist / (vDescent * 2); char buffer[20]; double distIncrement = (dist / nPoints); @@ -227,21 +215,20 @@ void FGAIFlightPlan::createLine( FGAIAircraft *ac, const SGGeod& startPoint, dou wpt->setTrackLength((dist / nPoints)); pushBackWaypoint(wpt); } - } -FGAIWaypoint * FGAIFlightPlan::createInAir(FGAIAircraft * ac, - const std::string & aName, - const SGGeod & aPos, double aElev, - double aSpeed) +FGAIWaypoint* FGAIFlightPlan::createInAir(FGAIAircraft* ac, + const std::string& aName, + const SGGeod& aPos, double aElev, + double aSpeed) { - FGAIWaypoint * wpt = createOnGround(ac, aName, aPos, aElev, aSpeed); - wpt->setGear_down (false ); - wpt->setFlaps (0.0f ); - wpt->setSpoilers (0.0f ); - wpt->setSpeedBrakes(0.0f ); - wpt->setOn_ground (false ); - wpt->setCrossat (aElev ); + FGAIWaypoint* wpt = createOnGround(ac, aName, aPos, aElev, aSpeed); + wpt->setGear_down(false); + wpt->setFlaps(0.0f); + wpt->setSpoilers(0.0f); + wpt->setSpeedBrakes(0.0f); + wpt->setOn_ground(false); + wpt->setCrossat(aElev); if (aPos.getElevationFt() < 10000.0f) { wpt->setApproachLights(); @@ -251,50 +238,50 @@ FGAIWaypoint * FGAIFlightPlan::createInAir(FGAIAircraft * ac, return wpt; } -FGAIWaypoint * FGAIFlightPlan::clone(FGAIWaypoint * aWpt) +FGAIWaypoint* FGAIFlightPlan::clone(FGAIWaypoint* aWpt) { - FGAIWaypoint *wpt = new FGAIWaypoint; - wpt->setName ( aWpt->getName () ); - wpt->setLongitude ( aWpt->getLongitude() ); - wpt->setLatitude ( aWpt->getLatitude() ); - wpt->setAltitude ( aWpt->getAltitude() ); - wpt->setSpeed ( aWpt->getSpeed() ); - wpt->setCrossat ( aWpt->getCrossat() ); - wpt->setGear_down ( aWpt->getGear_down() ); - wpt->setFlaps ( aWpt->getFlaps() ); - wpt->setFinished ( aWpt->isFinished() ); - wpt->setOn_ground ( aWpt->getOn_ground() ); - wpt->setLandingLight (aWpt->getLandingLight() ); - wpt->setNavLight (aWpt->getNavLight() ); - wpt->setStrobeLight (aWpt->getStrobeLight() ); - wpt->setTaxiLight (aWpt->getTaxiLight() ); - wpt->setRouteIndex ( 0 ); + FGAIWaypoint* wpt = new FGAIWaypoint; + wpt->setName(aWpt->getName()); + wpt->setLongitude(aWpt->getLongitude()); + wpt->setLatitude(aWpt->getLatitude()); + wpt->setAltitude(aWpt->getAltitude()); + wpt->setSpeed(aWpt->getSpeed()); + wpt->setCrossat(aWpt->getCrossat()); + wpt->setGear_down(aWpt->getGear_down()); + wpt->setFlaps(aWpt->getFlaps()); + wpt->setFinished(aWpt->isFinished()); + wpt->setOn_ground(aWpt->getOn_ground()); + wpt->setLandingLight(aWpt->getLandingLight()); + wpt->setNavLight(aWpt->getNavLight()); + wpt->setStrobeLight(aWpt->getStrobeLight()); + wpt->setTaxiLight(aWpt->getTaxiLight()); + wpt->setRouteIndex(0); return wpt; } -FGAIWaypoint * FGAIFlightPlan::cloneWithPos(FGAIAircraft * ac, FGAIWaypoint * aWpt, - const std::string & aName, - const SGGeod & aPos) +FGAIWaypoint* FGAIFlightPlan::cloneWithPos(FGAIAircraft* ac, FGAIWaypoint* aWpt, + const std::string& aName, + const SGGeod& aPos) { - FGAIWaypoint *wpt = clone(aWpt); - wpt->setName ( aName ); - wpt->setLongitude ( aPos.getLongitudeDeg () ); - wpt->setLatitude ( aPos.getLatitudeDeg () ); + FGAIWaypoint* wpt = clone(aWpt); + wpt->setName(aName); + wpt->setLongitude(aPos.getLongitudeDeg()); + wpt->setLatitude(aPos.getLatitudeDeg()); return wpt; } -void FGAIFlightPlan::createDefaultTakeoffTaxi(FGAIAircraft * ac, - FGAirport * aAirport, - FGRunway * aRunway) +void FGAIFlightPlan::createDefaultTakeoffTaxi(FGAIAircraft* ac, + FGAirport* aAirport, + FGRunway* aRunway) { SGGeod runwayTakeoff = aRunway->pointOnCenterline(5.0); double airportElev = aAirport->getElevation(); - FGAIWaypoint *wpt; + FGAIWaypoint* wpt; wpt = createOnGround(ac, "Airport Center", aAirport->geod(), airportElev, ac->getPerformance()->vTaxi()); @@ -313,44 +300,40 @@ void FGAIFlightPlan::createDefaultTakeoffTaxi(FGAIAircraft * ac, pushBackWaypoint(wpt); } -bool FGAIFlightPlan::createTakeoffTaxi(FGAIAircraft * ac, bool firstFlight, - FGAirport * apt, +bool FGAIFlightPlan::createTakeoffTaxi(FGAIAircraft* ac, bool firstFlight, + FGAirport* apt, double radius, - const string & fltType, - const string & acType, - const string & airline) + const string& fltType, + const string& acType, + const string& airline) { int route; // If this function is called during initialization, // make sure we obtain a valid gate ID first // and place the model at the location of the gate. if (firstFlight && apt->getDynamics()->hasParkings()) { - gate = apt->getDynamics()->getAvailableParking(radius, fltType, - acType, airline); - if (!gate.isValid()) { - SG_LOG(SG_AI, SG_WARN, "Could not find parking for a " << - acType << - " of flight type " << fltType << - " of airline " << airline << - " at airport " << apt->getId()); - } + gate = apt->getDynamics()->getAvailableParking(radius, fltType, + acType, airline); + if (!gate.isValid()) { + SG_LOG(SG_AI, SG_WARN, "Could not find parking for a " << acType << " of flight type " << fltType << " of airline " << airline << " at airport " << apt->getId()); + } } const string& rwyClass = getRunwayClassFromTrafficType(fltType); // Only set this if it hasn't been set by ATC already. if (activeRunway.empty()) { - //cerr << "Getting runway for " << ac->getTrafficRef()->getCallSign() << " at " << apt->getId() << endl; + // cerr << "Getting runway for " << ac->getTrafficRef()->getCallSign() << " at " << apt->getId() << endl; double depHeading = ac->getTrafficRef()->getCourse(); apt->getDynamics()->getActiveRunway(rwyClass, 1, activeRunway, depHeading); } - FGRunway * rwy = apt->getRunwayByIdent(activeRunway); + FGRunway* rwy = apt->getRunwayByIdent(activeRunway); SG_LOG(SG_AI, SG_BULK, "Taxi to " << apt->getId() << "/" << activeRunway); - assert( rwy != NULL ); + assert(rwy != NULL); SGGeod runwayTakeoff = rwy->pointOnCenterlineDisplaced(5.0); - FGGroundNetwork *gn = apt->groundNetwork(); + FGGroundNetwork* gn = apt->groundNetwork(); if (!gn->exists()) { SG_LOG(SG_AI, SG_DEBUG, "No groundnet " << apt->getId() << " creating default taxi."); createDefaultTakeoffTaxi(ac, apt, rwy); @@ -368,13 +351,13 @@ bool FGAIFlightPlan::createTakeoffTaxi(FGAIAircraft * ac, bool firstFlight, // fallback mechanism for this. // Starting from gate 0 in this case is a bit of a hack // which requires a more proper solution later on. - // delete taxiRoute; - // taxiRoute = new FGTaxiRoute; + // delete taxiRoute; + // taxiRoute = new FGTaxiRoute; // Determine which node to start from. FGTaxiNodeRef node; // Find out which node to start from - FGParking *park = gate.parking(); + FGParking* park = gate.parking(); if (park) { node = park->getPushBackPoint(); if (node == 0) { @@ -384,11 +367,11 @@ bool FGAIFlightPlan::createTakeoffTaxi(FGAIAircraft * ac, bool firstFlight, } else if (lastNodeVisited) { node = lastNodeVisited; } else { - SG_LOG(SG_AI, SG_WARN, "Taxiroute could not be constructed no lastNodeVisited at " << (apt?apt->getId():"????") << gate.isValid()); + SG_LOG(SG_AI, SG_WARN, "Taxiroute could not be constructed no lastNodeVisited at " << (apt ? apt->getId() : "????") << gate.isValid()); } } } else { - SG_LOG(SG_AI, SG_WARN, "Taxiroute could not be constructed no parking." << (apt?apt->getId():"????")); + SG_LOG(SG_AI, SG_WARN, "Taxiroute could not be constructed no parking." << (apt ? apt->getId() : "????")); } FGTaxiRoute taxiRoute; @@ -422,7 +405,7 @@ bool FGAIFlightPlan::createTakeoffTaxi(FGAIAircraft * ac, bool firstFlight, gate.release(); // free up our gate as required } else { if (taxiRoute.size() > 1) { - taxiRoute.next(skipNode, &route); // chop off the first waypoint, because that is already the last of the pushback route + taxiRoute.next(skipNode, &route); // chop off the first waypoint, because that is already the last of the pushback route } } @@ -436,7 +419,7 @@ bool FGAIFlightPlan::createTakeoffTaxi(FGAIAircraft * ac, bool firstFlight, while (taxiRoute.next(node, &route)) { char buffer[10]; snprintf(buffer, sizeof(buffer), "%d", node->getIndex()); - FGAIWaypoint *wpt = + FGAIWaypoint* wpt = createOnGround(ac, buffer, node->geod(), apt->getElevation(), ac->getPerformance()->vTaxi()); wpt->setRouteIndex(route); @@ -444,7 +427,7 @@ bool FGAIFlightPlan::createTakeoffTaxi(FGAIAircraft * ac, bool firstFlight, if (taxiRoute.nodesLeft() == 1) { // Note that we actually have hold points in the ground network, but this is just an initial test. //cerr << "Setting departurehold point: " << endl; - wpt->setName( wpt->getName() + string("_DepartureHold")); + wpt->setName(wpt->getName() + string("_DepartureHold")); wpt->setFlaps(0.5f); wpt->setTakeOffLights(); } @@ -465,7 +448,7 @@ bool FGAIFlightPlan::createTakeoffTaxi(FGAIAircraft * ac, bool firstFlight, accell_point += distM; } SGGeod accelPoint = rwy->pointOnCenterlineDisplaced(accell_point); - FGAIWaypoint *wpt = createOnRunway(ac, "Accel", accelPoint, apt->getElevation(), ac->getPerformance()->vRotate()); + FGAIWaypoint* wpt = createOnRunway(ac, "Accel", accelPoint, apt->getElevation(), ac->getPerformance()->vRotate()); wpt->setFlaps(0.5f); pushBackWaypoint(wpt); @@ -473,15 +456,15 @@ bool FGAIFlightPlan::createTakeoffTaxi(FGAIAircraft * ac, bool firstFlight, return true; } -void FGAIFlightPlan::createDefaultLandingTaxi(FGAIAircraft * ac, - FGAirport * aAirport) +void FGAIFlightPlan::createDefaultLandingTaxi(FGAIAircraft* ac, + FGAirport* aAirport) { SGGeod lastWptPos = SGGeod::fromDeg(waypoints.back()->getLongitude(), waypoints.back()->getLatitude()); double airportElev = aAirport->getElevation(); - FGAIWaypoint *wpt; + FGAIWaypoint* wpt; wpt = createOnGround(ac, "Runway Exit", lastWptPos, airportElev, ac->getPerformance()->vTaxi()); @@ -493,23 +476,23 @@ void FGAIFlightPlan::createDefaultLandingTaxi(FGAIAircraft * ac, if (gate.isValid()) { wpt = createOnGround(ac, "END-taxi", gate.parking()->geod(), airportElev, - ac->getPerformance()->vTaxi()); + ac->getPerformance()->vTaxi()); pushBackWaypoint(wpt); } } -bool FGAIFlightPlan::createLandingTaxi(FGAIAircraft * ac, - FGAirport * apt, +bool FGAIFlightPlan::createLandingTaxi(FGAIAircraft* ac, + FGAirport* apt, double radius, - const string & fltType, - const string & acType, - const string & airline) + const string& fltType, + const string& acType, + const string& airline) { int route; gate = apt->getDynamics()->getAvailableParking(radius, fltType, - acType, airline); + acType, airline); SGGeod lastWptPos = waypoints.back()->getPos(); - FGGroundNetwork *gn = apt->groundNetwork(); + FGGroundNetwork* gn = apt->groundNetwork(); // Find a route from runway end to parking/gate. if (!gn->exists()) { @@ -517,14 +500,14 @@ bool FGAIFlightPlan::createLandingTaxi(FGAIAircraft * ac, return true; } - FGRunway * rwy = apt->getRunwayByIdent(activeRunway); + FGRunway* rwy = apt->getRunwayByIdent(activeRunway); FGTaxiNodeRef runwayNode; if (gn->getVersion() == 1) { runwayNode = gn->findNearestNodeOnRunwayExit(lastWptPos, rwy); } else { runwayNode = gn->findNearestNode(lastWptPos); } - //cerr << "Using network node " << runwayId << endl; + // cerr << "Using network node " << runwayId << endl; // A negative gateId indicates an overflow parking, use a // fallback mechanism for this. // Starting from gate 0 doesn't work, so don't try it @@ -544,46 +527,46 @@ bool FGAIFlightPlan::createLandingTaxi(FGAIAircraft * ac, for (int i = 0; i < size; i++) { taxiRoute.next(node, &route); char buffer[32]; - snprintf(buffer, sizeof(buffer), "landingtaxi-%d-%d", node->getIndex(), i); - FGAIWaypoint *wpt = + snprintf(buffer, sizeof(buffer), "landingtaxi-%d-%d", node->getIndex(), i); + FGAIWaypoint* wpt = createOnGround(ac, buffer, node->geod(), apt->getElevation(), ac->getPerformance()->vTaxi()); wpt->setRouteIndex(route); // next WPT must be far enough from last and far enough from parking if ((!waypoints.back() || - SGGeodesy::distanceM(waypoints.back()->getPos(), wpt->getPos()) > 1) && - SGGeodesy::distanceM(gate.parking()->geod(), wpt->getPos()) > 20) { + SGGeodesy::distanceM(waypoints.back()->getPos(), wpt->getPos()) > 1) && + SGGeodesy::distanceM(gate.parking()->geod(), wpt->getPos()) > 20) { if (waypoints.back()) { - int dist = SGGeodesy::distanceM(waypoints.back()->getPos(), wpt->getPos()); - // pretty near better set speed down - if (dist<10 || (size - i) < 2 ) { - wpt->setSpeed(ac->getPerformance()->vTaxi()/2); - } + int dist = SGGeodesy::distanceM(waypoints.back()->getPos(), wpt->getPos()); + // pretty near better set speed down + if (dist < 10 || (size - i) < 2) { + wpt->setSpeed(ac->getPerformance()->vTaxi() / 2); + } } pushBackWaypoint(wpt); } } - SG_LOG(SG_AI, SG_BULK, "Created taxi from " << runwayNode->getIndex() << " to " << gate.parking()->ident() << " at " << apt->getId()); + SG_LOG(SG_AI, SG_BULK, "Created taxi from " << runwayNode->getIndex() << " to " << gate.parking()->ident() << " at " << apt->getId()); return true; } static double accelDistance(double v0, double v1, double accel) { - double t = fabs(v1 - v0) / accel; // time in seconds to change velocity - // area under the v/t graph: (t * v0) + (dV / 2t) where (dV = v1 - v0) - SG_LOG(SG_AI, SG_BULK, "Brakingtime " << t ); - return t * 0.5 * (v1 + v0); + double t = fabs(v1 - v0) / accel; // time in seconds to change velocity + // area under the v/t graph: (t * v0) + (dV / 2t) where (dV = v1 - v0) + SG_LOG(SG_AI, SG_BULK, "Brakingtime " << t); + return t * 0.5 * (v1 + v0); } -// find the horizontal distance to gain the specific altiude, holding +// find the horizontal distance to gain the specific altitude, holding // a constant pitch angle. Used to compute distance based on standard FD/AP // PITCH mode prior to VS or CLIMB engaging. Visually, we want to avoid // a dip in the nose angle after rotation, during initial climb-out. static double pitchDistance(double pitchAngleDeg, double altGainM) { - return altGainM / tan(pitchAngleDeg * SG_DEGREES_TO_RADIANS); + return altGainM / tan(pitchAngleDeg * SG_DEGREES_TO_RADIANS); } /******************************************************************* @@ -597,17 +580,17 @@ static double pitchDistance(double pitchAngleDeg, double altGainM) * more likely however. * ******************************************************************/ -bool FGAIFlightPlan::createTakeOff(FGAIAircraft * ac, +bool FGAIFlightPlan::createTakeOff(FGAIAircraft* ac, bool firstFlight, - FGAirport * apt, + FGAirport* apt, const SGGeod& pos, double speed, - const string & fltType) + const string& fltType) { SG_LOG(SG_AI, SG_BULK, "createTakeOff " << apt->getId() << "/" << activeRunway); double accell_point = 105.0; - // climb-out angle in degrees. could move this to the perf-db but this - // value is pretty sane + // climb-out angle in degrees. could move this to the perf-db but this + // value is pretty sane const double INITIAL_PITCH_ANGLE = 10.0; double accel = ac->getPerformance()->acceleration(); @@ -620,7 +603,7 @@ bool FGAIFlightPlan::createTakeOff(FGAIAircraft * ac, double vRotateMetric = vRotate * SG_KT_TO_MPS; double vTakeoffMetric = vTakeoff * SG_KT_TO_MPS; - FGAIWaypoint *wpt; + FGAIWaypoint* wpt; // Get the current active runway, based on code from David Luff // This should actually be unified and extended to include // Preferential runway use schema's @@ -628,9 +611,8 @@ bool FGAIFlightPlan::createTakeOff(FGAIAircraft * ac, // because the getActive runway function takes care of that. if (firstFlight) { const string& rwyClass = getRunwayClassFromTrafficType(fltType); - double heading = ac->getTrafficRef()->getCourse(); - apt->getDynamics()->getActiveRunway(rwyClass, 1, activeRunway, - heading); + double dHeading = ac->getTrafficRef()->getCourse(); + apt->getDynamics()->getActiveRunway(rwyClass, 1, activeRunway, dHeading); } // this is Sentry issue FLIGHTGEAR-DS : happens after reposition, @@ -641,19 +623,19 @@ bool FGAIFlightPlan::createTakeOff(FGAIAircraft * ac, } SG_LOG(SG_AI, SG_BULK, "Takeoff from airport " << apt->getId() << "/" << activeRunway); - FGRunway * rwy = apt->getRunwayByIdent(activeRunway); + FGRunway* rwy = apt->getRunwayByIdent(activeRunway); if (!rwy) return false; double airportElev = apt->getElevation(); if (pos.isValid()) { - SGGeod runwayEnd = rwy->pointOnCenterlineDisplaced(0); - double distM = SGGeodesy::distanceM(pos, runwayEnd); - if (distM > accell_point) { + SGGeod runwayEnd = rwy->pointOnCenterlineDisplaced(0); + double distM = SGGeodesy::distanceM(pos, runwayEnd); + if (distM > accell_point) { SG_LOG(SG_AI, SG_BULK, "Distance down runway " << distM << " " << accell_point); accell_point += distM; - } + } } // distance from the runway threshold to accelerate to rotation speed. @@ -664,7 +646,7 @@ bool FGAIFlightPlan::createTakeOff(FGAIAircraft * ac, pushBackWaypoint(wpt); // After rotation, we still need to accelerate to the take-off speed. - double t = d + accelDistance(vRotateMetric, vTakeoffMetric, accelMetric); + double t = d + accelDistance(vRotateMetric, vTakeoffMetric, accelMetric); SGGeod takeoffPoint = rwy->pointOnCenterlineDisplaced(t); wpt = createOnRunway(ac, "takeoff", takeoffPoint, airportElev, vTakeoff); wpt->setGear_down(true); @@ -674,10 +656,10 @@ bool FGAIFlightPlan::createTakeOff(FGAIAircraft * ac, double vRef = vTakeoff + 20; // climb-out at v2 + 20kts // We want gear-up to take place at ~400ft AGL. However, the flightplan - // will move onto the next leg once it gets within 2xspeed of the next waypoint. + // will move onto the next leg once it gets within 2x-speed of the next waypoint. // With closely spaced waypoints on climb-out this can occur almost immediately, // so we put the waypoint further away. - double gearUpDist = t + 2*vRef*SG_FEET_TO_METER + pitchDistance(INITIAL_PITCH_ANGLE, 400 * SG_FEET_TO_METER); + double gearUpDist = t + 2 * vRef * SG_FEET_TO_METER + pitchDistance(INITIAL_PITCH_ANGLE, 400 * SG_FEET_TO_METER); SGGeod gearUpPoint = rwy->pointOnCenterlineDisplaced(gearUpDist); wpt = createInAir(ac, "gear-up", gearUpPoint, airportElev + 400, vRef); wpt->setFlaps(0.5f); @@ -686,15 +668,15 @@ bool FGAIFlightPlan::createTakeOff(FGAIAircraft * ac, // limit climbout speed to 240kts below 10000' double vClimbBelow10000 = std::min(240.0, ac->getPerformance()->vClimb()); - // create two climb-out points. This is important becuase the first climb point will + // create two climb-out points. This is important because the first climb point will // be a (sometimes large) turn towards the destination, and we don't want to // commence that turn below 2000' - double climbOut = t + 2*vClimbBelow10000*SG_FEET_TO_METER + pitchDistance(INITIAL_PITCH_ANGLE, 2000 * SG_FEET_TO_METER); + double climbOut = t + 2 * vClimbBelow10000 * SG_FEET_TO_METER + pitchDistance(INITIAL_PITCH_ANGLE, 2000 * SG_FEET_TO_METER); SGGeod climbOutPoint = rwy->pointOnCenterlineDisplaced(climbOut); wpt = createInAir(ac, "2000'", climbOutPoint, airportElev + 2000, vClimbBelow10000); pushBackWaypoint(wpt); - climbOut = t + 2*vClimbBelow10000*SG_FEET_TO_METER + pitchDistance(INITIAL_PITCH_ANGLE, 2500 * SG_FEET_TO_METER); + climbOut = t + 2 * vClimbBelow10000 * SG_FEET_TO_METER + pitchDistance(INITIAL_PITCH_ANGLE, 2500 * SG_FEET_TO_METER); SGGeod climbOutPoint2 = rwy->pointOnCenterlineDisplaced(climbOut); wpt = createInAir(ac, "2500'", climbOutPoint2, airportElev + 2500, vClimbBelow10000); pushBackWaypoint(wpt); @@ -706,18 +688,17 @@ bool FGAIFlightPlan::createTakeOff(FGAIAircraft * ac, * CreateClimb * initialize the Aircraft in a climb. ******************************************************************/ -bool FGAIFlightPlan::createClimb(FGAIAircraft * ac, bool firstFlight, - FGAirport * apt, FGAirport* arrival, +bool FGAIFlightPlan::createClimb(FGAIAircraft* ac, bool firstFlight, + FGAirport* apt, FGAirport* arrival, double speed, double alt, - const string & fltType) + const string& fltType) { double vClimb = ac->getPerformance()->vClimb(); if (firstFlight) { const string& rwyClass = getRunwayClassFromTrafficType(fltType); - double heading = ac->getTrafficRef()->getCourse(); - apt->getDynamics()->getActiveRunway(rwyClass, 1, activeRunway, - heading); + double dHeading = ac->getTrafficRef()->getCourse(); + apt->getDynamics()->getActiveRunway(rwyClass, 1, activeRunway, dHeading); } if (sid) { @@ -731,18 +712,18 @@ bool FGAIFlightPlan::createClimb(FGAIAircraft * ac, bool firstFlight, FGRunwayRef runway = apt->getRunwayByIdent(activeRunway); SGGeod cur = runway->end(); if (!waypoints.empty()) { - cur = waypoints.back()->getPos(); + cur = waypoints.back()->getPos(); } - // compute course towards destination + // compute course towards destination double course = SGGeodesy::courseDeg(cur, arrival->geod()); - double distance = SGGeodesy::distanceM(cur, arrival->geod()); + // double distance = SGGeodesy::distanceM(cur, arrival->geod()); const double headingDiffRunway = SGMiscd::normalizePeriodic(-180, 180, course - runway->headingDeg()); - if( fabs(headingDiffRunway) <10 ) { + if (fabs(headingDiffRunway) < 10) { SGGeod climb1 = SGGeodesy::direct(cur, course, 10 * SG_NM_TO_METER); - FGAIWaypoint *wpt = createInAir(ac, "10000ft climb", climb1, 10000, vClimb); + FGAIWaypoint* wpt = createInAir(ac, "10000ft climb", climb1, 10000, vClimb); pushBackWaypoint(wpt); SGGeod climb2 = SGGeodesy::direct(cur, course, 20 * SG_NM_TO_METER); @@ -750,23 +731,18 @@ bool FGAIFlightPlan::createClimb(FGAIAircraft * ac, bool firstFlight, pushBackWaypoint(wpt); } else { double initialTurnRadius = getTurnRadius(vClimb, true); - double lateralOffset = initialTurnRadius; - if (headingDiffRunway > 0.0) { - lateralOffset *= -1.0; - } SGGeod climb1 = SGGeodesy::direct(cur, runway->headingDeg(), 5 * SG_NM_TO_METER); - FGAIWaypoint *wpt = createInAir(ac, "5000ft climb", climb1, 5000, vClimb); + FGAIWaypoint* wpt = createInAir(ac, "5000ft climb", climb1, 5000, vClimb); pushBackWaypoint(wpt); - int rightAngle = headingDiffRunway>0?90:-90; - int firstTurnIncrement = headingDiffRunway>0?2:-2; + int rightAngle = headingDiffRunway > 0 ? 90 : -90; + int firstTurnIncrement = headingDiffRunway > 0 ? 2 : -2; SGGeod firstTurnCenter = SGGeodesy::direct(climb1, ac->getTrueHeadingDeg() + rightAngle, initialTurnRadius); - createArc(ac, firstTurnCenter, ac->_getHeading()-rightAngle, course-rightAngle, firstTurnIncrement, initialTurnRadius, 5000, 100, vClimb, "climb-out%03d"); + createArc(ac, firstTurnCenter, ac->_getHeading() - rightAngle, course - rightAngle, firstTurnIncrement, initialTurnRadius, 5000, 100, vClimb, "climb-out%03d"); SGGeod climb2 = SGGeodesy::direct(cur, course, 20 * SG_NM_TO_METER); wpt = createInAir(ac, "18000ft climb", waypoints.back()->getPos(), 18000, vClimb); pushBackWaypoint(wpt); } - } return true; @@ -777,12 +753,12 @@ bool FGAIFlightPlan::createClimb(FGAIAircraft * ac, bool firstFlight, * Generate a flight path from the last waypoint of the cruise to * the permission to land point ******************************************************************/ -bool FGAIFlightPlan::createDescent(FGAIAircraft * ac, - FGAirport * apt, +bool FGAIFlightPlan::createDescent(FGAIAircraft* ac, + FGAirport* apt, const SGGeod& current, double speed, double alt, - const string & fltType, + const string& fltType, double requiredDistance) { // The descent path contains the following phases: @@ -790,24 +766,20 @@ bool FGAIFlightPlan::createDescent(FGAIAircraft * ac, // 2) a linear glide path from the initial position to // 3) a semi circle turn to final // 4) approach - bool reposition = false; - FGAIWaypoint *wpt; double vDescent = ac->getPerformance()->vDescent(); - double vApproach = ac->getPerformance()->vApproach(); + // double vApproach = ac->getPerformance()->vApproach(); //Beginning of Descent const string& rwyClass = getRunwayClassFromTrafficType(fltType); double heading = ac->getTrueHeadingDeg(); - apt->getDynamics()->getActiveRunway(rwyClass, 2, activeRunway, - heading); + apt->getDynamics()->getActiveRunway(rwyClass, 2, activeRunway, heading); if (!apt->hasRunwayWithIdent(activeRunway)) { - SG_LOG(SG_AI, SG_WARN, ac->getCallSign() << - "| FGAIFlightPlan::createDescent: No such runway " << activeRunway << " at " << apt->ident()); + SG_LOG(SG_AI, SG_WARN, ac->getCallSign() << "| FGAIFlightPlan::createDescent: No such runway " << activeRunway << " at " << apt->ident()); return false; } FGRunwayRef rwy = apt->getRunwayByIdent(activeRunway); - if (waypoints.size()==0 && ac->getTrueHeadingDeg()==0) { + if (waypoints.size() == 0 && ac->getTrueHeadingDeg() == 0) { // we obviously have no previous state and are free to position the aircraft double courseTowardsThreshold = SGGeodesy::courseDeg(current, rwy->pointOnCenterlineDisplaced(0)); ac->setHeading(courseTowardsThreshold); @@ -822,8 +794,8 @@ bool FGAIFlightPlan::createDescent(FGAIAircraft * ac, double initialTurnRadius = getTurnRadius(vDescent, true); //double finalTurnRadius = getTurnRadius(vApproach, true); -// get length of the downwind leg for the intended runway - double distanceOut = apt->getDynamics()->getApproachController()->getRunway(rwy->name())->getApproachDistance(); //12 * SG_NM_TO_METER; + // get length of the downwind leg for the intended runway + double distanceOut = apt->getDynamics()->getApproachController()->getRunway(rwy->name())->getApproachDistance(); //12 * SG_NM_TO_METER; //time_t previousArrivalTime= apt->getDynamics()->getApproachController()->getRunway(rwy->name())->getEstApproachTime(); // tells us the direction we have to turn @@ -843,28 +815,20 @@ bool FGAIFlightPlan::createDescent(FGAIAircraft * ac, double distance = SGGeodesy::distanceM(current, initialTarget); double azimuth = SGGeodesy::courseDeg(current, initialTarget); double secondaryAzimuth = SGGeodesy::courseDeg(current, secondaryTarget); - double initialHeadingDiff = SGMiscd::normalizePeriodic(-180, 180, azimuth-secondaryAzimuth); - double dummyAz2; + double initialHeadingDiff = SGMiscd::normalizePeriodic(-180, 180, azimuth - secondaryAzimuth); double courseTowardsThreshold = SGGeodesy::courseDeg(current, rwy->pointOnCenterlineDisplaced(0)); - double courseTowardsRwyEnd = SGGeodesy::courseDeg(current, otherRwyEnd); + // double courseTowardsRwyEnd = SGGeodesy::courseDeg(current, otherRwyEnd); double headingDiffToRunwayThreshold = SGMiscd::normalizePeriodic(-180, 180, ac->getTrueHeadingDeg() - courseTowardsThreshold); - double headingDiffToRunwayEnd = SGMiscd::normalizePeriodic(-180, 180, ac->getTrueHeadingDeg() - courseTowardsRwyEnd); + // double headingDiffToRunwayEnd = SGMiscd::normalizePeriodic(-180, 180, ac->getTrueHeadingDeg() - courseTowardsRwyEnd); - SG_LOG(SG_AI, SG_BULK, ac->getCallSign() << - "| " << - " WPs : " << waypoints.size() << - " Heading Diff (rwy) : " << headingDiffRunway << - " Distance : " << distance << - " Azimuth : " << azimuth << - " Heading : " << ac->getTrueHeadingDeg() << - " Initial Headingdiff " << initialHeadingDiff << - " Lateral : " << lateralOffset); + SG_LOG(SG_AI, SG_BULK, ac->getCallSign() << "| " + << " WPs : " << waypoints.size() << " Heading Diff (rwy) : " << headingDiffRunway << " Distance : " << distance << " Azimuth : " << azimuth << " Heading : " << ac->getTrueHeadingDeg() << " Initial Headingdiff " << initialHeadingDiff << " Lateral : " << lateralOffset); // Erase the two bogus BOD points: Note check for conflicts with scripted AI flightPlans IncrementWaypoint(false); IncrementWaypoint(false); - if (fabs(headingDiffRunway)>=30 && fabs(headingDiffRunway)<=150 ) { - if (distance < (2*initialTurnRadius)) { + if (fabs(headingDiffRunway) >= 30 && fabs(headingDiffRunway) <= 150) { + if (distance < (2 * initialTurnRadius)) { // Too near so we pass over and enter over other side SG_LOG(SG_AI, SG_BULK, ac->getCallSign() << "| Enter near S curve"); secondaryTarget = @@ -873,55 +837,55 @@ bool FGAIFlightPlan::createDescent(FGAIAircraft * ac, rwy->pointOffCenterline(-3 * distanceOut, -lateralOffset); // Entering not "straight" into runway so we do a s-curve - int rightAngle = headingDiffRunway>0?90:-90; - int firstTurnIncrement = headingDiffRunway>0?2:-2; + int rightAngle = headingDiffRunway > 0 ? 90 : -90; + int firstTurnIncrement = headingDiffRunway > 0 ? 2 : -2; SGGeod firstTurnCenter = SGGeodesy::direct(current, ac->getTrueHeadingDeg() + rightAngle, initialTurnRadius); SGGeod newCurrent = current; // If we are not far enough cross over - if (abs(headingDiffToRunwayThreshold)<90) { + if (abs(headingDiffToRunwayThreshold) < 90) { newCurrent = SGGeodesy::direct(current, ac->getTrueHeadingDeg(), distance + 1000); firstTurnCenter = SGGeodesy::direct(newCurrent, ac->getTrueHeadingDeg() + rightAngle, initialTurnRadius); - createLine(ac, current, ac->getTrueHeadingDeg(), distance + 1000, waypoints.size()>0?waypoints.back()->getAltitude():alt, 0, vDescent, "move%03d"); + createLine(ac, current, ac->getTrueHeadingDeg(), distance + 1000, waypoints.size() > 0 ? waypoints.back()->getAltitude() : alt, 0, vDescent, "move%03d"); } int offset = 1000; - while (SGGeodesy::distanceM(firstTurnCenter, secondaryTarget) < 2*initialTurnRadius) { - newCurrent = SGGeodesy::direct(newCurrent, ac->getTrueHeadingDeg(), offset+=100); + while (SGGeodesy::distanceM(firstTurnCenter, secondaryTarget) < 2 * initialTurnRadius) { + newCurrent = SGGeodesy::direct(newCurrent, ac->getTrueHeadingDeg(), offset += 100); firstTurnCenter = SGGeodesy::direct(newCurrent, ac->getTrueHeadingDeg() + rightAngle, initialTurnRadius); } - const double heading = VectorMath::outerTangentsAngle(firstTurnCenter, secondaryTarget, initialTurnRadius, initialTurnRadius )[0]; - createArc(ac, firstTurnCenter, ac->_getHeading()-rightAngle, heading-rightAngle, firstTurnIncrement, initialTurnRadius, waypoints.size()>0?waypoints.back()->getAltitude():alt, altDiff/4, vDescent, "near-initialturn%03d"); - double length = VectorMath::innerTangentsLength(firstTurnCenter, secondaryTarget, initialTurnRadius, initialTurnRadius ); - createLine(ac, waypoints.back()->getPos(), heading, length, waypoints.size()>0?waypoints.back()->getAltitude():alt, altDiff/2, vDescent, "descent%03d"); - int startVal = SGMiscd::normalizePeriodic(0, 360, heading-rightAngle); - int endVal = SGMiscd::normalizePeriodic(0, 360, rwy->headingDeg()-rightAngle); + const double dHeading = VectorMath::outerTangentsAngle(firstTurnCenter, secondaryTarget, initialTurnRadius, initialTurnRadius)[0]; + createArc(ac, firstTurnCenter, ac->_getHeading() - rightAngle, dHeading - rightAngle, firstTurnIncrement, initialTurnRadius, waypoints.size() > 0 ? waypoints.back()->getAltitude() : alt, altDiff / 4, vDescent, "near-initialturn%03d"); + double length = VectorMath::innerTangentsLength(firstTurnCenter, secondaryTarget, initialTurnRadius, initialTurnRadius); + createLine(ac, waypoints.back()->getPos(), dHeading, length, waypoints.size() > 0 ? waypoints.back()->getAltitude() : alt, altDiff / 2, vDescent, "descent%03d"); + int startVal = SGMiscd::normalizePeriodic(0, 360, dHeading - rightAngle); + int endVal = SGMiscd::normalizePeriodic(0, 360, rwy->headingDeg() - rightAngle); // Turn into runway - createArc(ac, secondaryTarget, startVal ,endVal , firstTurnIncrement, initialTurnRadius, - waypoints.size()>0?waypoints.back()->getAltitude():alt, altDiff/4, vDescent, "turn%03d"); + createArc(ac, secondaryTarget, startVal, endVal, firstTurnIncrement, initialTurnRadius, + waypoints.size() > 0 ? waypoints.back()->getAltitude() : alt, altDiff / 4, vDescent, "turn%03d"); } else { SG_LOG(SG_AI, SG_BULK, ac->getCallSign() << "| Enter far S curve"); // Entering not "straight" into runway so we do a s-curve - int rightAngle = headingDiffRunway>0?90:-90; - int firstTurnIncrement = headingDiffRunway>0?2:-2; + int rightAngle = headingDiffRunway > 0 ? 90 : -90; + int firstTurnIncrement = headingDiffRunway > 0 ? 2 : -2; SGGeod firstTurnCenter = SGGeodesy::direct(current, ac->getTrueHeadingDeg() + rightAngle, initialTurnRadius); - int innerTangent = headingDiffRunway<0?0:1; + int innerTangent = headingDiffRunway < 0 ? 0 : 1; int offset = 1000; - while (SGGeodesy::distanceM(firstTurnCenter, secondaryTarget)<2*initialTurnRadius) { - secondaryTarget = rwy->pointOffCenterline(-2 * distanceOut + (offset+=1000), lateralOffset); + while (SGGeodesy::distanceM(firstTurnCenter, secondaryTarget) < 2 * initialTurnRadius) { + secondaryTarget = rwy->pointOffCenterline(-2 * distanceOut + (offset += 1000), lateralOffset); } - const double heading = VectorMath::innerTangentsAngle(firstTurnCenter, secondaryTarget, initialTurnRadius, initialTurnRadius )[innerTangent]; - createArc(ac, firstTurnCenter, ac->_getHeading()-rightAngle, heading-rightAngle, firstTurnIncrement, initialTurnRadius, waypoints.size()>0?waypoints.back()->getAltitude():alt, altDiff/8, vDescent, "far-initialturn%03d"); - double length = VectorMath::innerTangentsLength(firstTurnCenter, secondaryTarget, initialTurnRadius, initialTurnRadius ); - createLine(ac, waypoints.back()->getPos(), heading, length, waypoints.size()>0?waypoints.back()->getAltitude():alt, altDiff*0.75, vDescent, "descent%03d"); - int startVal = SGMiscd::normalizePeriodic(0, 360, heading+rightAngle); - int endVal = SGMiscd::normalizePeriodic(0, 360, rwy->headingDeg()+rightAngle); + const double dHeading = VectorMath::innerTangentsAngle(firstTurnCenter, secondaryTarget, initialTurnRadius, initialTurnRadius)[innerTangent]; + createArc(ac, firstTurnCenter, ac->_getHeading() - rightAngle, dHeading - rightAngle, firstTurnIncrement, initialTurnRadius, waypoints.size() > 0 ? waypoints.back()->getAltitude() : alt, altDiff / 8, vDescent, "far-initialturn%03d"); + double length = VectorMath::innerTangentsLength(firstTurnCenter, secondaryTarget, initialTurnRadius, initialTurnRadius); + createLine(ac, waypoints.back()->getPos(), dHeading, length, waypoints.size() > 0 ? waypoints.back()->getAltitude() : alt, altDiff * 0.75, vDescent, "descent%03d"); + int startVal = SGMiscd::normalizePeriodic(0, 360, dHeading + rightAngle); + int endVal = SGMiscd::normalizePeriodic(0, 360, rwy->headingDeg() + rightAngle); // Turn into runway - createArc(ac, secondaryTarget, startVal, endVal, firstTurnIncrement*-1, initialTurnRadius, - waypoints.size()>0?waypoints.back()->getAltitude():alt, altDiff/8, vDescent, "s-turn%03d"); + createArc(ac, secondaryTarget, startVal, endVal, firstTurnIncrement * -1, initialTurnRadius, + waypoints.size() > 0 ? waypoints.back()->getAltitude() : alt, altDiff / 8, vDescent, "s-turn%03d"); } - } else if (fabs(headingDiffRunway)>=150 ) { + } else if (fabs(headingDiffRunway) >= 150) { // We are entering downwind - if (distance < (2*initialTurnRadius)) { + if (distance < (2 * initialTurnRadius)) { // Too near so we pass over and enter over other side SG_LOG(SG_AI, SG_BULK, ac->getCallSign() << "| Enter near downrunway"); secondaryTarget = @@ -930,50 +894,50 @@ bool FGAIFlightPlan::createDescent(FGAIAircraft * ac, rwy->pointOffCenterline(-3 * distanceOut, -lateralOffset); // Entering not "straight" into runway so we do a s-curve - int rightAngle = azimuth>0?90:-90; - int firstTurnIncrement = azimuth>0?2:-2; + int rightAngle = azimuth > 0 ? 90 : -90; + int firstTurnIncrement = azimuth > 0 ? 2 : -2; SGGeod firstTurnCenter = SGGeodesy::direct(current, ac->getTrueHeadingDeg() + rightAngle, initialTurnRadius); // rwy->headingDeg()-rightAngle - int endVal = SGMiscd::normalizePeriodic(0, 360, rwy->headingDeg()-180); - SGGeod secondTurnCenter = SGGeodesy::direct(firstTurnCenter, endVal, 2*initialTurnRadius); - createArc(ac, firstTurnCenter, ac->_getHeading()-rightAngle, endVal, firstTurnIncrement, initialTurnRadius, waypoints.size()>0?waypoints.back()->getAltitude():alt, altDiff/4, vDescent, "d-near-initialturn%03d"); + int endVal = SGMiscd::normalizePeriodic(0, 360, rwy->headingDeg() - 180); + SGGeod secondTurnCenter = SGGeodesy::direct(firstTurnCenter, endVal, 2 * initialTurnRadius); + createArc(ac, firstTurnCenter, ac->_getHeading() - rightAngle, endVal, firstTurnIncrement, initialTurnRadius, waypoints.size() > 0 ? waypoints.back()->getAltitude() : alt, altDiff / 4, vDescent, "d-near-initialturn%03d"); endVal = SGMiscd::normalizePeriodic(0, 360, rwy->headingDeg()); // int endVal2 = SGMiscd::normalizePeriodic(0, 360, rwy->headingDeg()-rightAngle); - const double endVal2 = VectorMath::outerTangentsAngle(secondTurnCenter, secondaryTarget, initialTurnRadius, initialTurnRadius )[0]; - createArc(ac, secondTurnCenter, endVal, endVal2+rightAngle, -firstTurnIncrement, initialTurnRadius, waypoints.size()>0?waypoints.back()->getAltitude():alt, altDiff/4, vDescent, "secondturn%03d"); + const double endVal2 = VectorMath::outerTangentsAngle(secondTurnCenter, secondaryTarget, initialTurnRadius, initialTurnRadius)[0]; + createArc(ac, secondTurnCenter, endVal, endVal2 + rightAngle, -firstTurnIncrement, initialTurnRadius, waypoints.size() > 0 ? waypoints.back()->getAltitude() : alt, altDiff / 4, vDescent, "secondturn%03d"); //outer - double length = VectorMath::outerTangentsLength(secondTurnCenter, secondaryTarget, initialTurnRadius, initialTurnRadius ); - createLine(ac, waypoints.back()->getPos(), endVal2, length, waypoints.size()>0?waypoints.back()->getAltitude():alt, altDiff/4, vDescent, "descent%03d"); - endVal = SGMiscd::normalizePeriodic(0, 360, rwy->headingDeg()+rightAngle); + double length = VectorMath::outerTangentsLength(secondTurnCenter, secondaryTarget, initialTurnRadius, initialTurnRadius); + createLine(ac, waypoints.back()->getPos(), endVal2, length, waypoints.size() > 0 ? waypoints.back()->getAltitude() : alt, altDiff / 4, vDescent, "descent%03d"); + endVal = SGMiscd::normalizePeriodic(0, 360, rwy->headingDeg() + rightAngle); // Turn into runway - createArc(ac, secondaryTarget, endVal2+rightAngle, endVal, -firstTurnIncrement, initialTurnRadius, - waypoints.size()>0?waypoints.back()->getAltitude():alt, altDiff/4, vDescent, "turn%03d"); + createArc(ac, secondaryTarget, endVal2 + rightAngle, endVal, -firstTurnIncrement, initialTurnRadius, + waypoints.size() > 0 ? waypoints.back()->getAltitude() : alt, altDiff / 4, vDescent, "turn%03d"); } else { SG_LOG(SG_AI, SG_BULK, ac->getCallSign() << "| Enter far S downrunway"); // Entering not "straight" into runway so we do a s-curve - int rightAngle = headingDiffRunway>0?90:-90; - int firstTurnIncrement = headingDiffRunway>0?2:-2; - int innerTangent = headingDiffRunway<0?0:1; + int rightAngle = headingDiffRunway > 0 ? 90 : -90; + int firstTurnIncrement = headingDiffRunway > 0 ? 2 : -2; + int innerTangent = headingDiffRunway < 0 ? 0 : 1; SGGeod firstTurnCenter = SGGeodesy::direct(current, ac->getTrueHeadingDeg() + rightAngle, initialTurnRadius); - const double heading = VectorMath::innerTangentsAngle(firstTurnCenter, secondaryTarget, initialTurnRadius, initialTurnRadius )[innerTangent]; - createArc(ac, firstTurnCenter, ac->_getHeading()-rightAngle, heading-rightAngle, firstTurnIncrement, initialTurnRadius, waypoints.size()>0?waypoints.back()->getAltitude():alt, altDiff/3, vDescent, "d-far-initialturn%03d"); - double length = VectorMath::innerTangentsLength(firstTurnCenter, secondaryTarget, initialTurnRadius, initialTurnRadius ); - createLine(ac, waypoints.back()->getPos(), heading, length, waypoints.size()>0?waypoints.back()->getAltitude():alt, altDiff/3, vDescent, "descent%03d"); - int startVal = SGMiscd::normalizePeriodic(0, 360, heading+rightAngle); - int endVal = SGMiscd::normalizePeriodic(0, 360, rwy->headingDeg()+rightAngle); + const double dHeading = VectorMath::innerTangentsAngle(firstTurnCenter, secondaryTarget, initialTurnRadius, initialTurnRadius)[innerTangent]; + createArc(ac, firstTurnCenter, ac->_getHeading() - rightAngle, dHeading - rightAngle, firstTurnIncrement, initialTurnRadius, waypoints.size() > 0 ? waypoints.back()->getAltitude() : alt, altDiff / 3, vDescent, "d-far-initialturn%03d"); + double length = VectorMath::innerTangentsLength(firstTurnCenter, secondaryTarget, initialTurnRadius, initialTurnRadius); + createLine(ac, waypoints.back()->getPos(), dHeading, length, waypoints.size() > 0 ? waypoints.back()->getAltitude() : alt, altDiff / 3, vDescent, "descent%03d"); + int startVal = SGMiscd::normalizePeriodic(0, 360, dHeading + rightAngle); + int endVal = SGMiscd::normalizePeriodic(0, 360, rwy->headingDeg() + rightAngle); // Turn into runway createArc(ac, secondaryTarget, startVal, endVal, -firstTurnIncrement, initialTurnRadius, - waypoints.size()>0?waypoints.back()->getAltitude():alt, altDiff/3, vDescent, "d-s-turn%03d"); + waypoints.size() > 0 ? waypoints.back()->getAltitude() : alt, altDiff / 3, vDescent, "d-s-turn%03d"); } } else { SG_LOG(SG_AI, SG_BULK, ac->getCallSign() << "| Enter far straight"); // Entering "straight" into runway so only one turn - int rightAngle = headingDiffRunway>0?90:-90; + int rightAngle = headingDiffRunway > 0 ? 90 : -90; SGGeod firstTurnCenter = SGGeodesy::direct(current, ac->getTrueHeadingDeg() - rightAngle, initialTurnRadius); - int firstTurnIncrement = headingDiffRunway>0?-2:2; - const double heading = rwy->headingDeg(); - createArc(ac, firstTurnCenter, ac->_getHeading()+rightAngle, heading+rightAngle, firstTurnIncrement, initialTurnRadius, ac->getAltitude(), altDiff/3, vDescent, "straight_turn_%03d"); + int firstTurnIncrement = headingDiffRunway > 0 ? -2 : 2; + const double dHeading = rwy->headingDeg(); + createArc(ac, firstTurnCenter, ac->_getHeading() + rightAngle, dHeading + rightAngle, firstTurnIncrement, initialTurnRadius, ac->getAltitude(), altDiff / 3, vDescent, "straight_turn_%03d"); } time_t now = globals->get_time_params()->get_cur_time(); @@ -990,39 +954,38 @@ bool FGAIFlightPlan::createDescent(FGAIAircraft * ac, * Generate a hold flight path from the permission to land point * Exactly one hold pattern ******************************************************************/ -bool FGAIFlightPlan::createHold(FGAIAircraft * ac, - FGAirport * apt, - const SGGeod& current, - double speed, - double alt, - const string & fltType, - double requiredDistance) +bool FGAIFlightPlan::createHold(FGAIAircraft* ac, + FGAirport* apt, + const SGGeod& current, + double speed, + double alt, + const string& fltType, + double requiredDistance) { - //Beginning of Descent + // Beginning of Descent const string& rwyClass = getRunwayClassFromTrafficType(fltType); double vDescent = ac->getPerformance()->vDescent(); - double vApproach = ac->getPerformance()->vApproach(); + // double vApproach = ac->getPerformance()->vApproach(); double initialTurnRadius = getTurnRadius(vDescent, true); - double heading = ac->getTrueHeadingDeg(); + double dHeading = ac->getTrueHeadingDeg(); apt->getDynamics()->getActiveRunway(rwyClass, 2, activeRunway, - heading); + dHeading); if (!apt->hasRunwayWithIdent(activeRunway)) { - SG_LOG(SG_AI, SG_WARN, ac->getCallSign() << - "| FGAIFlightPlan::createHold: No such runway " << activeRunway << " at " << apt->ident()); + SG_LOG(SG_AI, SG_WARN, ac->getCallSign() << "| FGAIFlightPlan::createHold: No such runway " << activeRunway << " at " << apt->ident()); return false; } FGRunwayRef rwy = apt->getRunwayByIdent(activeRunway); double currentAltitude = waypoints.back()->getAltitude(); - double distanceOut = apt->getDynamics()->getApproachController()->getRunway(rwy->name())->getApproachDistance(); //12 * SG_NM_TO_METER; + double distanceOut = apt->getDynamics()->getApproachController()->getRunway(rwy->name())->getApproachDistance(); //12 * SG_NM_TO_METER; double lateralOffset = initialTurnRadius; SGGeod secondaryTarget = rwy->pointOffCenterline(-2 * distanceOut, lateralOffset); SGGeod secondHoldCenter = rwy->pointOffCenterline(-4 * distanceOut, lateralOffset); - createArc(ac, secondaryTarget, rwy->headingDeg()-90, rwy->headingDeg()+90, 5, initialTurnRadius, - currentAltitude, 0, vDescent, "hold_1_%03d"); - createArc(ac, secondHoldCenter, rwy->headingDeg()+90, rwy->headingDeg()-90, 5, initialTurnRadius, - currentAltitude, 0, vDescent, "hold_2_%03d"); + createArc(ac, secondaryTarget, rwy->headingDeg() - 90, rwy->headingDeg() + 90, 5, initialTurnRadius, + currentAltitude, 0, vDescent, "hold_1_%03d"); + createArc(ac, secondHoldCenter, rwy->headingDeg() + 90, rwy->headingDeg() - 90, 5, initialTurnRadius, + currentAltitude, 0, vDescent, "hold_2_%03d"); return true; } @@ -1032,40 +995,40 @@ bool FGAIFlightPlan::createHold(FGAIAircraft * ac, */ static double runwayGlideslopeTouchdownDistance(FGRunway* rwy) { - FGNavRecord* gs = rwy->glideslope(); - if (!gs) { - return -1; - } + FGNavRecord* gs = rwy->glideslope(); + if (!gs) { + return -1; + } - SGVec3d runwayPosCart = SGVec3d::fromGeod(rwy->pointOnCenterline(0.0)); - // compute a unit vector in ECF cartesian space, from the runway beginning to the end - SGVec3d runwayDirectionVec = normalize(SGVec3d::fromGeod(rwy->end()) - runwayPosCart); - SGVec3d gsTransmitterVec = gs->cart() - runwayPosCart; + SGVec3d runwayPosCart = SGVec3d::fromGeod(rwy->pointOnCenterline(0.0)); + // compute a unit vector in ECF cartesian space, from the runway beginning to the end + SGVec3d runwayDirectionVec = normalize(SGVec3d::fromGeod(rwy->end()) - runwayPosCart); + SGVec3d gsTransmitterVec = gs->cart() - runwayPosCart; -// project the gsTransmitterVec along the runwayDirctionVec to get out -// final value (in metres) - double dist = dot(runwayDirectionVec, gsTransmitterVec); - return dist; + // project the gsTransmitterVec along the runwayDirctionVec to get out + // final value (in metres) + double dist = dot(runwayDirectionVec, gsTransmitterVec); + return dist; } /******************************************************************* * CreateLanding (Leg 7) - * Create a flight path from the "permision to land" point (currently + * Create a flight path from the "permission to land" point (currently hardcoded at 5000 meters from the threshold) to the threshold, at a standard glide slope angle of 3 degrees. Position : 50.0354 8.52592 384 364 11112 ******************************************************************/ -bool FGAIFlightPlan::createLanding(FGAIAircraft * ac, FGAirport * apt, - const string & fltType) +bool FGAIFlightPlan::createLanding(FGAIAircraft* ac, FGAirport* apt, + const string& fltType) { double vTouchdown = ac->getPerformance()->vTouchdown(); - double vTaxi = ac->getPerformance()->vTaxi(); - double decel = ac->getPerformance()->decelerationOnGround(); + double vTaxi = ac->getPerformance()->vTaxi(); + double decel = ac->getPerformance()->decelerationOnGround(); double vApproach = ac->getPerformance()->vApproach(); - double vTouchdownMetric = vTouchdown * SG_KT_TO_MPS; - double vTaxiMetric = vTaxi * SG_KT_TO_MPS; - double decelMetric = decel * SG_KT_TO_MPS; + double vTouchdownMetric = vTouchdown * SG_KT_TO_MPS; + double vTaxiMetric = vTaxi * SG_KT_TO_MPS; + double decelMetric = decel * SG_KT_TO_MPS; char buffer[30]; if (!apt->hasRunwayWithIdent(activeRunway)) { @@ -1074,7 +1037,7 @@ bool FGAIFlightPlan::createLanding(FGAIAircraft * ac, FGAirport * apt, } - FGRunway * rwy = apt->getRunwayByIdent(activeRunway); + FGRunway* rwy = apt->getRunwayByIdent(activeRunway); if (!rwy) { return false; } @@ -1088,39 +1051,39 @@ bool FGAIFlightPlan::createLanding(FGAIAircraft * ac, FGAirport * apt, double touchdownDistance = runwayGlideslopeTouchdownDistance(rwy); if (touchdownDistance < 0.0) { - double landingLength = rwy->lengthM() - (rwy->displacedThresholdM()); - // touchdown 25% of the way along the landing area - touchdownDistance = rwy->displacedThresholdM() + (landingLength * 0.25); + double landingLength = rwy->lengthM() - (rwy->displacedThresholdM()); + // touchdown 25% of the way along the landing area + touchdownDistance = rwy->displacedThresholdM() + (landingLength * 0.25); } const double tanGlideslope = tan(3.0); SGGeod coord; - // find glideslope entry point, 2000' above touchdown elevation + // find glideslope entry point, 2000' above touchdown elevation double glideslopeEntry = -((2000 * SG_FEET_TO_METER) / tanGlideslope) + touchdownDistance; snprintf(buffer, sizeof(buffer), "Glideslope begin Rwy %s", activeRunway.c_str()); - FGAIWaypoint *wpt = createInAir(ac, buffer, rwy->pointOnCenterline(-glideslopeEntry), - currElev + 2000, vApproach); + FGAIWaypoint* wpt = createInAir(ac, buffer, rwy->pointOnCenterline(-glideslopeEntry), + currElev + 2000, vApproach); wpt->setGear_down(true); wpt->setFlaps(1.0f); wpt->setSpeedBrakes(1.0f); pushBackWaypoint(wpt); - // deceleration point, 500' above touchdown elevation - slow from approach speed - // to touchdown speed + // deceleration point, 500' above touchdown elevation - slow from approach speed + // to touchdown speed double decelPoint = -((500 * SG_FEET_TO_METER) / tanGlideslope) + touchdownDistance; wpt = createInAir(ac, "500' decel", rwy->pointOnCenterline(-decelPoint), - currElev + 500, vTouchdown); + currElev + 500, vTouchdown); wpt->setGear_down(true); wpt->setFlaps(1.0f); wpt->setSpeedBrakes(1.0f); pushBackWaypoint(wpt); - // compute elevation above the runway start, based on a 3-degree glideslope + // compute elevation above the runway start, based on a 3-degree glideslope double heightAboveRunwayStart = touchdownDistance * - tan(3.0 * SG_DEGREES_TO_RADIANS) * SG_METER_TO_FEET; + tan(3.0 * SG_DEGREES_TO_RADIANS) * SG_METER_TO_FEET; wpt = createInAir(ac, "CrossThreshold", rwy->begin(), heightAboveRunwayStart + currElev, vTouchdown); wpt->setGear_down(true); @@ -1132,10 +1095,10 @@ bool FGAIFlightPlan::createLanding(FGAIAircraft * ac, FGAirport * apt, SG_LOG(SG_AI, SG_BULK, "Landing " << glideslopeEntry << "\t" << decelPoint << " Rollout " << rolloutDistance); - int nPoints = (int)(rolloutDistance/60); + int nPoints = (int)(rolloutDistance / 60); for (int i = 1; i <= nPoints; i++) { snprintf(buffer, sizeof(buffer), "rollout%03d", i); - double t = 1-pow((double) (nPoints - i), 2) / pow(nPoints, 2); + double t = 1 - pow((double)(nPoints - i), 2) / pow(nPoints, 2); coord = rwy->pointOnCenterline(touchdownDistance + (rolloutDistance * t)); double vel = (vTouchdownMetric * (1.0 - t)) + (vTaxiMetric * t); wpt = createOnRunway(ac, buffer, coord, currElev, vel); @@ -1149,7 +1112,7 @@ bool FGAIFlightPlan::createLanding(FGAIAircraft * ac, FGAirport * apt, wpt->setSpeed(vTaxi); double mindist = (1.1 * rolloutDistance) + touchdownDistance; - FGGroundNetwork *gn = apt->groundNetwork(); + FGGroundNetwork* gn = apt->groundNetwork(); if (!gn) { SG_LOG(SG_AI, SG_DEBUG, "No groundnet " << apt->getId() << " no landing created."); return true; @@ -1178,18 +1141,18 @@ bool FGAIFlightPlan::createLanding(FGAIAircraft * ac, FGAirport * apt, * createParking Leg 9 * initialize the Aircraft at the parking location ******************************************************************/ -bool FGAIFlightPlan::createParking(FGAIAircraft * ac, FGAirport * apt, +bool FGAIFlightPlan::createParking(FGAIAircraft* ac, FGAirport* apt, double radius) { - FGAIWaypoint *wpt; + FGAIWaypoint* wpt; double aptElev = apt->getElevation(); double vTaxi = ac->getPerformance()->vTaxi(); double vTaxiReduced = vTaxi * (2.0 / 3.0); if (!gate.isValid()) { - wpt = createOnGround(ac, "END-ParkingInvalidGate", apt->geod(), aptElev, - vTaxiReduced); - pushBackWaypoint(wpt); - return true; + wpt = createOnGround(ac, "END-ParkingInvalidGate", apt->geod(), aptElev, + vTaxiReduced); + pushBackWaypoint(wpt); + return true; } FGParking* parking = gate.parking(); @@ -1204,37 +1167,37 @@ bool FGAIFlightPlan::createParking(FGAIAircraft * ac, FGAirport * apt, pushBackWaypoint(wpt); SGGeodesy::direct(parking->geod(), reverseHeading, 14, - pos, az); + pos, az); wpt = createOnGround(ac, "parking2", pos, aptElev, 3); pushBackWaypoint(wpt); SGGeodesy::direct(parking->geod(), reverseHeading, 10, - pos, az); + pos, az); wpt = createOnGround(ac, "parking3", pos, aptElev, 2); pushBackWaypoint(wpt); SGGeodesy::direct(parking->geod(), reverseHeading, 6, - pos, az); + pos, az); wpt = createOnGround(ac, "parking4", pos, aptElev, 2); pushBackWaypoint(wpt); SGGeodesy::direct(parking->geod(), reverseHeading, 3, - pos, az); + pos, az); wpt = createOnGround(ac, "parking5", pos, aptElev, 2); pushBackWaypoint(wpt); char buffer[30]; snprintf(buffer, sizeof(buffer), "Parking-%s", parking->getName().c_str()); - wpt = createOnGround(ac, buffer, parking->geod(), aptElev, vTaxiReduced/3); + wpt = createOnGround(ac, buffer, parking->geod(), aptElev, vTaxiReduced / 3); pushBackWaypoint(wpt); SGGeodesy::direct(parking->geod(), parking->getHeading(), 2, - pos, az); - wpt = createOnGround(ac, "Beyond-Parking", pos, aptElev, vTaxiReduced/3); + pos, az); + wpt = createOnGround(ac, "Beyond-Parking", pos, aptElev, vTaxiReduced / 3); pushBackWaypoint(wpt); SGGeodesy::direct(parking->geod(), parking->getHeading(), 3, - pos, az); - wpt = createOnGround(ac, "END-Parking", pos, aptElev, vTaxiReduced/3); + pos, az); + wpt = createOnGround(ac, "END-Parking", pos, aptElev, vTaxiReduced / 3); pushBackWaypoint(wpt); return true; } @@ -1250,10 +1213,10 @@ bool FGAIFlightPlan::createParking(FGAIAircraft * ac, FGAirport * apt, * * Currently valid traffic types for gate assignment: * - gate (commercial gate) - * - cargo (commercial gargo), - * - ga (general aviation) , - * - ul (ultralight), - * - mil-fighter (military - fighter), + * - cargo (commercial cargo) + * - ga (general aviation) + * - ul (ultralight) + * - mil-fighter (military - fighter) * - mil-transport (military - transport) * * Valid runway classes: @@ -1286,7 +1249,7 @@ double FGAIFlightPlan::getTurnRadius(double speed, bool inAir) if (inAir == false) { turn_radius = ((360 / 30) * fabs(speed)) / (2 * M_PI); } else { - turn_radius = 0.1911 * speed * speed; // an estimate for 25 degrees bank + turn_radius = 0.1911 * speed * speed; // an estimate for 25 degrees bank } return turn_radius; }