} waypoint;
- FGAIFlightPlan(const string& filename);
+ FGAIFlightPlan(const string& filename);
FGAIFlightPlan(const std::string& p,
double course,
time_t start,
double getLeadDistance( void ) const {return lead_distance;}
double getBearing(waypoint* previous, waypoint* next) const;
double getBearing(double lat, double lon, waypoint* next) const;
- time_t getStartTime() const { return start_time; };
+ time_t getStartTime() const { return start_time; }
void create(FGAirport *dep, FGAirport *arr, int leg, double alt, double speed, double lat, double lon,
bool firstLeg, double radius, const string& fltType, const string& aircraftType, const string& airline);
- void setLeg(int val) { leg = val;};
- void setTime(time_t st) { start_time = st; };
- int getGate() const { return gateId; };
- double getLeadInAngle() const { return leadInAngle; };
- const string& getRunway() const { return rwy._rwy_no; };
- const string& getRunwayId() const { return rwy._id; };
- void setRepeat(bool r) { repeat = r; };
- bool getRepeat(void) const { return repeat; };
+ void setLeg(int val) { leg = val;}
+ void setTime(time_t st) { start_time = st; }
+ int getGate() const { return gateId; }
+ double getLeadInAngle() const { return leadInAngle; }
+ const string& getRunway() const { return rwy._rwy_no; }
+ const string& getRunwayId() const { return rwy._id; }
+ void setRepeat(bool r) { repeat = r; }
+ bool getRepeat(void) const { return repeat; }
void restart(void);
- int getNrOfWayPoints() { return waypoints.size(); };
+ int getNrOfWayPoints() { return waypoints.size(); }
int getRouteIndex(int i); // returns the AI related index of this current routes.
- FGTaxiRoute *getTaxiRoute() { return taxiRoute; };
+ FGTaxiRoute *getTaxiRoute() { return taxiRoute; }
void deleteTaxiRoute();
- string getRunway() { return activeRunway; };
- bool isActive(time_t time) {return time >= this->getStartTime();};
+ string getRunway() { return activeRunway; }
+ bool isActive(time_t time) {return time >= this->getStartTime();}
private:
FGRunway rwy;
double distance_to_go;
double lead_distance;
double leadInAngle;
- time_t start_time;
+ time_t start_time;
int leg;
int gateId;
string activeRunway;
FGAirRoute airRoute;
FGTaxiRoute *taxiRoute;
-
- Point3D temp;
- sgdVec3 a, b, cross;
- sgdVec3 newPos;
- sgdMat4 matrix;
- double angle;
- double midlat, midlon;
- double course, distance;
-
void createPushBack(bool, FGAirport*, double, double, double, const string&, const string&, const string&);
void createTaxi(bool, int, FGAirport *, double, double, double, const string&, const string&, const string&);
void createTakeOff(bool, FGAirport *, double, const string&);
void evaluateRoutePart(double deplat, double deplon, double arrlat, double arrlon);
};
-
-
#endif // _FG_AIFLIGHTPLAN_HXX
SGWayPoint sec (arrlon,
arrlat,
100);
+ double course, distance;
first.CourseAndDistance(sec, &course, &distance);
distance *= SG_METER_TO_NM;
- temp = sgPolarToCart3d(Point3D(deplon *
- SG_DEGREES_TO_RADIANS,
- deplat *
- SG_DEGREES_TO_RADIANS,
- 1.0));
- a[0] = temp.x();
- a[1] = temp.y();
- a[2] = temp.z();
- temp = sgPolarToCart3d(Point3D(arrlon *
- SG_DEGREES_TO_RADIANS,
- arrlat *
- SG_DEGREES_TO_RADIANS,
- 1.0));
- b[0] = temp.x();
- b[1] = temp.y();
- b[2] = temp.z();
- sgdNormaliseVec3(a);
- sgdNormaliseVec3(b);
- sgdVectorProductVec3(cross,b,a);
+ SGVec3d a = SGVec3d::fromGeoc(SGGeoc::fromDegM(deplon, deplat, 1));
+ SGVec3d b = SGVec3d::fromGeoc(SGGeoc::fromDegM(arrlon, arrlat, 1));
+ SGVec3d _cross = cross(b, a);
- angle = sgACos(sgdScalarProductVec3(a,b));
+ double angle = sgACos(dot(a, b));
tmpNode = 0;
for (double ang = 0.0; ang < angle; ang += 0.05)
{
+ sgdVec3 newPos;
+ sgdMat4 matrix;
//cerr << "Angle = " << ang << endl;
- sgdMakeRotMat4(matrix, ang, cross);
+ sgdMakeRotMat4(matrix, ang, _cross.sg());
for(int j = 0; j < 3; j++)
{
newPos[j] =0.0;
}
}
//cerr << "1"<< endl;
- temp = sgCartToPolar3d(Point3D(newPos[0], newPos[1],newPos[2]));
- midlat = temp.lat() * SG_RADIANS_TO_DEGREES;
- midlon = temp.lon() * SG_RADIANS_TO_DEGREES;
+ SGGeoc geoc = SGGeoc::fromCart(SGVec3d(newPos[0], newPos[1], newPos[2]));
+ double midlat = geoc.getLatitudeDeg();
+ double midlon = geoc.getLongitudeDeg();
prevNode = tmpNode;
tmpNode = globals->get_airwaynet()->findNearestNode(midlat, midlon);
FGAIAircraft::update(dt);
Run(dt);
Transform();
-}
\ No newline at end of file
+}
{
FGAirport *dep;
FGAirport *arr;
- sgdVec3 a, b, cross;
- sgdVec3 newPos;
- sgdMat4 matrix;
double angle;
FGAIManager *aimgr;
double distanceToDest;
double speed;
- Point3D temp;
time_t
totalTimeEnroute,
elapsedTimeEnroute,
if (!(dep && arr))
return false;
- temp = sgPolarToCart3d(Point3D(dep->getLongitude() *
- SG_DEGREES_TO_RADIANS,
- dep->getLatitude() *
- SG_DEGREES_TO_RADIANS,
- 1.0));
- a[0] = temp.x();
- a[1] = temp.y();
- a[2] = temp.z();
+ SGVec3d a = SGVec3d::fromGeoc(SGGeoc::fromDegM(dep->getLongitude(),
+ dep->getLatitude(), 1));
+ SGVec3d b = SGVec3d::fromGeoc(SGGeoc::fromDegM(arr->getLongitude(),
+ arr->getLatitude(), 1));
+ SGVec3d _cross = cross(b, a);
- temp = sgPolarToCart3d(Point3D(arr->getLongitude() *
- SG_DEGREES_TO_RADIANS,
- arr->getLatitude() *
- SG_DEGREES_TO_RADIANS,
- 1.0));
- b[0] = temp.x();
- b[1] = temp.y();
- b[2] = temp.z();
- sgdNormaliseVec3(a);
- sgdNormaliseVec3(b);
- sgdVectorProductVec3(cross,b,a);
-
- angle = sgACos(sgdScalarProductVec3(a,b));
+ angle = sgACos(dot(a, b));
// Okay, at this point we have the angle between departure and
// arrival airport, in degrees. From here we can interpolate the
//cout << "a = " << a[0] << " " << a[1] << " " << a[2]
// << "b = " << b[0] << " " << b[1] << " " << b[2] << endl;
- sgdMakeRotMat4(matrix, angle, cross);
+ sgdMat4 matrix;
+ sgdMakeRotMat4(matrix, angle, _cross.sg());
+ SGVec3d newPos(0, 0, 0);
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];
}
}
- temp = sgCartToPolar3d(Point3D(newPos[0], newPos[1],newPos[2]));
if (now > (*i)->getDepartureTime())
{
- //cerr << "Lat = " << lat << ", lon = " << lon << endl;
- //cerr << "Time diff: " << now-i->getDepartureTime() << endl;
- lat = temp.lat() * SG_RADIANS_TO_DEGREES;
- lon = temp.lon() * SG_RADIANS_TO_DEGREES;
+ SGGeoc geoc = SGGeoc::fromCart(newPos);
+ lat = geoc.getLatitudeDeg();
+ lon = geoc.getLongitudeDeg();
}
else
{