From 5000d212ec18ff6c1d76605eb55914e81ee2432f Mon Sep 17 00:00:00 2001
From: Csaba Halasz <Csaba.Halasz@gmail.com>
Date: Thu, 30 Sep 2010 01:05:04 +0200
Subject: [PATCH] Merged commit from Vivian Meazza: Rationalize methods
 (ea85e50c2093942164bbc02f371a0c05b259f9f4)

---
 src/AIModel/AIEscort.cxx | 17 ++++++++++++++++-
 src/AIModel/AIEscort.hxx |  8 +++-----
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/src/AIModel/AIEscort.cxx b/src/AIModel/AIEscort.cxx
index 873ed7174..927e62655 100644
--- a/src/AIModel/AIEscort.cxx
+++ b/src/AIModel/AIEscort.cxx
@@ -230,7 +230,6 @@ bool FGAIEscort::getGroundElev(SGGeod inpos) {
 
 }
 
-
 void FGAIEscort::setParent()
 {
     double lat = _selected_ac->getDoubleValue("position/latitude-deg");
@@ -269,6 +268,22 @@ void FGAIEscort::setParent()
 
 }
 
+void FGAIEscort::calcRangeBearing(double lat, double lon, double lat2, double lon2,
+                                  double &range, double &bearing) const
+{
+    // calculate the bearing and range of the second pos from the first
+    double az2, distance;
+    geo_inverse_wgs_84(lat, lon, lat2, lon2, &bearing, &az2, &distance);
+    range = distance * SG_METER_TO_NM;
+}
+
+double FGAIEscort::calcTrueBearingDeg(double bearing, double heading)
+{
+    double angle = bearing + heading;
+    SG_NORMALIZE_RANGE(angle, 0.0, 360.0);
+    return angle;
+}
+
 SGVec3d FGAIEscort::getCartHitchPosAt(const SGVec3d& _off) const {
     double hdg = _selected_ac->getDoubleValue("orientation/true-heading-deg");
     double pitch = _selected_ac->getDoubleValue("orientation/pitch-deg");
diff --git a/src/AIModel/AIEscort.hxx b/src/AIModel/AIEscort.hxx
index d2e21f5ae..96e997962 100644
--- a/src/AIModel/AIEscort.hxx
+++ b/src/AIModel/AIEscort.hxx
@@ -70,11 +70,9 @@ private:
 
     SGVec3d getCartHitchPosAt(const SGVec3d& off) const;
 
-//    void calcRangeBearing(double lat, double lon, double lat2, double lon2,
-//        double &range, double &bearing) const;
-    //double calcRelBearingDeg(double bearing, double heading);
-    //double calcTrueBearingDeg(double bearing, double heading);
-    //double calcRecipBearingDeg(double bearing);
+    void calcRangeBearing(double lat, double lon, double lat2, double lon2,
+        double &range, double &bearing) const;
+    double calcTrueBearingDeg(double bearing, double heading);
 
     SGGeod _selectedpos;
     SGGeod _tgtpos;