#include <iostream>
#include <simgear/route/waypoint.hxx>
-#include <Navaids/awynet.hxx>
+#include <Airports/simple.hxx>
#include <Airports/runways.hxx>
#include <Airports/dynamics.hxx>
#include "AIAircraft.hxx"
#include "performancedata.hxx"
-
using std::iostream;
+/*
void FGAIFlightPlan::evaluateRoutePart(double deplat,
double deplon,
double arrlat,
SGGeoc arr(SGGeoc::fromDegM(arrlon, arrlat, 100.0));
SGVec3d a = SGVec3d::fromGeoc(dep);
- SGVec3d b = SGVec3d::fromGeoc(arr);
- SGVec3d _cross = cross(b, a);
+ SGVec3d nb = normalize(SGVec3d::fromGeoc(arr));
+ SGVec3d na = normalize(a);
+
+ SGVec3d _cross = cross(nb, na);
- double angle = sgACos(dot(a, b));
+ double angle = acos(dot(na, nb));
+ const double angleStep = 0.05 * SG_DEGREES_TO_RADIANS;
tmpNode = 0;
- for (double ang = 0.0; ang < angle; ang += 0.05)
- {
- sgdVec3 newPos;
- sgdMat4 matrix;
- //cerr << "Angle = " << ang << endl;
- sgdMakeRotMat4(matrix, ang, _cross.data());
- for(int j = 0; j < 3; j++)
- {
- newPos[j] =0.0;
- for (int k = 0; k<3; k++)
- {
- newPos[j] += matrix[j][k]*a[k];
- }
- }
-
- //cerr << "1"<< endl;
- SGGeod geod = SGGeod::fromCart(SGVec3d(newPos[0], newPos[1], newPos[2]));
+ for (double ang = 0.0; ang < angle; ang += angleStep)
+ {
+ SGQuatd q = SGQuatd::fromAngleAxis(ang, _cross);
+ SGGeod geod = SGGeod::fromCart(q.transform(a));
prevNode = tmpNode;
tmpNode = globals->get_airwaynet()->findNearestNode(geod);
}
}
-
+*/
/*
void FGAIFlightPlan::createCruise(bool firstFlight, FGAirport *dep,
FGAirport *arr, double latitude,
init_waypoint->flaps_down= false;
init_waypoint->finished = false;
init_waypoint->on_ground = false;
- waypoints.push_back(init_waypoint);
+ pushBackWaypoint(init_waypoint);
routefile.append("Data/AI/FlightPlans");
snprintf(buffer, 32, "%s-%s.txt",
dep->getId().c_str(),
wpt->flaps_down= false;
wpt->finished = false;
wpt->on_ground = false;
- waypoints.push_back(wpt);
+ pushBackWaypoint(wpt);
}
if (!(routefile.exists()))
wpt->flaps_down= false;
wpt->finished = false;
wpt->on_ground = false;
- waypoints.push_back(wpt);
+ pushBackWaypoint(wpt);
}
*/
* Note that this is the original version that does not
* do any dynamic route computation.
******************************************************************/
-void FGAIFlightPlan::createCruise(FGAIAircraft *ac, bool firstFlight, FGAirport *dep,
+bool FGAIFlightPlan::createCruise(FGAIAircraft *ac, bool firstFlight, FGAirport *dep,
FGAirport *arr, double latitude,
double longitude, double speed,
double alt, const string& fltType)
{
double vCruise = ac->getPerformance()->vCruise();
- waypoint *wpt;
+ FGAIWaypoint *wpt;
wpt = createInAir(ac, "Cruise", SGGeod::fromDeg(longitude, latitude), alt, vCruise);
- waypoints.push_back(wpt);
+ pushBackWaypoint(wpt);
string rwyClass = getRunwayClassFromTrafficType(fltType);
double heading = ac->getTrafficRef()->getCourse();
arr->getDynamics()->getActiveRunway(rwyClass, 2, activeRunway, heading);
- rwy = arr->getRunwayByIdent(activeRunway);
+ FGRunway* rwy = arr->getRunwayByIdent(activeRunway);
+ assert( rwy != NULL );
// begin descent 110km out
- SGGeod beginDescentPoint = rwy->pointOnCenterline(-110000);
+ SGGeod beginDescentPoint = rwy->pointOnCenterline(0);
+ SGGeod secondaryDescentPoint = rwy->pointOnCenterline(-10000);
- wpt = createInAir(ac, "BOD", beginDescentPoint, alt, vCruise);
- waypoints.push_back(wpt);
+ wpt = createInAir(ac, "BOD", beginDescentPoint, alt, vCruise);
+ pushBackWaypoint(wpt);
+ wpt = createInAir(ac, "BOD2", secondaryDescentPoint, alt, vCruise);
+ pushBackWaypoint(wpt);
+ return true;
}