]> git.mxchange.org Git - flightgear.git/commitdiff
Port over remaining Point3D usage to the more type and unit safe SG* classes.
authorfrohlich <frohlich>
Mon, 16 Mar 2009 16:37:39 +0000 (16:37 +0000)
committerTim Moore <timoore@redhat.com>
Wed, 18 Mar 2009 07:00:08 +0000 (08:00 +0100)
Remove leftover headers from plib/sg.

Modified Files:
  src/AIModel/AIBase.cxx
  src/AIModel/AIFlightPlanCreateCruise.cxx
  src/ATCDCL/AIEntity.cxx src/ATCDCL/AIEntity.hxx
  src/ATCDCL/AIGAVFRTraffic.cxx src/ATCDCL/AIGAVFRTraffic.hxx
  src/ATCDCL/AILocalTraffic.cxx src/ATCDCL/AILocalTraffic.hxx
  src/ATCDCL/AIMgr.cxx src/ATCDCL/ATC.hxx
  src/ATCDCL/ATCDialog.cxx src/ATCDCL/ATCProjection.cxx
  src/ATCDCL/ATCProjection.hxx src/ATCDCL/ATCutils.cxx
  src/ATCDCL/ATCutils.hxx src/ATCDCL/approach.cxx
  src/ATCDCL/commlist.cxx src/ATCDCL/ground.cxx
src/ATCDCL/ground.hxx src/ATCDCL/tower.cxx
  src/ATCDCL/tower.hxx src/Airports/calc_loc.cxx
  src/Airports/dynamics.cxx src/Airports/groundnetwork.cxx
  src/Airports/parking.cxx src/Airports/runwayprefs.cxx
  src/Airports/simple.cxx src/Cockpit/cockpit.cxx
  src/Cockpit/hud.hxx src/Cockpit/hud_card.cxx
  src/Cockpit/hud_rwy.cxx src/Environment/environment.cxx
  src/FDM/UFO.cxx src/FDM/SP/MagicCarpet.cxx src/GUI/dialog.hxx
  src/Instrumentation/HUD/HUD.hxx
  src/Instrumentation/HUD/HUD_runway.cxx
  src/Instrumentation/KLN89/kln89.cxx src/Main/fg_init.cxx
  src/Main/viewer.cxx src/Main/viewmgr.cxx
  src/Model/panelnode.cxx src/MultiPlayer/mpmessages.hxx
  src/Scenery/tilemgr.cxx src/Traffic/SchedFlight.cxx
  src/Traffic/TrafficMgr.cxx

46 files changed:
src/AIModel/AIBase.cxx
src/AIModel/AIFlightPlanCreateCruise.cxx
src/ATCDCL/AIEntity.cxx
src/ATCDCL/AIEntity.hxx
src/ATCDCL/AIGAVFRTraffic.cxx
src/ATCDCL/AIGAVFRTraffic.hxx
src/ATCDCL/AILocalTraffic.cxx
src/ATCDCL/AILocalTraffic.hxx
src/ATCDCL/AIMgr.cxx
src/ATCDCL/ATC.hxx
src/ATCDCL/ATCDialog.cxx
src/ATCDCL/ATCProjection.cxx
src/ATCDCL/ATCProjection.hxx
src/ATCDCL/ATCutils.cxx
src/ATCDCL/ATCutils.hxx
src/ATCDCL/approach.cxx
src/ATCDCL/commlist.cxx
src/ATCDCL/ground.cxx
src/ATCDCL/ground.hxx
src/ATCDCL/tower.cxx
src/ATCDCL/tower.hxx
src/Airports/calc_loc.cxx
src/Airports/dynamics.cxx
src/Airports/groundnetwork.cxx
src/Airports/parking.cxx
src/Airports/runwayprefs.cxx
src/Airports/simple.cxx
src/Cockpit/cockpit.cxx
src/Cockpit/hud.hxx
src/Cockpit/hud_card.cxx
src/Cockpit/hud_rwy.cxx
src/Environment/environment.cxx
src/FDM/SP/MagicCarpet.cxx
src/FDM/UFO.cxx
src/GUI/dialog.hxx
src/Instrumentation/HUD/HUD.hxx
src/Instrumentation/HUD/HUD_runway.cxx
src/Instrumentation/KLN89/kln89.cxx
src/Main/fg_init.cxx
src/Main/viewer.cxx
src/Main/viewmgr.cxx
src/Model/panelnode.cxx
src/MultiPlayer/mpmessages.hxx
src/Scenery/tilemgr.cxx
src/Traffic/SchedFlight.cxx
src/Traffic/TrafficMgr.cxx

index 5988ac8f6baae90256b6b4bde6d1614ed8e4e048..1ba3942eac45b69ac94587d2bc45726bb8aa1f2e 100644 (file)
@@ -32,9 +32,7 @@
 #include <osg/Node>
 #include <osgDB/FileUtils>
 
-#include <simgear/math/point3d.hxx>
-#include <simgear/math/polar3d.hxx>
-#include <simgear/math/sg_geodesy.hxx>
+#include <simgear/math/SGMath.hxx>
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/scene/model/modellib.hxx>
 #include <simgear/scene/util/SGNodeMasks.hxx>
index f1d50fdbad9757ab6bf2d3a07f79b5c4eaf06bcb..4f714cc8cd3f13af267ceb0a976e5aa3d0108ded 100755 (executable)
@@ -27,8 +27,6 @@
 #include <iostream>
 #include "AIFlightPlan.hxx"
 #include "AIAircraft.hxx"
-#include <simgear/math/polar3d.hxx>
-#include <simgear/math/sg_geodesy.hxx>
 #include <simgear/route/waypoint.hxx>
 
 #include <Navaids/awynet.hxx>
index aa741e3594c3f84d656f94d42927241ad1224121..0d3d764fdafc967711cab234133f61783972b0e7 100644 (file)
@@ -45,26 +45,21 @@ FGAIEntity::FGAIEntity() :
 }
 
 FGAIEntity::~FGAIEntity() {
-       //cout << "FGAIEntity dtor called..." << endl;
-       //cout << "Removing model from scene graph..." << endl;
-       globals->get_scenery()->get_scene_graph()->removeChild(_aip.getSceneGraph());
-
-       //cout << "Done!" << endl;
+    globals->get_scenery()->get_scene_graph()->removeChild(_aip.getSceneGraph());
 }
 
 void FGAIEntity::SetModel(osg::Node* model) {
-       _aip.init(model);
-       _aip.setVisible(false);
-       globals->get_scenery()->get_scene_graph()->addChild(_aip.getSceneGraph());
-
+    _aip.init(model);
+    _aip.setVisible(false);
+    globals->get_scenery()->get_scene_graph()->addChild(_aip.getSceneGraph());
 }
 
 void FGAIEntity::Update(double dt) {
 }
 
 const string &FGAIEntity::GetCallsign() {
-       static string s = "";
-       return(s);
+    static string s = "";
+    return(s);
 }
 
 void FGAIEntity::RegisterTransmission(int code) {
@@ -73,7 +68,7 @@ void FGAIEntity::RegisterTransmission(int code) {
 // Run the internal calculations
 //void FGAIEntity::Update() {
 void FGAIEntity::Transform() {
-    _aip.setPosition(_pos.lon(), _pos.lat(), _pos.elev() * SG_METER_TO_FEET);
+    _aip.setPosition(_pos);
     _aip.setOrientation(_roll, _pitch, _hdg);
     _aip.update();    
 }
index f85dae2176d3856675853441ddd3ea6a17752d14..5254c80996646c2d6280615177478b8646e40894 100644 (file)
 #ifndef _FG_AIEntity_HXX
 #define _FG_AIEntity_HXX
 
-#include <simgear/math/point3d.hxx>
+#include <simgear/math/SGMath.hxx>
 #include <simgear/scene/model/placement.hxx>
 
-
 /*****************************************************************
 *
 *  FGAIEntity - this class implements the minimum requirement
@@ -37,33 +36,34 @@ class FGAIEntity {
 
 public:
 
-       FGAIEntity();
+    FGAIEntity();
     virtual ~FGAIEntity();
        
-       // Set the 3D model to use (Must be called)
-  void SetModel(osg::Node* model);
+    // Set the 3D model to use (Must be called)
+    void SetModel(osg::Node* model);
 
     // Run the internal calculations
     virtual void Update(double dt)=0;
-       
+    
     // Send a transmission *TO* the AIEntity.
     // FIXME int code is a hack - eventually this will receive Alexander's coded messages.
     virtual void RegisterTransmission(int code)=0;
-       
-       inline const Point3D& GetPos() const { return(_pos); }
-       
-       virtual const string& GetCallsign()=0;
+    
+    const SGGeod& getPos() const
+    { return _pos; }
+    
+    virtual const string& GetCallsign()=0;
        
 protected:
-
-    Point3D _pos;      // WGS84 lat & lon in degrees, elev above sea-level in meters
-    double _hdg;               //True heading in degrees
+    
+    SGGeod _pos;       // Geodetic position
+    double _hdg;        //True heading in degrees
     double _roll;      //degrees
     double _pitch;     //degrees
 
     SGModelPlacement _aip;
     double _ground_elevation_m;
-
+    
     void Transform();
 };
 
index faaf41e643f29a3dcd21c9abc54f2975b65e33be..93a1f80cbdbd0edc960bb4aaad9020d0cd40b4fd 100644 (file)
@@ -23,9 +23,9 @@
 #  include <config.h>
 #endif
 
+#include <simgear/math/SGMath.hxx>
 #include <Airports/runways.hxx>
 #include <Main/globals.hxx>
-#include <simgear/math/point3d.hxx>
 #include <string>
 #include <math.h>
 
@@ -39,7 +39,7 @@ using std::string;
 #include "tower.hxx"
 
 // extern from Airports/simple.cxx
-extern Point3D fgGetAirportPos( const std::string& id );
+extern SGGeod fgGetAirportPos( const std::string& id );
 
 FGAIGAVFRTraffic::FGAIGAVFRTraffic() {
        ATC = globals->get_ATC_mgr();
@@ -71,7 +71,7 @@ FGAIGAVFRTraffic::~FGAIGAVFRTraffic() {
 
 // Init en-route to destID at point pt.
 // TODO - no idea what to do if pt is above planes ceiling due mountains!!
-bool FGAIGAVFRTraffic::Init(const Point3D& pt, const string& destID, const string& callsign) {
+bool FGAIGAVFRTraffic::Init(const SGGeod& pt, const string& destID, const string& callsign) {
        FGAILocalTraffic::Init(callsign, destID, EN_ROUTE);
        // TODO FIXME - to get up and running we're going to ignore elev and get FGAIMgr to 
        // pass in known good values for the test location.  Need to fix this!!! (or at least canonically decide who has responsibility for setting elev).
@@ -79,8 +79,8 @@ bool FGAIGAVFRTraffic::Init(const Point3D& pt, const string& destID, const strin
        _destID = destID;
        _pos = pt;
        _destPos = fgGetAirportPos(destID);     // TODO - check if we are within the tower catchment area already.
-       _cruise_alt = (_destPos.elev() + 2500.0) * SG_FEET_TO_METER;    // TODO look at terrain elevation as well
-       _pos.setelev(_cruise_alt);
+       _cruise_alt = (_destPos.getElevationM() + 2500.0) * SG_FEET_TO_METER;   // TODO look at terrain elevation as well
+       _pos.setElevationM(_cruise_alt);
        // initially set waypoint as airport location
        _wp = _destPos;
        // Set the initial track
@@ -120,7 +120,7 @@ void FGAIGAVFRTraffic::Update(double dt) {
                
                // we shouldn't really need this since there's a LOD of 10K on the whole plane anyway I think.
                // There are two _aip.setVisible statements set when _local = true that can be removed if the below is removed.
-               if(dclGetHorizontalSeparation(_pos, Point3D(fgGetDouble("/position/longitude-deg"), fgGetDouble("/position/latitude-deg"), 0.0)) > 8000) _aip.setVisible(false);
+               if(dclGetHorizontalSeparation(_pos, SGGeod::fromDegM(fgGetDouble("/position/longitude-deg"), fgGetDouble("/position/latitude-deg"), 0.0)) > 8000) _aip.setVisible(false);
                else _aip.setVisible(true);
                
        } else if(_local) {
@@ -133,7 +133,7 @@ void FGAIGAVFRTraffic::Update(double dt) {
 void FGAIGAVFRTraffic::FlyPlane(double dt) {
        if(_climbout) {
                // Check whether to level off
-               if(_pos.elev() >= _cruise_alt) {
+               if(_pos.getElevationM() >= _cruise_alt) {
                        slope = 0.0;
                        _pitch = 0.0;
                        IAS = _cruise_ias;              // FIXME - use smooth transistion to new speed and attitude.
@@ -163,7 +163,7 @@ void FGAIGAVFRTraffic::FlyPlane(double dt) {
                // Possibly check whether to start descent before this?
                //cout << "." << flush;
                //cout << "sep = " << dclGetHorizontalSeparation(_destPos, _pos) / 1600.0 << '\n';
-               if(dclGetHorizontalSeparation(_destPos, _pos) / 1600.0 < 8.0) {
+                if(dclGetHorizontalSeparation(_destPos, _pos) / 1600.0 < 8.0) {
                        //cout << "-" << flush;
                        if(!_towerContactedIncoming) {
                                //cout << "_" << flush;
@@ -214,10 +214,10 @@ void FGAIGAVFRTraffic::FlyPlane(double dt) {
                                        _wp = GetPatternApproachPos();
                                        //_hdg = GetHeadingFromTo(_pos, _wp);   // TODO - turn properly!
                                        SetTrack(GetHeadingFromTo(_pos, _wp));
-                                       slope = atan((_wp.elev() - _pos.elev()) / dclGetHorizontalSeparation(_wp, _pos)) * DCL_RADIANS_TO_DEGREES;
+                                       slope = atan((_wp.getElevationM() - _pos.getElevationM()) / dclGetHorizontalSeparation(_wp, _pos)) * DCL_RADIANS_TO_DEGREES;
                                        double thesh_offset = 0.0;
-                                       Point3D opos = ortho.ConvertToLocal(_pos);
-                                       double angToApt = atan((_pos.elev() - fgGetAirportElev(airportID)) / (opos.y() - thesh_offset)) * DCL_RADIANS_TO_DEGREES;
+                                       SGVec3d opos = ortho.ConvertToLocal(_pos);
+                                       double angToApt = atan((_pos.getElevationM() - fgGetAirportElev(airportID)) / (opos.y() - thesh_offset)) * DCL_RADIANS_TO_DEGREES;
                                        //cout << "angToApt = " << angToApt << ' ';
                                        slope = (angToApt > -5.0 ? 0.0 : angToApt);
                                        //cout << "slope = " << slope << '\n';
@@ -234,7 +234,7 @@ void FGAIGAVFRTraffic::FlyPlane(double dt) {
                                        _incoming = true;
                                        _wp = GetPatternApproachPos();
                                        SetTrack(GetHeadingFromTo(_pos, _wp));
-                                       slope = atan((_wp.elev() - _pos.elev()) / dclGetHorizontalSeparation(_wp, _pos)) * DCL_RADIANS_TO_DEGREES;
+                                       slope = atan((_wp.getElevationM() - _pos.getElevationM()) / dclGetHorizontalSeparation(_wp, _pos)) * DCL_RADIANS_TO_DEGREES;
                                        //cout << "slope = " << slope << '\n';
                                        pending_transmission = "Report ";
                                        pending_transmission += (patternDirection == 1 ? "right downwind " : "left downwind ");
@@ -245,15 +245,15 @@ void FGAIGAVFRTraffic::FlyPlane(double dt) {
                                        ConditionalTransmit(4);
                                }
                        }
-                       if(_pos.elev() < (fgGetAirportElev(airportID) + (1000.0 * SG_FEET_TO_METER))) slope = 0.0;      
+                       if(_pos.getElevationM() < (fgGetAirportElev(airportID) + (1000.0 * SG_FEET_TO_METER))) slope = 0.0;     
                }
        }
        if(_incoming) {
                //cout << "i" << '\n';
-               Point3D orthopos = ortho.ConvertToLocal(_pos);
+               SGVec3d orthopos = ortho.ConvertToLocal(_pos);
                // TODO - Check whether to start descent
                // become _local after the 3 mile report.
-               if(_pos.elev() < (fgGetAirportElev(airportID) + (1000.0 * SG_FEET_TO_METER))) slope = 0.0;      
+               if(_pos.getElevationM() < (fgGetAirportElev(airportID) + (1000.0 * SG_FEET_TO_METER))) slope = 0.0;     
                // TODO - work out why I needed to add the above line to stop the plane going underground!!!
                // (Although it's worth leaving it in as a robustness check anyway).
                if(_straightIn) {
@@ -264,9 +264,9 @@ void FGAIGAVFRTraffic::FlyPlane(double dt) {
                                //cout << "Established at " << orthopos << '\n';
                        }
                        double thesh_offset = 30.0;
-                       //cout << "orthopos.y = " << orthopos.y() << " alt = " << _pos.elev() - fgGetAirportElev(airportID) << '\n';
+                       //cout << "orthopos.y = " << orthopos.y() << " alt = " << _pos.getElevationM() - fgGetAirportElev(airportID) << '\n';
                        if(_established && (orthopos.y() > -5400.0)) {
-                               slope = atan((_pos.elev() - fgGetAirportElev(airportID)) / (orthopos.y() - thesh_offset)) * DCL_RADIANS_TO_DEGREES;
+                               slope = atan((_pos.getElevationM() - fgGetAirportElev(airportID)) / (orthopos.y() - thesh_offset)) * DCL_RADIANS_TO_DEGREES;
                                //cout << "slope0 = " << slope << '\n';
                        }
                        //cout << "slope1 = " << slope << '\n';
@@ -310,7 +310,7 @@ void FGAIGAVFRTraffic::FlyPlane(double dt) {
                        } else {
                                //cout << "D" << flush;
                                //cout << '\n' << dclGetHorizontalSeparation(_wp, _pos) << '\n';
-                               //cout << ortho.ConvertToLocal(_pos);
+                               //cout << ortho.ConvertToLocal(GetPos());
                                //cout << ortho.ConvertToLocal(_wp);
                                if(dclGetHorizontalSeparation(_wp, _pos) < 100.0) {
                                        pending_transmission = "2 miles out for ";
@@ -340,7 +340,6 @@ void FGAIGAVFRTraffic::FlyPlane(double dt) {
                slope = 0.0;
        }
        // FIXME - lots of hackery in the next six lines!!!!
-       //double track = _hdg;
        double crab = 0.0;      // This is a placeholder for when we take wind into account.    
        _hdg = track + crab;
        double vel = _cruise_ias;
@@ -425,31 +424,31 @@ int FGAIGAVFRTraffic::GetQuadrangleAltitude(int dir, int des_alt) {
 // 1/ A few miles out on extended centreline for straight-in.
 // 2/ At an appropriate point on circuit side of rwy for a 45deg entry to downwind.
 // 3/ At and appropriate point on non-circuit side of rwy at take-off end for perpendicular entry to circuit overflying end-of-rwy.
-Point3D FGAIGAVFRTraffic::GetPatternApproachPos() {
+SGGeod FGAIGAVFRTraffic::GetPatternApproachPos() {
        //cout << "\n\n";
        //cout << "Calculating pattern approach pos for " << plane.callsign << '\n';
-       Point3D orthopos = ortho.ConvertToLocal(_pos);
-       Point3D tmp;
+       SGVec3d orthopos = ortho.ConvertToLocal(_pos);
+       SGVec3d tmp;
        //cout << "patternDirection = " << patternDirection << '\n';
        if(orthopos.y() >= -1000.0) {   // Note that this has to be set the same as the calculation in tower.cxx - at the moment approach type is not transmitted properly between the two.
                //cout << "orthopos.x = " << orthopos.x() << '\n';
                if((orthopos.x() * patternDirection) > 0.0) {   // 45 deg entry
-                       tmp.setx(2000 * patternDirection);
-                       tmp.sety((rwy.end2ortho.y() / 2.0) + 2000);
-                       tmp.setelev(fgGetAirportElev(airportID) + (1000 * SG_FEET_TO_METER));
+                        tmp.x() = 2000 * patternDirection;
+                       tmp.y() = (rwy.end2ortho.y() / 2.0) + 2000;
+                       tmp.z() = (fgGetAirportElev(airportID) + (1000 * SG_FEET_TO_METER));
                        _e45 = true;
                        //cout << "45 deg entry... ";
                } else {
-                       tmp.setx(1000 * patternDirection * -1);
-                       tmp.sety(rwy.end2ortho.y());
-                       tmp.setelev(fgGetAirportElev(airportID) + (1000 * SG_FEET_TO_METER));
+                        tmp.x() = (1000 * patternDirection * -1);
+                       tmp.y() = (rwy.end2ortho.y());
+                       tmp.z() = (fgGetAirportElev(airportID) + (1000 * SG_FEET_TO_METER));
                        _e45 = false;
                        //cout << "90 deg entry... ";
                }
        } else {
-               tmp.setx(0);
-               tmp.sety(-5400);
-               tmp.setelev((5400.0 / 6.0) + fgGetAirportElev(airportID) + 10.0);
+               tmp.x() = 0;
+               tmp.y() = -5400;
+               tmp.z() = ((5400.0 / 6.0) + fgGetAirportElev(airportID) + 10.0);
                //cout << "Straight in... ";
        }
        //cout << "Waypoint is " << tmp << '\n';
index ce3870dcf111c36bb2944fa45a18ccd8b98a7457..fda97cf39671d78c4b02e6daf875d90699e5fcc8 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef _FG_AIGAVFRTraffic_HXX
 #define _FG_AIGAVFRTraffic_HXX
 
-#include <simgear/math/point3d.hxx>
+#include <simgear/math/SGMath.hxx>
 #include <Main/fg_props.hxx>
 
 #include "AILocalTraffic.hxx"
@@ -38,7 +38,7 @@ public:
        ~FGAIGAVFRTraffic();
        
        // Init en-route to destID at point pt. (lat, lon, elev) (elev in meters, lat and lon in degrees).
-       bool Init(const Point3D& pt, const string& destID, const string& callsign);
+       bool Init(const SGGeod& pt, const string& destID, const string& callsign);
        // Init at srcID to fly to destID
        bool Init(const string& srcID, const string& destID, const string& callsign, OperatingState state = PARKED);
        
@@ -96,14 +96,14 @@ private:
        bool _clearedStraightIn;
        bool _downwindEntry;
        bool _clearedDownwindEntry;
-       Point3D _wp;    // Next waypoint (ie. the one we're currently heading for)
+       SGGeod _wp;     // Next waypoint (ie. the one we're currently heading for)
        bool _enroute;
        string _destID;
        bool _climbout;
        double _cruise_alt;
        double _cruise_ias;
        double _cruise_climb_ias;
-       Point3D _destPos;
+       SGGeod _destPos;
        bool _local;
        bool _incoming;
        bool _established;
@@ -113,7 +113,7 @@ private:
        
        int GetQuadrangleAltitude(int dir, int des_alt);
        
-       Point3D GetPatternApproachPos();
+       SGGeod GetPatternApproachPos();
        
        void FlyPlane(double dt);
        
index 51399a2866ac4682e48dfda9f0549337e2bf0da8..0e81570aeb5b9f1c7137ab19b3a777556f3609c0 100644 (file)
@@ -39,8 +39,7 @@ during descent to avoid occasionally landing short or long.
 #include <Main/viewer.hxx>
 #include <Scenery/scenery.hxx>
 #include <Scenery/tilemgr.hxx>
-#include <simgear/math/point3d.hxx>
-#include <simgear/math/sg_geodesy.hxx>
+#include <simgear/math/SGMath.hxx>
 #include <simgear/misc/sg_path.hxx>
 #include <string>
 #include <math.h>
@@ -165,20 +164,18 @@ void FGAILocalTraffic::GetRwyDetails(const string& id) {
   
        // move to the +l end/center of the runway
                //cout << "Runway center is at " << runway._lon << ", " << runway._lat << '\n';
-       Point3D origin = Point3D(runway->longitude(), runway->latitude(), aptElev);
-               Point3D ref = origin;
        double tshlon, tshlat, tshr;
                double tolon, tolat, tor;
                rwy.length = runway->lengthM();
                rwy.width = runway->widthM();
-       geo_direct_wgs_84 ( aptElev, ref.lat(), ref.lon(), other_way, 
+       geo_direct_wgs_84 ( aptElev, runway->latitude(), runway->longitude(), other_way, 
                                rwy.length / 2.0 - 25.0, &tshlat, &tshlon, &tshr );
-       geo_direct_wgs_84 ( aptElev, ref.lat(), ref.lon(), hdg, 
+       geo_direct_wgs_84 ( aptElev, runway->latitude(), runway->longitude(), hdg, 
                                rwy.length / 2.0 - 25.0, &tolat, &tolon, &tor );
                // Note - 25 meters in from the runway end is a bit of a hack to put the plane ahead of the user.
                // now copy what we need out of runway into rwy
-       rwy.threshold_pos = Point3D(tshlon, tshlat, aptElev);
-               Point3D takeoff_end = Point3D(tolon, tolat, aptElev);
+       rwy.threshold_pos = SGGeod::fromDegM(tshlon, tshlat, aptElev);
+               SGGeod takeoff_end = SGGeod::fromDegM(tolon, tolat, aptElev);
                //cout << "Threshold position = " << tshlon << ", " << tshlat << ", " << aptElev << '\n';
                //cout << "Takeoff position = " << tolon << ", " << tolat << ", " << aptElev << '\n';
                rwy.hdg = hdg;
@@ -236,7 +233,7 @@ bool FGAILocalTraffic::Init(const string& callsign, const string& ICAO, Operatin
 
        //cout << "In Init(), initialState = " << initialState << endl;
        operatingState = initialState;
-       Point3D orthopos;
+       SGVec3d orthopos;
        switch(operatingState) {
        case PARKED:
                tuned_station = ground;
@@ -252,7 +249,7 @@ bool FGAILocalTraffic::Init(const string& callsign, const string& ICAO, Operatin
                vel = 0.0;
                slope = 0.0;
                _pos = ourGate->pos;
-               _pos.setelev(aptElev);
+               _pos.setElevationM(aptElev);
                _hdg = ourGate->heading;
                Transform();
                
@@ -275,10 +272,10 @@ bool FGAILocalTraffic::Init(const string& callsign, const string& ICAO, Operatin
                freeTaxi = true;
                // Set a position and orientation in an approximate place for hold short.
                //cout << "rwy.width = " << rwy.width << '\n';
-               orthopos = Point3D((rwy.width / 2.0 + 10.0) * -1.0, 0.0, 0.0);
+               orthopos = SGVec3d((rwy.width / 2.0 + 10.0) * -1.0, 0.0, 0.0);
                // TODO - set the x pos to be +ve if a RH parallel rwy.
                _pos = ortho.ConvertFromLocal(orthopos);
-               _pos.setelev(aptElev);
+               _pos.setElevationM(aptElev);
                _hdg = rwy.hdg + 90.0;
                // TODO - reset the heading if RH rwy.
                _pitch = 0.0;
@@ -318,8 +315,8 @@ bool FGAILocalTraffic::Init(const string& callsign, const string& ICAO, Operatin
                touchAndGo = false;
 
                if(initialLeg == DOWNWIND) {
-                       _pos = ortho.ConvertFromLocal(Point3D(1000*patternDirection, 800, 0.0));
-                       _pos.setelev(rwy.threshold_pos.elev() + 1000 * SG_FEET_TO_METER);
+                        _pos = ortho.ConvertFromLocal(SGVec3d(1000*patternDirection, 800, 0.0));
+                       _pos.setElevationM(rwy.threshold_pos.getElevationM() + 1000 * SG_FEET_TO_METER);
                        _hdg = rwy.hdg + 180.0;
                        leg = DOWNWIND;
                        elevInitGood = false;
@@ -337,9 +334,7 @@ bool FGAILocalTraffic::Init(const string& callsign, const string& ICAO, Operatin
                        Transform();
                } else {                        
                        // Default to initial position on threshold for now
-                       _pos.setlat(rwy.threshold_pos.lat());
-                       _pos.setlon(rwy.threshold_pos.lon());
-                       _pos.setelev(rwy.threshold_pos.elev());
+                        _pos = rwy.threshold_pos;
                        _hdg = rwy.hdg;
                        
                        // Now we've set the position we can do the ground elev
@@ -450,7 +445,7 @@ void FGAILocalTraffic::Update(double dt) {
        // we shouldn't really need this since there's a LOD of 10K on the whole plane anyway I think.
        // At the moment though I need to to avoid DList overflows - the whole plane LOD obviously isn't getting picked up.
        if(!_invisible) {
-               if(dclGetHorizontalSeparation(_pos, Point3D(fgGetDouble("/position/longitude-deg"), fgGetDouble("/position/latitude-deg"), 0.0)) > 8000) _aip.setVisible(false);
+                if(dclGetHorizontalSeparation(_pos, SGGeod::fromDegM(fgGetDouble("/position/longitude-deg"), fgGetDouble("/position/latitude-deg"), 0.0)) > 8000) _aip.setVisible(false);
                else _aip.setVisible(true);
        } else {
                _aip.setVisible(false);
@@ -567,7 +562,7 @@ void FGAILocalTraffic::Update(double dt) {
                        DoGroundElev();
                        if(!elevInitGood) {
                                if(_ground_elevation_m > -9990.0) {
-                                       _pos.setelev(_ground_elevation_m + wheelOffset);
+                                       _pos.setElevationM(_ground_elevation_m + wheelOffset);
                                        //cout << "TAKEOFF_ROLL, POS = " << pos.lon() << ", " << pos.lat() << ", " << pos.elev() << '\n';
                                        //Transform();
                                        _aip.setVisible(true);
@@ -585,7 +580,7 @@ void FGAILocalTraffic::Update(double dt) {
                if(!elevInitGood) {
                        //DoGroundElev();
                        if(_ground_elevation_m > -9990.0) {
-                               _pos.setelev(_ground_elevation_m + wheelOffset);
+                               _pos.setElevationM(_ground_elevation_m + wheelOffset);
                                //Transform();
                                _aip.setVisible(true);
                                //Transform();
@@ -611,7 +606,7 @@ void FGAILocalTraffic::Update(double dt) {
                                //cout << "C" << endl;
                                node* np = new node;
                                np->struct_type = NODE;
-                               np->pos = ortho.ConvertFromLocal(Point3D(0.0, 10.0, 0.0));
+                               np->pos = ortho.ConvertFromLocal(SGVec3d(0.0, 10.0, 0.0));
                                path.push_back(np);
                        } else {
                                //cout << "D" << endl;
@@ -645,7 +640,7 @@ void FGAILocalTraffic::Update(double dt) {
                if(!elevInitGood) {
                        DoGroundElev();
                        if(_ground_elevation_m > -9990.0) {
-                               _pos.setelev(_ground_elevation_m + wheelOffset);
+                               _pos.setElevationM(_ground_elevation_m + wheelOffset);
                                //Transform();
                                _aip.setVisible(true);
                                //Transform();
@@ -800,8 +795,8 @@ void FGAILocalTraffic::FlyTrafficPattern(double dt) {
        double turn_time = 60.0;        // seconds - TODO - check this guess
        double turn_circumference;
        double turn_radius;
-       Point3D orthopos = ortho.ConvertToLocal(_pos);  // ortho position of the plane
-       //cout << "runway elev = " << rwy.threshold_pos.elev() << ' ' << rwy.threshold_pos.elev() * SG_METER_TO_FEET << '\n';
+       SGVec3d orthopos = ortho.ConvertToLocal(_pos);  // ortho position of the plane
+       //cout << "runway elev = " << rwy.threshold_pos.getElevationM() << ' ' << rwy.threshold_pos.getElevationM() * SG_METER_TO_FEET << '\n';
        //cout << "elev = " << _pos.elev() << ' ' << _pos.elev() * SG_METER_TO_FEET << '\n';
 
        // HACK FOR TESTING - REMOVE
@@ -825,7 +820,7 @@ void FGAILocalTraffic::FlyTrafficPattern(double dt) {
                        vel += dveldt * dt;
                }
                if(_ground_elevation_m > -9990.0) {
-                       _pos.setelev(_ground_elevation_m + wheelOffset);
+                       _pos.setElevationM(_ground_elevation_m + wheelOffset);
                }
                IAS = vel + (cos((_hdg - wind_from) * DCL_DEGREES_TO_RADIANS) * wind_speed);
                if(IAS >= 70) {
@@ -843,7 +838,7 @@ void FGAILocalTraffic::FlyTrafficPattern(double dt) {
                // (decided in FGTower and accessed through GetCrosswindConstraint(...)).
                // According to AIM, traffic should climb to within 300ft of pattern altitude before commencing crosswind turn.
                // TODO - At hot 'n high airports this may be 500ft AGL though - need to make this a variable.
-               if((_pos.elev() - rwy.threshold_pos.elev()) * SG_METER_TO_FEET > 700) {
+               if((_pos.getElevationM() - rwy.threshold_pos.getElevationM()) * SG_METER_TO_FEET > 700) {
                        double cc = 0.0;
                        if(tower->GetCrosswindConstraint(cc)) {
                                if(orthopos.y() > cc) {
@@ -858,7 +853,7 @@ void FGAILocalTraffic::FlyTrafficPattern(double dt) {
                }
                // Need to check for levelling off in case we can't turn crosswind as soon
                // as we would like due to other traffic.
-               if((_pos.elev() - rwy.threshold_pos.elev()) * SG_METER_TO_FEET > 1000) {
+               if((_pos.getElevationM() - rwy.threshold_pos.getElevationM()) * SG_METER_TO_FEET > 1000) {
                        slope = 0.0;
                        _pitch = 0.0;
                        IAS = 80.0;             // FIXME - use smooth transistion to new speed and attitude.
@@ -880,7 +875,7 @@ void FGAILocalTraffic::FlyTrafficPattern(double dt) {
                break;
        case CROSSWIND:
                goAround = false;
-               if((_pos.elev() - rwy.threshold_pos.elev()) * SG_METER_TO_FEET > 1000) {
+               if((_pos.getElevationM() - rwy.threshold_pos.getElevationM()) * SG_METER_TO_FEET > 1000) {
                        slope = 0.0;
                        _pitch = 0.0;
                        IAS = 80.0;             // FIXME - use smooth transistion to new speed
@@ -902,7 +897,7 @@ void FGAILocalTraffic::FlyTrafficPattern(double dt) {
        case TURN2:
                SetTrack(rwy.hdg - (180 * patternDirection));
                // just in case we didn't make height on crosswind
-               if((_pos.elev() - rwy.threshold_pos.elev()) * SG_METER_TO_FEET > 1000) {
+               if((_pos.getElevationM() - rwy.threshold_pos.getElevationM()) * SG_METER_TO_FEET > 1000) {
                        slope = 0.0;
                        _pitch = 0.0;
                        IAS = 80.0;             // FIXME - use smooth transistion to new speed
@@ -914,12 +909,12 @@ void FGAILocalTraffic::FlyTrafficPattern(double dt) {
                break;
        case DOWNWIND:
                // just in case we didn't make height on crosswind
-               if(((_pos.elev() - rwy.threshold_pos.elev()) * SG_METER_TO_FEET > 995) && ((_pos.elev() - rwy.threshold_pos.elev()) * SG_METER_TO_FEET < 1015)) {
+               if(((_pos.getElevationM() - rwy.threshold_pos.getElevationM()) * SG_METER_TO_FEET > 995) && ((_pos.getElevationM() - rwy.threshold_pos.getElevationM()) * SG_METER_TO_FEET < 1015)) {
                        slope = 0.0;
                        _pitch = 0.0;
                        IAS = 90.0;             // FIXME - use smooth transistion to new speed
                }
-               if((_pos.elev() - rwy.threshold_pos.elev()) * SG_METER_TO_FEET >= 1015) {
+               if((_pos.getElevationM() - rwy.threshold_pos.getElevationM()) * SG_METER_TO_FEET >= 1015) {
                        slope = -1.0;
                        _pitch = -1.0;
                        IAS = 90.0;             // FIXME - use smooth transistion to new speed
@@ -1044,20 +1039,20 @@ void FGAILocalTraffic::FlyTrafficPattern(double dt) {
                if(descending) {
                        if(orthopos.y() < -50.0) {
                                double thesh_offset = 30.0;
-                               slope = atan((_pos.elev() - fgGetAirportElev(airportID)) / (orthopos.y() - thesh_offset)) * DCL_RADIANS_TO_DEGREES;
+                               slope = atan((_pos.getElevationM() - fgGetAirportElev(airportID)) / (orthopos.y() - thesh_offset)) * DCL_RADIANS_TO_DEGREES;
                                //cout << "slope = " << slope << ", elev = " << _pos.elev() << ", apt_elev = " << fgGetAirportElev(airportID) << ", op.y = " << orthopos.y() << '\n';
                                if(slope < -10.0) slope = -10.0;
                                _savedSlope = slope;
                                _pitch = -4.0;
                                IAS = 70.0;
                        } else {
-                               if(_pos.elev() < (rwy.threshold_pos.elev()+10.0+wheelOffset)) {
+                               if(_pos.getElevationM() < (rwy.threshold_pos.getElevationM()+10.0+wheelOffset)) {
                                        if(_ground_elevation_m > -9990.0) {
-                                               if(_pos.elev() < (_ground_elevation_m + wheelOffset + 1.0)) {
+                                               if(_pos.getElevationM() < (_ground_elevation_m + wheelOffset + 1.0)) {
                                                        slope = -2.0;
                                                        _pitch = 1.0;
                                                        IAS = 55.0;
-                                               } else if(_pos.elev() < (_ground_elevation_m + wheelOffset + 5.0)) {
+                                               } else if(_pos.getElevationM() < (_ground_elevation_m + wheelOffset + 5.0)) {
                                                        slope = -4.0;
                                                        _pitch = -2.0;
                                                        IAS = 60.0;
@@ -1082,15 +1077,15 @@ void FGAILocalTraffic::FlyTrafficPattern(double dt) {
                // Try and track the extended centreline
                SetTrack(rwy.hdg - (0.2 * orthopos.x()));
                //cout << "orthopos.x() = " << orthopos.x() << " hdg = " << hdg << '\n';
-               if(_pos.elev() < (rwy.threshold_pos.elev()+20.0+wheelOffset)) {
+               if(_pos.getElevationM() < (rwy.threshold_pos.getElevationM()+20.0+wheelOffset)) {
                        DoGroundElev(); // Need to call it here expicitly on final since it's only called
                                        // for us in update(...) when the inAir flag is false.
                }
-               if(_pos.elev() < (rwy.threshold_pos.elev()+10.0+wheelOffset)) {
+               if(_pos.getElevationM() < (rwy.threshold_pos.getElevationM()+10.0+wheelOffset)) {
                        //slope = -1.0;
                        //_pitch = 1.0;
                        if(_ground_elevation_m > -9990.0) {
-                               if((_ground_elevation_m + wheelOffset) > _pos.elev()) {
+                               if((_ground_elevation_m + wheelOffset) > _pos.getElevationM()) {
                                        slope = 0.0;
                                        _pitch = 0.0;
                                        leg = LANDING_ROLL;
@@ -1107,7 +1102,7 @@ void FGAILocalTraffic::FlyTrafficPattern(double dt) {
                //inAir = false;
                descending = false;
                if(_ground_elevation_m > -9990.0) {
-                       _pos.setelev(_ground_elevation_m + wheelOffset);
+                       _pos.setElevationM(_ground_elevation_m + wheelOffset);
                }
                track = rwy.hdg;
                dveldt = -5.0;
@@ -1289,7 +1284,7 @@ void FGAILocalTraffic::ProcessCallback(int code) {
        }
 }
 
-void FGAILocalTraffic::ExitRunway(const Point3D& orthopos) {
+void FGAILocalTraffic::ExitRunway(const SGVec3d& orthopos) {
        //cout << "In ExitRunway" << endl;
        //cout << "Runway ID is " << rwy.ID << endl;
        
@@ -1312,7 +1307,7 @@ void FGAILocalTraffic::ExitRunway(const Point3D& orthopos) {
                node* rwyExit = *(exitNodes.begin());
                //int gateID;           //This might want to be more persistant at some point
                while(nItr != exitNodes.end()) {
-                       d = ortho.ConvertToLocal((*nItr)->pos).y() - ortho.ConvertToLocal(_pos).y();    //FIXME - consider making orthopos a class variable
+                        d = ortho.ConvertToLocal((*nItr)->pos).y() - ortho.ConvertToLocal(_pos).y();   //FIXME - consider making orthopos a class variable
                        if(d > 0.0) {
                                if(d < dist) {
                                        dist = d;
@@ -1460,8 +1455,7 @@ void FGAILocalTraffic::Taxi(double dt) {
        // If we have reached turning point then get next point and turn onto that heading
        // Look out for the finish!!
 
-       //Point3D orthopos = ortho.ConvertToLocal(pos); // ortho position of the plane
-       desiredTaxiHeading = GetHeadingFromTo(_pos, nextTaxiNode->pos);
+        desiredTaxiHeading = GetHeadingFromTo(_pos, nextTaxiNode->pos);
        
        bool lastNode = (taxiPathPos == path.size() ? true : false);
        if(lastNode) {
@@ -1494,7 +1488,7 @@ void FGAILocalTraffic::Taxi(double dt) {
                _pos = dclUpdatePosition(_pos, track, slope, dist);
                //cout << "Updated position...\n";
                if(_ground_elevation_m > -9990) {
-                       _pos.setelev(_ground_elevation_m + wheelOffset);
+                       _pos.setElevationM(_ground_elevation_m + wheelOffset);
                } // else don't change the elev until we get a valid ground elev again!
        } else if(lastNode) {
                if(taxiState == TD_LINING_UP) {
@@ -1513,7 +1507,7 @@ void FGAILocalTraffic::Taxi(double dt) {
                                _pos = dclUpdatePosition(_pos, track, slope, dist);
                                //cout << "Updated position...\n";
                                if(_ground_elevation_m > -9990) {
-                                       _pos.setelev(_ground_elevation_m + wheelOffset);
+                                       _pos.setElevationM(_ground_elevation_m + wheelOffset);
                                } // else don't change the elev until we get a valid ground elev again!
                                if(fabs(_hdg - rwy.hdg) <= 1.0) {
                                        operatingState = IN_PATTERN;
@@ -1545,7 +1539,7 @@ void FGAILocalTraffic::DoGroundElev() {
        // Only do the proper hitlist stuff if we are within visible range of the viewer.
        double visibility_meters = fgGetDouble("/environment/visibility-m");
        FGViewer* vw = globals->get_current_view();
-       if(dclGetHorizontalSeparation(_pos, Point3D(vw->getLongitude_deg(), vw->getLatitude_deg(), 0.0)) > visibility_meters) {
+       if(dclGetHorizontalSeparation(_pos, SGGeod::fromDegM(vw->getLongitude_deg(), vw->getLatitude_deg(), 0.0)) > visibility_meters) {
                _ground_elevation_m = aptElev;
                return;
        }
index e2fb7ee6c5d77878f51ef866bb3137f1e2e2ed12..c62a9456e9a4ad8bf135a23e03888bac2e6a5775 100644 (file)
@@ -22,7 +22,7 @@
 #ifndef _FG_AILocalTraffic_HXX
 #define _FG_AILocalTraffic_HXX
 
-#include <simgear/math/point3d.hxx>
+#include <simgear/math/SGMath.hxx>
 #include <Main/fg_props.hxx>
 
 #include "AIPlane.hxx"
@@ -216,7 +216,7 @@ private:
 
        void CalculateSoD(double base_leg_pos, double downwind_leg_pos, bool pattern_direction);
 
-       void ExitRunway(const Point3D& orthopos);
+       void ExitRunway(const SGVec3d& orthopos);
 
        void StartTaxi();
 
index 36a97783ee2d86763812d1c34efabdd80c773b93..073acd7e77a4c89fd8030f8b53df5c4313dca537 100644 (file)
@@ -54,7 +54,7 @@ using std::cout;
 using namespace simgear;
 
 // extern from Airports/simple.cxx
-extern Point3D fgGetAirportPos( const std::string& id );
+extern SGGeod fgGetAirportPos( const std::string& id );
 
 FGAIMgr::FGAIMgr() {
        ATC = globals->get_ATC_mgr();
@@ -151,24 +151,6 @@ void FGAIMgr::init() {
        SearchByPos(15.0);
        
        initDone = true;
-       
-       //cout << "AIMgr::init done..." << endl;
-       
-       /*
-       // TESTING
-       FGATCAlignedProjection ortho;
-       ortho.Init(fgGetAirportPos("KEMT"), 205.0);     // Guess of rwy19 heading
-       //Point3D ip = ortho.ConvertFromLocal(Point3D(6000, 1000, 1000));       // 90 deg entry
-       //Point3D ip = ortho.ConvertFromLocal(Point3D(-7000, 3000, 1000));      // 45 deg entry
-       Point3D ip = ortho.ConvertFromLocal(Point3D(1000, -7000, 1000));        // straight-in
-       ATC->AIRegisterAirport("KEMT");
-       FGAIGAVFRTraffic* p = new FGAIGAVFRTraffic();
-       p->SetModel(_defaultModel);
-       p->Init(ip, "KEMT", GenerateShortForm(GenerateUniqueCallsign()));
-       ai_list.push_back(p);
-       traffic[ident].push_back(p);
-       activated["KEMT"] = 1;
-       */      
 }
 
 void FGAIMgr::bind() {
@@ -185,7 +167,7 @@ void FGAIMgr::update(double dt) {
        
        //cout << activated.size() << '\n';
        
-       Point3D userPos = Point3D(lon_node->getDoubleValue(), lat_node->getDoubleValue(), elev_node->getDoubleValue());
+        SGGeod userPos = SGGeod::fromDegM(lon_node->getDoubleValue(), lat_node->getDoubleValue(), elev_node->getDoubleValue());
        
        // TODO - make these class variables!!
        static int i = 0;
@@ -244,7 +226,7 @@ void FGAIMgr::update(double dt) {
                                //cout << "Size of list is " << (*it).second.size() << " at " << s << '\n';
                                if((*it).second.size()) {
                                        FGAIEntity* e = *((*it).second.rbegin());       // Get the last airplane currently scheduled to arrive at this airport.
-                                       cd = dclGetHorizontalSeparation(e->GetPos(), fgGetAirportPos(s));
+                                       cd = dclGetHorizontalSeparation(e->getPos(), fgGetAirportPos(s));
                                        if(cd < (d < 5000 ? 10000 : d + 5000)) {
                                                gen = true;
                                        }
@@ -340,11 +322,11 @@ void FGAIMgr::GenerateSimpleAirportTraffic(const string& ident, double min_dist)
        }
        */
        
-       Point3D aptpos = fgGetAirportPos(ident);        // TODO - check for elev of -9999
-       //cout << "ident = " << ident << ", elev = " << aptpos.elev() << '\n';
+       SGGeod aptpos = fgGetAirportPos(ident);         // TODO - check for elev of -9999
+       //cout << "ident = " << ident << ", elev = " << aptpos.getElevationM() << '\n';
        
        // Operate from airports at 3000ft and below only to avoid the default cloud layers and since we don't degrade AI performance with altitude.
-       if(aptpos.elev() > 3000) {
+       if(aptpos.getElevationM() > 3000) {
                //cout << "High alt airports not yet supported - returning\n";
                return;
        }
@@ -354,7 +336,7 @@ void FGAIMgr::GenerateSimpleAirportTraffic(const string& ident, double min_dist)
        
        // Get the time and only operate VFR in the (approximate) daytime.
        struct tm *t = globals->get_time_params()->getGmt();
-       int loc_time = t->tm_hour + int(aptpos.lon() / (360.0 / 24.0));
+       int loc_time = t->tm_hour + int(aptpos.getLongitudeDeg() / (360.0 / 24.0));
        while (loc_time < 0)
                loc_time += 24;
        while (loc_time >= 24)
@@ -367,7 +349,7 @@ void FGAIMgr::GenerateSimpleAirportTraffic(const string& ident, double min_dist)
        double visibility;
        FGEnvironment stationweather =
             ((FGEnvironmentMgr *)globals->get_subsystem("environment"))
-              ->getEnvironment(aptpos.lat(), aptpos.lon(), aptpos.elev());     // TODO - check whether this should take ft or m for elev.
+              ->getEnvironment(aptpos.getLatitudeDeg(), aptpos.getLongitudeDeg(), aptpos.getElevationM());     // TODO - check whether this should take ft or m for elev.
        visibility = stationweather.get_visibility_m();
        // Technically we can do VFR down to 1 mile (1600m) but that's pretty murky!
        //cout << "vis = " << visibility << '\n';
@@ -376,7 +358,7 @@ void FGAIMgr::GenerateSimpleAirportTraffic(const string& ident, double min_dist)
        ATC->AIRegisterAirport(ident);
        
        // Next - get the distance from user to the airport.
-       Point3D userpos = Point3D(lon_node->getDoubleValue(), lat_node->getDoubleValue(), elev_node->getDoubleValue());
+       SGGeod userpos = SGGeod::fromDegM(lon_node->getDoubleValue(), lat_node->getDoubleValue(), elev_node->getDoubleValue());
        double d = dclGetHorizontalSeparation(userpos, aptpos); // in meters
        
        int lev = fgGetInt("/sim/ai-traffic/level");
@@ -413,8 +395,8 @@ void FGAIMgr::GenerateSimpleAirportTraffic(const string& ident, double min_dist)
                        FGAIGAVFRTraffic* t = new FGAIGAVFRTraffic();
                        t->SetModel(cessna ? _defaultModel : _piperModel);
                        //cout << "Generating VFR traffic " << s << " inbound to " << ident << " " << ad << " meters out from " << dir << " degrees\n";
-                       Point3D tpos = dclUpdatePosition(aptpos, dir, 6.0, ad);
-                       if(tpos.elev() > (aptpos.elev() + 3000.0)) tpos.setelev(aptpos.elev() + 3000.0);
+                       SGGeod tpos = dclUpdatePosition(aptpos, dir, 6.0, ad);
+                       if(tpos.getElevationM() > (aptpos.getElevationM() + 3000.0)) tpos.setElevationM(aptpos.getElevationM() + 3000.0);
                        t->Init(tpos, ident, s);
                        ai_list.push_back(t);
                }
@@ -473,8 +455,8 @@ void FGAIMgr::GenerateSimpleAirportTraffic(const string& ident, double min_dist)
                        FGAIGAVFRTraffic* t = new FGAIGAVFRTraffic();
                        t->SetModel(cessna ? _defaultModel.get() : (_havePiperModel ? _piperModel.get() : _defaultModel.get()));
                        //cout << "Generating VFR traffic " << s << " inbound to " << ident << " " << ad << " meters out from " << dir << " degrees\n";
-                       Point3D tpos = dclUpdatePosition(aptpos, dir, 6.0, ad);
-                       if(tpos.elev() > (aptpos.elev() + 3000.0)) tpos.setelev(aptpos.elev() + 3000.0);        // FEET yuk :-(
+                       SGGeod tpos = dclUpdatePosition(aptpos, dir, 6.0, ad);
+                       if(tpos.getElevationM() > (aptpos.getElevationM() + 3000.0)) tpos.setElevationM(aptpos.getElevationM() + 3000.0);       // FEET yuk :-(
                        t->Init(tpos, ident, s);
                        ai_list.push_back(t);
                        traffic[ident].push_back(t);
@@ -522,8 +504,6 @@ void FGAIMgr::SearchByPos(double range) {
                                
                                //double rlon = lon * SGD_DEGREES_TO_RADIANS;
                                //double rlat = lat * SGD_DEGREES_TO_RADIANS;
-                               //Point3D aircraft = sgGeodToCart( Point3D(rlon, rlat, elev) );
-                               //Point3D airport;
                                for(; current != last; ++current) {
                                        //cout << "Found " << *current << endl;;
                                        if(activated.find(*current) == activated.end()) {
@@ -557,7 +537,7 @@ void FGAIMgr::SearchByPos(double range) {
                for(twd_itr = towered.begin(); twd_itr != towered.end(); twd_itr++) {
                        // Only activate the closest airport not already activated each time.
                        if(activated.find(twd_itr->ident) == activated.end()) {
-                               double sep = dclGetHorizontalSeparation(Point3D(lon, lat, elev), fgGetAirportPos(twd_itr->ident));
+                                double sep = dclGetHorizontalSeparation(SGGeod::fromDegM(lon, lat, elev), fgGetAirportPos(twd_itr->ident));
                                if(sep < closest) {
                                        closest = sep;
                                        s = twd_itr->ident;
index ecc9f5f603f4d9a4c8b4fd5d9454f087b81cf2a8..22bb8370b4acfcbd4be23f644d388a112c1dc5eb 100644 (file)
@@ -91,9 +91,9 @@ struct ATCData {
 // perhaps we could use an FGRunway instead of this.
 // That wouldn't cache the orthopos though.
 struct RunwayDetails {
-       Point3D threshold_pos;
-       Point3D end1ortho;      // ortho projection end1 (the threshold ATM)
-       Point3D end2ortho;      // ortho projection end2 (the take off end in the current hardwired scheme)
+       SGGeod threshold_pos;
+       SGVec3d end1ortho;      // ortho projection end1 (the threshold ATM)
+       SGVec3d end2ortho;      // ortho projection end2 (the take off end in the current hardwired scheme)
        double hdg;             // true runway heading
        double length;  // In *METERS*
        double width;   // ditto
@@ -297,8 +297,7 @@ operator >> ( std::istream& fin, ATCData& a )
        // cout << a.ident << endl;
        
        // generate cartesian coordinates
-       Point3D geod( a.lon * SGD_DEGREES_TO_RADIANS, a.lat * SGD_DEGREES_TO_RADIANS, a.elev );
-       Point3D cart = sgGeodToCart( geod );
+        SGVec3d cart = SGVec3d::fromGeod(SGGeod::fromRadM(a.lon, a.lat, a.elev));
        a.x = cart.x();
        a.y = cart.y();
        a.z = cart.z();
index 385e1f7356f5faa863b7cbded01d1cd1c385b812..5e548667ea999a88ef6aea4febbbfd8d5207a6e9 100644 (file)
@@ -322,8 +322,7 @@ void FGATCDialog::FreqDialog() {
        double lon = fgGetDouble("/position/longitude-deg");
        double lat = fgGetDouble("/position/latitude-deg");
        double elev = fgGetDouble("/position/altitude-ft");
-       Point3D aircraft = sgGeodToCart(Point3D(lon * SGD_DEGREES_TO_RADIANS,
-               lat * SGD_DEGREES_TO_RADIANS, elev));
+       SGVec3d aircraft = SGVec3d::fromGeod(SGGeod::fromDegM(lon, lat, elev));
 
        // search stations in range
        int num_stat = current_commlist->FindByPos(lon, lat, elev, 50.0, &atc_stations);
@@ -332,8 +331,8 @@ void FGATCDialog::FreqDialog() {
                // fill map (sorts by distance and removes duplicates)
                comm_list_iterator itr = atc_stations.begin();
                for (; itr != atc_stations.end(); ++itr) {
-                       Point3D station = Point3D(itr->x, itr->y, itr->z);
-                       double distance = aircraft.distance3Dsquared(station);
+                       SGVec3d station(itr->x, itr->y, itr->z);
+                       double distance = distSqr(aircraft, station);
                        uniq[atcdata(itr->ident, itr->name, distance)] = true;
                }
                // create button per map entry (modified copy of <button-template>)
index 5914594bcee6c8b3ac69857c24db60ba4af901b5..fb6b1bed4cbefd4647ba4c15cf213c6d98fb0896 100644 (file)
 #include <simgear/constants.h>
 
 FGATCAlignedProjection::FGATCAlignedProjection() {
-    _origin.setlat(0.0);
-    _origin.setlon(0.0);
-    _origin.setelev(0.0);
-    _correction_factor = cos(_origin.lat() * SG_DEGREES_TO_RADIANS);
+    _origin.setLatitudeRad(0);
+    _origin.setLongitudeRad(0);
+    _origin.setElevationM(0);
+    _correction_factor = cos(_origin.getLatitudeRad());
 }
 
-FGATCAlignedProjection::FGATCAlignedProjection(const Point3D& centre, double heading) {
+FGATCAlignedProjection::FGATCAlignedProjection(const SGGeod& centre, double heading) {
     _origin = centre;
     _theta = heading * SG_DEGREES_TO_RADIANS;
-    _correction_factor = cos(_origin.lat() * SG_DEGREES_TO_RADIANS);
+    _correction_factor = cos(_origin.getLatitudeRad());
 }
 
 FGATCAlignedProjection::~FGATCAlignedProjection() {
 }
 
-void FGATCAlignedProjection::Init(const Point3D& centre, double heading) {
+void FGATCAlignedProjection::Init(const SGGeod& centre, double heading) {
     _origin = centre;
     _theta = heading * SG_DEGREES_TO_RADIANS;
-    _correction_factor = cos(_origin.lat() * SG_DEGREES_TO_RADIANS);
+    _correction_factor = cos(_origin.getLatitudeRad());
 }
 
-Point3D FGATCAlignedProjection::ConvertToLocal(const Point3D& pt) {
+SGVec3d FGATCAlignedProjection::ConvertToLocal(const SGGeod& pt) {
     // convert from lat/lon to orthogonal
-    double delta_lat = pt.lat() - _origin.lat();
-    double delta_lon = pt.lon() - _origin.lon();
-    double y = sin(delta_lat * SG_DEGREES_TO_RADIANS) * SG_EQUATORIAL_RADIUS_M;
-    double x = sin(delta_lon * SG_DEGREES_TO_RADIANS) * SG_EQUATORIAL_RADIUS_M * _correction_factor;
+    double delta_lat = pt.getLatitudeRad() - _origin.getLatitudeRad();
+    double delta_lon = pt.getLongitudeRad() - _origin.getLongitudeRad();
+    double y = sin(delta_lat) * SG_EQUATORIAL_RADIUS_M;
+    double x = sin(delta_lon) * SG_EQUATORIAL_RADIUS_M * _correction_factor;
 
     // Align
     if(_theta != 0.0) {
@@ -62,18 +62,18 @@ Point3D FGATCAlignedProjection::ConvertToLocal(const Point3D& pt) {
         y = (xbar*sin(_theta)) + (y*cos(_theta));
     }
 
-    return(Point3D(x,y,pt.elev()));
+    return SGVec3d(x, y, pt.getElevationM());
 }
 
-Point3D FGATCAlignedProjection::ConvertFromLocal(const Point3D& pt) {
+SGGeod FGATCAlignedProjection::ConvertFromLocal(const SGVec3d& pt) {
     // de-align
     double thi = _theta * -1.0;
     double x = pt.x()*cos(thi) - pt.y()*sin(thi);
     double y = (pt.x()*sin(thi)) + (pt.y()*cos(thi));
 
     // convert from orthogonal to lat/lon
-    double delta_lat = asin(y / SG_EQUATORIAL_RADIUS_M) * SG_RADIANS_TO_DEGREES;
-    double delta_lon = (asin(x / SG_EQUATORIAL_RADIUS_M) * SG_RADIANS_TO_DEGREES) / _correction_factor;
+    double delta_lat = asin(y / SG_EQUATORIAL_RADIUS_M);
+    double delta_lon = asin(x / SG_EQUATORIAL_RADIUS_M) / _correction_factor;
 
-    return(Point3D(_origin.lon()+delta_lon, _origin.lat()+delta_lat, pt.elev()));
+    return SGGeod::fromRadM(_origin.getLongitudeRad()+delta_lon, _origin.getLatitudeRad()+delta_lat, pt.z());
 }
index d24e1eee5d55cd0cc0093970822505b1bd36548e..fbc93a0d624eabba117ee8ddac2651ee4d6e3dc5 100644 (file)
@@ -21,7 +21,7 @@
 #ifndef _FG_ATC_PROJECTION_HXX
 #define _FG_ATC_PROJECTION_HXX
 
-#include <simgear/math/point3d.hxx>
+#include <simgear/math/SGMath.hxx>
 
 // FGATCAlignedProjection - a class to project an area local to a runway onto an orthogonal co-ordinate system
 // with the origin at the threshold and the runway aligned with the y axis.
@@ -29,19 +29,19 @@ class FGATCAlignedProjection {
 
 public:
     FGATCAlignedProjection();
-    FGATCAlignedProjection(const Point3D& centre, double heading);
+    FGATCAlignedProjection(const SGGeod& centre, double heading);
     ~FGATCAlignedProjection();
 
-    void Init(const Point3D& centre, double heading);
+    void Init(const SGGeod& centre, double heading);
 
     // Convert a lat/lon co-ordinate (degrees) to the local projection (meters)
-    Point3D ConvertToLocal(const Point3D& pt);
+    SGVec3d ConvertToLocal(const SGGeod& pt);
 
     // Convert a local projection co-ordinate (meters) to lat/lon (degrees)
-    Point3D ConvertFromLocal(const Point3D& pt);
+    SGGeod ConvertFromLocal(const SGVec3d& pt);
 
 private:
-    Point3D _origin;   // lat/lon of local area origin (the threshold)
+    SGGeod _origin;    // lat/lon of local area origin (the threshold)
     double _theta;     // the rotation angle for alignment in radians
     double _correction_factor; // Reduction in surface distance per degree of longitude due to latitude.  Saves having to do a cos() every call.
 
index 20460524e4acd4adc92ab115c4cd152878c933c7..94eaff246e4d5615f3c45794c116892a5bf47f1c 100644 (file)
 
 #include <sstream>
 
-#include <math.h>
-#include <simgear/math/point3d.hxx>
+#include <simgear/math/SGMath.hxx>
 #include <simgear/constants.h>
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/debug/logstream.hxx>
-#include <plib/sg.h>
-//#include <iomanip.h>
 
 #include <Airports/runways.hxx>
 #include <Main/globals.hxx>
@@ -187,15 +184,15 @@ string GetCompassDirection(double h) {
 //================================================================================================================
 
 // Given two positions (lat & lon in degrees), get the HORIZONTAL separation (in meters)
-double dclGetHorizontalSeparation(const Point3D& pos1, const Point3D& pos2) {
+double dclGetHorizontalSeparation(const SGGeod& pos1, const SGGeod& pos2) {
        double x;       //East-West separation
        double y;       //North-South separation
        double z;       //Horizontal separation - z = sqrt(x^2 + y^2)
        
-       double lat1 = pos1.lat() * SG_DEGREES_TO_RADIANS;
-       double lon1 = pos1.lon() * SG_DEGREES_TO_RADIANS;
-       double lat2 = pos2.lat() * SG_DEGREES_TO_RADIANS;
-       double lon2 = pos2.lon() * SG_DEGREES_TO_RADIANS;
+       double lat1 = pos1.getLatitudeRad();
+       double lon1 = pos1.getLongitudeRad();
+       double lat2 = pos2.getLatitudeRad();
+       double lon2 = pos2.getLongitudeRad();
        
        y = sin(fabs(lat1 - lat2)) * SG_EQUATORIAL_RADIUS_M;
        x = sin(fabs(lon1 - lon2)) * SG_EQUATORIAL_RADIUS_M * (cos((lat1 + lat2) / 2.0));
@@ -226,13 +223,15 @@ double dclGetLinePointSeparation(double px, double py, double x1, double y1, dou
 // Given a position (lat/lon/elev), heading and vertical angle (degrees), and distance (meters), calculate the new position.
 // This function assumes the world is spherical.  If geodetic accuracy is required use the functions is sg_geodesy instead!
 // Assumes that the ground is not hit!!!  Expects heading and angle in degrees, distance in meters. 
-Point3D dclUpdatePosition(const Point3D& pos, double heading, double angle, double distance) {
+SGGeod dclUpdatePosition(const SGGeod& pos, double heading, double angle, double distance) {
+    // FIXME: use SGGeodesy instead ...
+
        //cout << setprecision(10) << pos.lon() << ' ' << pos.lat() << '\n';
        heading *= DCL_DEGREES_TO_RADIANS;
        angle *= DCL_DEGREES_TO_RADIANS;
-       double lat = pos.lat() * DCL_DEGREES_TO_RADIANS;
-       double lon = pos.lon() * DCL_DEGREES_TO_RADIANS;
-       double elev = pos.elev();
+       double lat = pos.getLatitudeRad();
+       double lon = pos.getLongitudeRad();
+       double elev = pos.getElevationM();
        //cout << setprecision(10) << lon*DCL_RADIANS_TO_DEGREES << ' ' << lat*DCL_RADIANS_TO_DEGREES << '\n';
        
        double horiz_dist = distance * cos(angle);
@@ -253,17 +252,17 @@ Point3D dclUpdatePosition(const Point3D& pos, double heading, double angle, doub
        
        //cout << setprecision(15) << DCL_DEGREES_TO_RADIANS * DCL_RADIANS_TO_DEGREES << '\n';
        
-       return(Point3D(lon*DCL_RADIANS_TO_DEGREES, lat*DCL_RADIANS_TO_DEGREES, elev));
+       return SGGeod::fromRadM(lon, lat, elev);
 }
 
 // Get a heading in degrees from one lat/lon to another.
 // This function assumes the world is spherical.  If geodetic accuracy is required use the functions is sg_geodesy instead!
 // Warning - at the moment we are not checking for identical points - currently it returns 0 in this instance.
-double GetHeadingFromTo(const Point3D& A, const Point3D& B) {
-       double latA = A.lat() * DCL_DEGREES_TO_RADIANS;
-       double lonA = A.lon() * DCL_DEGREES_TO_RADIANS;
-       double latB = B.lat() * DCL_DEGREES_TO_RADIANS;
-       double lonB = B.lon() * DCL_DEGREES_TO_RADIANS;
+double GetHeadingFromTo(const SGGeod& A, const SGGeod& B) {
+       double latA = A.getLatitudeRad();
+       double lonA = A.getLongitudeRad();
+       double latB = B.getLatitudeRad();
+       double lonB = B.getLongitudeRad();
        double xdist = sin(lonB - lonA) * (double)SG_EQUATORIAL_RADIUS_M * cos((latA+latB)/2.0);
        double ydist = sin(latB - latA) * (double)SG_EQUATORIAL_RADIUS_M;
        double heading = atan2(xdist, ydist) * DCL_RADIANS_TO_DEGREES;
@@ -292,14 +291,14 @@ double GetAngleDiff_deg( const double &a1, const double &a2) {
 }
 
 // Runway stuff
-// Given a Point3D (lon/lat/elev) and an FGRunway struct, determine if the point lies on the runway
-bool OnRunway(const Point3D& pt, const FGRunwayBase* rwy) {
+// Given (lon/lat/elev) and an FGRunway struct, determine if the point lies on the runway
+bool OnRunway(const SGGeod& pt, const FGRunwayBase* rwy) {
        FGATCAlignedProjection ortho;
-       Point3D centre(rwy->longitude(), rwy->latitude(), 0.0); // We don't need the elev
+       SGGeod centre = SGGeod::fromDegM(rwy->longitude(), rwy->latitude(), 0); // We don't need the elev
        ortho.Init(centre, rwy->headingDeg());
        
-       Point3D xyc = ortho.ConvertToLocal(centre);
-       Point3D xyp = ortho.ConvertToLocal(pt);
+       SGVec3d xyc = ortho.ConvertToLocal(centre);
+       SGVec3d xyp = ortho.ConvertToLocal(pt);
        
        //cout << "Length offset = " << fabs(xyp.y() - xyc.y()) << '\n';
        //cout << "Width offset = " << fabs(xyp.x() - xyc.x()) << '\n';
index c47c3469a0f5e9220b40314d75362606cf5688e0..b26a55cd0b0b01c22ed9be353e060a55e25ab0ce 100644 (file)
@@ -21,8 +21,8 @@
 #include <Airports/simple.hxx>
 #include <Airports/runways.hxx>
 
+#include <simgear/math/SGMath.hxx>
 #include <math.h>
-#include <simgear/math/point3d.hxx>
 #include <string>
 using std::string;
 
@@ -72,7 +72,7 @@ string GetCompassDirection(double h);
 ********************************/
 
 // Given two positions (lat & lon in degrees), get the HORIZONTAL separation (in meters)
-double dclGetHorizontalSeparation(const Point3D& pos1, const Point3D& pos2);
+double dclGetHorizontalSeparation(const SGGeod& pos1, const SGGeod& pos2);
 
 // Given a point and a line, get the HORIZONTAL shortest distance from the point to a point on the line.
 // Expects to be fed orthogonal co-ordinates, NOT lat & lon !
@@ -80,10 +80,10 @@ double dclGetLinePointSeparation(double px, double py, double x1, double y1, dou
 
 // Given a position (lat/lon/elev), heading, vertical angle, and distance, calculate the new position.
 // Assumes that the ground is not hit!!!  Expects heading and angle in degrees, distance in meters.
-Point3D dclUpdatePosition(const Point3D& pos, double heading, double angle, double distance);
+SGGeod dclUpdatePosition(const SGGeod& pos, double heading, double angle, double distance);
 
 // Get a heading from one lat/lon to another (in degrees)
-double GetHeadingFromTo(const Point3D& A, const Point3D& B);
+double GetHeadingFromTo(const SGGeod& A, const SGGeod& B);
 
 // Given a heading (in degrees), bound it from 0 -> 360
 void dclBoundHeading(double &hdg);
@@ -98,6 +98,6 @@ double GetAngleDiff_deg( const double &a1, const double &a2);
 *
 ****************/
 
-// Given a Point3D (lon/lat/elev) and an FGRunway struct, determine if the point lies on the runway
-bool OnRunway(const Point3D& pt, const FGRunwayBase* rwy);
+// Given (lon/lat/elev) and an FGRunway struct, determine if the point lies on the runway
+bool OnRunway(const SGGeod& pt, const FGRunwayBase* rwy);
 
index 6e75de47cd28c0b70beac0c901ccd8f974f5a00f..ed396b0d986966e0c8886138c1e5882fd6818441 100644 (file)
@@ -33,7 +33,6 @@
 #include <Airports/simple.hxx>
 
 #include <simgear/constants.h>
-#include <simgear/math/polar3d.hxx>
 #include <simgear/misc/sg_path.hxx>
 
 #include <Environment/environment_mgr.hxx>
@@ -413,9 +412,8 @@ void FGApproach::calc_wp( const int &i ) {
        
        int wpn = planes[i].wpn;
        // waypoint 0: Threshold of active runway
-       calc_gc_course_dist(Point3D(lon*SGD_DEGREES_TO_RADIANS, lat*SGD_DEGREES_TO_RADIANS, 0.0),
-                           Point3D(active_rw_lon*SGD_DEGREES_TO_RADIANS,active_rw_lat*SGD_DEGREES_TO_RADIANS, 0.0 ),
-                           &course, &d);
+        course = SGGeoc::courseRad(SGGeoc::fromDegM(lon, lat, 6e6), SGGeoc::fromDegM(active_rw_lon, active_rw_lat, 6e6));
+        d = SGGeoc::distanceM(SGGeoc::fromDegM(lon, lat, 6e6), SGGeoc::fromDegM(active_rw_lon, active_rw_lat, 6e6));
        double d1 = active_rw_hdg+180.0;
        if ( d1 > 360.0 ) d1 -=360.0;
        calc_cd_head_dist(360.0-course*SGD_RADIANS_TO_DEGREES, d/SG_NM_TO_METER, 
@@ -587,13 +585,9 @@ void FGApproach::update_plane_dat() {
     planes[i].hdg = hdg_node->getDoubleValue();
     planes[i].spd = speed_node->getDoubleValue();
 
-    /*Point3D aircraft = sgGeodToCart( Point3D(planes[i].lon*SGD_DEGREES_TO_RADIANS, 
-                                            planes[i].lat*SGD_DEGREES_TO_RADIANS, 
-                                            planes[i].alt*SG_FEET_TO_METER) );*/
     double course, distance;
-    calc_gc_course_dist(Point3D(lon*SGD_DEGREES_TO_RADIANS, lat*SGD_DEGREES_TO_RADIANS, 0.0),
-                       Point3D(planes[i].lon*SGD_DEGREES_TO_RADIANS,planes[i].lat*SGD_DEGREES_TO_RADIANS, 0.0 ),
-                       &course, &distance);
+    course = SGGeoc::courseRad(SGGeoc::fromDegM(lon, lat, 6e6), SGGeoc::fromDegM(planes[i].lon, active_rw_lat, 6e6));
+    distance = SGGeoc::distanceM(SGGeoc::fromDegM(lon, lat, 6e6), SGGeoc::fromDegM(planes[i].lon, active_rw_lat, 6e6));
     planes[i].dist = distance/SG_NM_TO_METER;
     planes[i].brg  = 360.0-course*SGD_RADIANS_TO_DEGREES;
 
index 034461d3de43865fb22cad0a7746f84072eaacaa..140b3f2da0f487e9b589cbd491b39479ef41631d 100644 (file)
@@ -32,7 +32,6 @@
 #include <Airports/simple.hxx>
 
 #include "commlist.hxx"
-//#include "atislist.hxx"
 #include "ATCutils.hxx"
 
 
@@ -115,9 +114,6 @@ bool FGCommList::LoadComms(const SGPath& path) {
 bool FGCommList::FindByFreq( double lon, double lat, double elev, double freq,
                                                ATCData* ad, atc_type tp )
 {
-       lon *= SGD_DEGREES_TO_RADIANS;
-       lat *= SGD_DEGREES_TO_RADIANS;
-       
        // HACK - if freq > 1000 assume it's in KHz, otherwise assume MHz.
        // A bit ugly but it works for now!!!!
        comm_list_type stations;
@@ -130,20 +126,18 @@ bool FGCommList::FindByFreq( double lon, double lat, double elev, double freq,
        comm_list_iterator last = stations.end();
        
        // double az1, az2, s;
-       Point3D aircraft = sgGeodToCart( Point3D(lon, lat, elev) );
-       Point3D station;
+       SGVec3d aircraft = SGVec3d::fromGeod(SGGeod::fromDegM(lon, lat, elev));
        const double orig_max_d = 1e100; 
        double max_d = orig_max_d;
-       double d;
        // TODO - at the moment this loop returns the first match found in range
        // We want to return the closest match in the event of a frequency conflict
        for ( ; current != last ; ++current ) {
                //cout << "testing " << current->get_ident() << endl;
-               station = Point3D(current->x, current->y, current->z);
+                SGVec3d station(current->x, current->y, current->z);
                //cout << "aircraft = " << aircraft << endl;
                //cout << "station = " << station << endl;
                
-               d = aircraft.distance3Dsquared( station );
+               double d = distSqr(aircraft, station);
                
                //cout << "  dist = " << sqrt(d)
                //     << "  range = " << current->range * SG_NM_TO_METER << endl;
@@ -192,17 +186,12 @@ int FGCommList::FindByPos(double lon, double lat, double elev, double range, com
                        comm_list_iterator current = Fstations.begin();
                        comm_list_iterator last = Fstations.end();
                        
-                       double rlon = lon * SGD_DEGREES_TO_RADIANS;
-                       double rlat = lat * SGD_DEGREES_TO_RADIANS;
-                       
                        // double az1, az2, s;
-                       Point3D aircraft = sgGeodToCart( Point3D(rlon, rlat, elev) );
-                       Point3D station;
-                       double d;
+                        SGVec3d aircraft = SGVec3d::fromGeod(SGGeod::fromDegM(lon, lat, elev));
                        for(; current != last; ++current) {
                                if((current->type == tp) || (tp == INVALID)) {
-                                       station = Point3D(current->x, current->y, current->z);
-                                       d = aircraft.distance3Dsquared( station );
+                                        SGVec3d station(current->x, current->y, current->z);
+                                       double d = distSqr(aircraft, station);
                                        // NOTE The below is squared since we match to distance3Dsquared (above) to avoid a sqrt.
                                        if ( d < (current->range * SG_NM_TO_METER
                                             * current->range * SG_NM_TO_METER ) ) {
@@ -238,11 +227,10 @@ double FGCommList::FindClosest( double lon, double lat, double elev, ATCData& ad
                        double tmp;
                        for(itr = stations.begin(); itr != stations.end(); ++itr) {     
                                ATCData ad2 = *itr;
-                               //Point3D p1(*itr.lon, *itr.lat, *itr.elev);
-                               Point3D p1(ad2.lon, ad2.lat, ad2.elev);
+                               SGGeod p1 = SGGeod::fromDegM(ad2.lon, ad2.lat, ad2.elev);
                                const FGAirport *a = fgFindAirportID(ad2.ident);
                                if (a) {
-                                       Point3D p2(lon, lat, elev);
+                                       SGGeod p2 = SGGeod::fromDegM(lon, lat, elev);
                                        tmp = dclGetHorizontalSeparation(p1, p2);
                                        if(tmp <= closest) {
                                                closest = tmp;
index 8f309e370264fa1c15c6595c3c4dc0f51b7ced70..db7b9abca3e49d54062a0a9d13402e5ad0ff6b53 100644 (file)
@@ -153,11 +153,11 @@ bool FGGround::LoadNetwork() {
                        fin >> buf;
                        np->nodeID = atoi(buf);
                        fin >> buf;
-                       np->pos.setlon(atof(buf));
+                       np->pos.setLongitudeDeg(atof(buf));
                        fin >> buf;
-                       np->pos.setlat(atof(buf));
+                       np->pos.setLatitudeDeg(atof(buf));
                        fin >> buf;
-                       np->pos.setelev(atof(buf));
+                       np->pos.setElevationM(atof(buf));
                        fin >> buf;             // node type
                        if(!strcmp(buf, "J")) {
                                np->type = JUNCTION;
@@ -241,11 +241,11 @@ bool FGGround::LoadNetwork() {
                        fin >> buf;
                        gp->nodeID = atoi(buf);
                        fin >> buf;
-                       gp->pos.setlon(atof(buf));
+                       gp->pos.setLongitudeDeg(atof(buf));
                        fin >> buf;
-                       gp->pos.setlat(atof(buf));
+                       gp->pos.setLatitudeDeg(atof(buf));
                        fin >> buf;
-                       gp->pos.setelev(atof(buf));
+                       gp->pos.setElevationM(atof(buf));
                        fin >> buf;             // gate type - ignore this for now
                        fin >> buf;             // gate heading
                        gp->heading = atoi(buf);
@@ -376,19 +376,17 @@ void FGGround::DoRwyDetails() {
   }
     // move to the +l end/center of the runway
   //cout << "Runway center is at " << runway._lon << ", " << runway._lat << '\n';
-    Point3D origin = Point3D(runway->longitude(), runway->latitude(), aptElev);
-  Point3D ref = origin;
-    double tshlon, tshlat, tshr;
+  double tshlon, tshlat, tshr;
   double tolon, tolat, tor;
   rwy.length = runway->lengthM();
-    geo_direct_wgs_84 ( aptElev, ref.lat(), ref.lon(), other_way, 
-                        rwy.length / 2.0 - 25.0, &tshlat, &tshlon, &tshr );
-    geo_direct_wgs_84 ( aptElev, ref.lat(), ref.lon(), runway->headingDeg(), 
-                        rwy.length / 2.0 - 25.0, &tolat, &tolon, &tor );
+  geo_direct_wgs_84 ( aptElev, runway->latitude(), runway->longitude(), other_way, 
+                      rwy.length / 2.0 - 25.0, &tshlat, &tshlon, &tshr );
+  geo_direct_wgs_84 ( aptElev, runway->latitude(), runway->longitude(), runway->headingDeg(), 
+                      rwy.length / 2.0 - 25.0, &tolat, &tolon, &tor );
   // Note - 25 meters in from the runway end is a bit of a hack to put the plane ahead of the user.
   // now copy what we need out of runway into rwy
-    rwy.threshold_pos = Point3D(tshlon, tshlat, aptElev);
-  Point3D takeoff_end = Point3D(tolon, tolat, aptElev);
+  rwy.threshold_pos = SGGeod::fromDegM(tshlon, tshlat, aptElev);
+  SGGeod takeoff_end = SGGeod::fromDegM(tolon, tolat, aptElev);
   //cout << "Threshold position = " << tshlon << ", " << tshlat << ", " << aptElev << '\n';
   //cout << "Takeoff position = " << tolon << ", " << tolat << ", " << aptElev << '\n';
   rwy.hdg = runway->headingDeg();
@@ -672,7 +670,6 @@ void FGGround::RequestDeparture(const PlaneRec& plane, FGAIEntity* requestee) {
        g->cleared = false;
        g->incoming = false;
        // TODO - need to handle the next 3 as well
-    //Point3D current_pos;
     //node* destination;
     //node* last_clearance;
        
index a94e3f252c233a90ab332c293efefc84905f28da..257ffdad86b3a5092266c9d36f441d23e3740dcd 100644 (file)
@@ -25,9 +25,8 @@
 #include <vector>
 #include <list>
 
-#include <simgear/math/point3d.hxx>
+#include <simgear/math/SGMath.hxx>
 #include <simgear/misc/sgstream.hxx>
-#include <simgear/math/sg_geodesy.hxx>
 #include <simgear/props/props.hxx>
 
 #include "ATC.hxx"
@@ -96,8 +95,8 @@ struct node : public ground_network_element {
        ~node();
        
        unsigned int nodeID;    //each node in an airport needs a unique ID number - this is ZERO-BASED to match array position
-       Point3D pos;
-       Point3D orthoPos;
+       SGGeod pos;
+       SGVec3d orthoPos;
        std::string name;
        node_type type;
        arc_array_type arcs;
@@ -178,14 +177,13 @@ typedef shortest_path_map_type::iterator shortest_path_map_iterator;
 
 // A more specialist plane rec to include ground information
 struct GroundRec {
-       FGAIEntity* planePtr;   // This might move to the planeRec eventually
+    FGAIEntity* planePtr;      // This might move to the planeRec eventually
        
     PlaneRec plane;
-    Point3D current_pos;
     node* destination;
     node* last_clearance;
-       bool taxiRequestOutstanding;    // Plane has requested taxi and we haven't responded yet
-       double clearanceCounter;                // Hack for communication timing - counter since clearance requested in seconds 
+    bool taxiRequestOutstanding;       // Plane has requested taxi and we haven't responded yet
+    double clearanceCounter;           // Hack for communication timing - counter since clearance requested in seconds 
        
     bool cleared;  // set true when the plane has been cleared to somewhere
     bool incoming; //true for arrivals, false for departures
@@ -197,19 +195,6 @@ typedef std::list < GroundRec* > ground_rec_list;
 typedef ground_rec_list::iterator ground_rec_list_itr;
 typedef ground_rec_list::const_iterator ground_rec_list_const_itr;
 
-//////////////////////////////////////////////////////////////////////////////////////////
-
-// Hack
-// perhaps we could use an FGRunway instead of this
-struct GRunwayDetails {
-       Point3D threshold_pos;
-       Point3D end1ortho;      // ortho projection end1 (the threshold ATM)
-       Point3D end2ortho;      // ortho projection end2 (the take off end in the current hardwired scheme)
-       double hdg;             // true runway heading
-       double length;  // In *METERS*
-       std::string rwyID;
-};
-
 ///////////////////////////////////////////////////////////////////////////////
 //
 // FGGround
index 52d50f9a83c6ddc30656c0955e11cd260ae8b0f6..e8d0b0db46a319bbb4f3951c664aa6310d7e76fb 100644 (file)
@@ -113,7 +113,7 @@ TowerPlaneRec::TowerPlaneRec(const PlaneRec& p) :
        plane = p;
 }
 
-TowerPlaneRec::TowerPlaneRec(const Point3D& pt) :
+TowerPlaneRec::TowerPlaneRec(const SGGeod& pt) :
        planePtr(NULL),
        clearedToLand(false),
        clearedToLineUp(false),
@@ -141,10 +141,10 @@ TowerPlaneRec::TowerPlaneRec(const Point3D& pt) :
        isUser(false)
 {
        plane.callsign = "UNKNOWN";
-       pos = pt;
+       pos = pt;
 }
 
-TowerPlaneRec::TowerPlaneRec(const PlaneRec& p, const Point3D& pt) :
+TowerPlaneRec::TowerPlaneRec(const PlaneRec& p, const SGGeod& pt) :
        planePtr(NULL),
        clearedToLand(false),
        clearedToLineUp(false),
@@ -172,7 +172,7 @@ TowerPlaneRec::TowerPlaneRec(const PlaneRec& p, const Point3D& pt) :
        isUser(false)
 {
        plane = p;
-       pos = pt;
+       pos = pt;
 }
 
 
@@ -320,9 +320,9 @@ void FGTower::Init() {
        DoRwyDetails();
        
        // TODO - this currently assumes only one active runway.
-       rwyOccupied = OnActiveRunway(Point3D(user_lon_node->getDoubleValue(), user_lat_node->getDoubleValue(), 0.0));
+       rwyOccupied = OnActiveRunway(SGGeod::fromDegM(user_lon_node->getDoubleValue(), user_lat_node->getDoubleValue(), 0.0));
        
-       if(!OnAnyRunway(Point3D(user_lon_node->getDoubleValue(), user_lat_node->getDoubleValue(), 0.0), false)) {
+       if(!OnAnyRunway(SGGeod::fromDegM(user_lon_node->getDoubleValue(), user_lat_node->getDoubleValue(), 0.0), false)) {
                //cout << ident << "  ADD 0\n";
                current_atcdialog->add_entry(ident, "@AP Tower, @CS @MI miles @CD of the airport for full stop@AT",
                                "Contact tower for VFR arrival (full stop)", TOWER,
@@ -449,22 +449,6 @@ void FGTower::Update(double dt) {
        
        // Call the base class update for the response time handling.
        FGATC::Update(dt);
-
-       /*
-       if(ident == "KEMT") {   
-               // For AI debugging convienience - may be removed
-               Point3D user_pos;
-               user_pos.setlon(user_lon_node->getDoubleValue());
-               user_pos.setlat(user_lat_node->getDoubleValue());
-               user_pos.setelev(user_elev_node->getDoubleValue());
-               Point3D user_ortho_pos = ortho.ConvertToLocal(user_pos);
-               fgSetDouble("/AI/user/ortho-x", user_ortho_pos.x());
-               fgSetDouble("/AI/user/ortho-y", user_ortho_pos.y());
-               fgSetDouble("/AI/user/elev", user_elev_node->getDoubleValue());
-       }
-       */
-       
-       //cout << "Done T" << endl;
 }
 
 void FGTower::ReceiveUserCallback(int code) {
@@ -507,7 +491,7 @@ void FGTower::Respond() {
                        // Should we clear staight in or for downwind entry?
                        // For now we'll clear straight in if greater than 1km from a line drawn through the threshold perpendicular to the rwy.
                        // Later on we might check the actual heading and direct some of those to enter on downwind or base.
-                       Point3D op = ortho.ConvertToLocal(t->pos);
+                       SGVec3d op = ortho.ConvertToLocal(t->pos);
                        float gp = fgGetFloat("/gear/gear/position-norm");
                        if(gp < 1)
                                t->gearWasUp = true; // This will be needed on final to tell "Gear down, ready to land."
@@ -558,7 +542,7 @@ void FGTower::Respond() {
                                trns += " Cleared for take-off" + wtr;
                                t->clearedToTakeOff = true;
                        } else {
-                               if(!OnAnyRunway(Point3D(user_lon_node->getDoubleValue(), user_lat_node->getDoubleValue(), 0.0), true)) {
+                               if(!OnAnyRunway(SGGeod::fromDegM(user_lon_node->getDoubleValue(), user_lat_node->getDoubleValue(), 0.0), true)) {
                                        // TODO: Check if any AI Planes on final and tell something like: "After the landing CALLSIGN line up runway two eight right"
                                        trns += " Line up runway " + ConvertRwyNumToSpokenString(activeRwy);
                                        t->clearedToTakeOff = false;
@@ -972,16 +956,16 @@ void FGTower::CheckCircuitList(double dt) {
                TowerPlaneRec* t = *circuitListItr;
                //cout << ident <<  ' ' << circuitList.size() << ' ' << t->plane.callsign << " " << t->leg << " eta " << t->eta << '\n';
                if(t->isUser) {
-                       t->pos.setlon(user_lon_node->getDoubleValue());
-                       t->pos.setlat(user_lat_node->getDoubleValue());
-                       t->pos.setelev(user_elev_node->getDoubleValue());
+                       t->pos.setLongitudeDeg(user_lon_node->getDoubleValue());
+                       t->pos.setLatitudeDeg(user_lat_node->getDoubleValue());
+                       t->pos.setElevationM(user_elev_node->getDoubleValue());
                        //cout << ident <<  ' ' << circuitList.size() << ' ' << t->plane.callsign << " " << t->leg << " eta " << t->eta << '\n';
                } else {
-                       t->pos = t->planePtr->GetPos();         // We should probably only set the pos's on one walk through the traffic list in the update function, to save a few CPU should we end up duplicating this.
+                       t->pos = t->planePtr->getPos();         // We should probably only set the pos's on one walk through the traffic list in the update function, to save a few CPU should we end up duplicating this.
                        t->landingType = t->planePtr->GetLandingOption();
                        //cout << "AI plane landing option is " << t->landingType << '\n';
                }
-               Point3D tortho = ortho.ConvertToLocal(t->pos);
+               SGVec3d tortho = ortho.ConvertToLocal(t->pos);
                if(t->isUser) {
                        // Need to figure out which leg he's on
                        //cout << "rwy.hdg = " << rwy.hdg << " user hdg = " << user_hdg_node->getDoubleValue();
@@ -1224,11 +1208,11 @@ void FGTower::CheckRunwayList(double dt) {
                        rwyListItr = rwyList.begin();
                        TowerPlaneRec* t = *rwyListItr;
                        if(t->isUser) {
-                               t->pos.setlon(user_lon_node->getDoubleValue());
-                               t->pos.setlat(user_lat_node->getDoubleValue());
-                               t->pos.setelev(user_elev_node->getDoubleValue());
+                               t->pos.setLongitudeDeg(user_lon_node->getDoubleValue());
+                               t->pos.setLatitudeDeg(user_lat_node->getDoubleValue());
+                               t->pos.setElevationM(user_elev_node->getDoubleValue());
                        } else {
-                               t->pos = t->planePtr->GetPos();         // We should probably only set the pos's on one walk through the traffic list in the update function, to save a few CPU should we end up duplicating this.
+                               t->pos = t->planePtr->getPos();         // We should probably only set the pos's on one walk through the traffic list in the update function, to save a few CPU should we end up duplicating this.
                        }
                        bool on_rwy = OnActiveRunway(t->pos);
                        if(!on_rwy) {
@@ -1288,15 +1272,15 @@ void FGTower::CheckApproachList(double dt) {
                //cout << "t = " << t << endl;
                //cout << "Checking " << t->plane.callsign << endl;
                if(t->isUser) {
-                       t->pos.setlon(user_lon_node->getDoubleValue());
-                       t->pos.setlat(user_lat_node->getDoubleValue());
-                       t->pos.setelev(user_elev_node->getDoubleValue());
+                       t->pos.setLongitudeDeg(user_lon_node->getDoubleValue());
+                       t->pos.setLatitudeDeg(user_lat_node->getDoubleValue());
+                       t->pos.setElevationM(user_elev_node->getDoubleValue());
                } else {
                        // TODO - set/update the position if it's an AI plane
                }
                doThresholdETACalc();   // We need this here because planes in the lists are not guaranteed to *always* have the correct ETA
                //cout << "eta is " << t->eta << ", rwy is " << (rwyList.size() ? "occupied " : "clear ") << '\n';
-               Point3D tortho = ortho.ConvertToLocal(t->pos);
+               SGVec3d tortho = ortho.ConvertToLocal(t->pos);
                if(t->eta < 12 && rwyList.size() && !(t->instructedToGoAround)) {
                        // TODO - need to make this more sophisticated 
                        // eg. is the plane accelerating down the runway taking off [OK],
@@ -1425,11 +1409,11 @@ void FGTower::CheckDepartureList(double dt) {
                //cout << "Dep list, checking " << t->plane.callsign;
                
                double distout; // meters
-               if(t->isUser) distout = dclGetHorizontalSeparation(Point3D(lon, lat, elev), Point3D(user_lon_node->getDoubleValue(), user_lat_node->getDoubleValue(), user_elev_node->getDoubleValue()));
-               else distout = dclGetHorizontalSeparation(Point3D(lon, lat, elev), t->planePtr->GetPos());
+               if(t->isUser) distout = dclGetHorizontalSeparation(SGGeod::fromDegM(lon, lat, elev), SGGeod::fromDegM(user_lon_node->getDoubleValue(), user_lat_node->getDoubleValue(), user_elev_node->getDoubleValue()));
+               else distout = dclGetHorizontalSeparation(SGGeod::fromDegM(lon, lat, elev), t->planePtr->getPos());
                //cout << " distout = " << distout << '\n';
                if(t->isUser && !(t->clearedToTakeOff)) {       // HACK - we use clearedToTakeOff to check if ATC already contacted with plane (and cleared take-off) or not
-                       if(!OnAnyRunway(Point3D(user_lon_node->getDoubleValue(), user_lat_node->getDoubleValue(), 0.0), false)) {
+                       if(!OnAnyRunway(SGGeod::fromDegM(user_lon_node->getDoubleValue(), user_lat_node->getDoubleValue(), 0.0), false)) {
                                current_atcdialog->remove_entry(ident, USER_REQUEST_TAKE_OFF, TOWER);
                                t->clearedToTakeOff = true;     // FIXME
                        }
@@ -1526,20 +1510,18 @@ void FGTower::DoRwyDetails() {
   }
     // move to the +l end/center of the runway
   //cout << "Runway center is at " << runway._lon << ", " << runway._lat << '\n';
-    Point3D origin = Point3D(runway->longitude(), runway->latitude(), aptElev);
-  Point3D ref = origin;
-    double tshlon, tshlat, tshr;
+  double tshlon, tshlat, tshr;
   double tolon, tolat, tor;
   rwy.length = runway->lengthM();
-    geo_direct_wgs_84 ( aptElev, ref.lat(), ref.lon(), other_way, 
-                        rwy.length / 2.0 - 25.0, &tshlat, &tshlon, &tshr );
-    geo_direct_wgs_84 ( aptElev, ref.lat(), ref.lon(), runway->headingDeg(), 
-                        rwy.length / 2.0 - 25.0, &tolat, &tolon, &tor );
-
+  geo_direct_wgs_84 ( aptElev, runway->latitude(), runway->longitude(), other_way, 
+                      rwy.length / 2.0 - 25.0, &tshlat, &tshlon, &tshr );
+  geo_direct_wgs_84 ( aptElev, runway->latitude(), runway->longitude(), runway->headingDeg(), 
+                      rwy.length / 2.0 - 25.0, &tolat, &tolon, &tor );
+  
   // Note - 25 meters in from the runway end is a bit of a hack to put the plane ahead of the user.
   // now copy what we need out of runway into rwy
-    rwy.threshold_pos = Point3D(tshlon, tshlat, aptElev);
-  Point3D takeoff_end = Point3D(tolon, tolat, aptElev);
+  rwy.threshold_pos = SGGeod::fromDegM(tshlon, tshlat, aptElev);
+  SGGeod takeoff_end = SGGeod::fromDegM(tolon, tolat, aptElev);
   //cout << "Threshold position = " << tshlon << ", " << tshlat << ", " << aptElev << '\n';
   //cout << "Takeoff position = " << tolon << ", " << tolat << ", " << aptElev << '\n';
   rwy.hdg = runway->headingDeg();
@@ -1561,10 +1543,10 @@ void FGTower::DoRwyDetails() {
 
 // Figure out if a given position lies on the active runway
 // Might have to change when we consider more than one active rwy.
-bool FGTower::OnActiveRunway(const Point3D& pt) {
+bool FGTower::OnActiveRunway(const SGGeod& pt) {
        // TODO - check that the centre calculation below isn't confused by displaced thesholds etc.
-       Point3D xyc((rwy.end1ortho.x() + rwy.end2ortho.x())/2.0, (rwy.end1ortho.y() + rwy.end2ortho.y())/2.0, 0.0);
-       Point3D xyp = ortho.ConvertToLocal(pt);
+       SGVec3d xyc((rwy.end1ortho.x() + rwy.end2ortho.x())/2.0, (rwy.end1ortho.y() + rwy.end2ortho.y())/2.0, 0.0);
+       SGVec3d xyp = ortho.ConvertToLocal(pt);
        
        //cout << "Length offset = " << fabs(xyp.y() - xyc.y()) << '\n';
        //cout << "Width offset = " << fabs(xyp.x() - xyc.x()) << '\n';
@@ -1579,7 +1561,7 @@ bool FGTower::OnActiveRunway(const Point3D& pt) {
 
 // Figure out if a given position lies on any runway or not
 // Only call this at startup - reading the runways database is expensive and needs to be fixed!
-bool FGTower::OnAnyRunway(const Point3D& pt, bool onGround) {
+bool FGTower::OnAnyRunway(const SGGeod& pt, bool onGround) {
        ATCData ad;
        double dist = current_commlist->FindClosest(lon, lat, elev, ad, TOWER, 7.0);
        if(dist < 0.0) {
@@ -1832,7 +1814,7 @@ void FGTower::CalcETA(TowerPlaneRec* tpr, bool printout) {
        // Sign convention - dist_out is -ve for approaching planes and +ve for departing planes
        // dist_across is +ve in the pattern direction - ie a plane correctly on downwind will have a +ve dist_across
        
-       Point3D op = ortho.ConvertToLocal(tpr->pos);
+       SGVec3d op = ortho.ConvertToLocal(tpr->pos);
        //if(printout) {
        //if(!tpr->isUser) cout << "Orthopos is " << op.x() << ", " << op.y() << ' ';
        //cout << "opType is " << tpr->opType << '\n';
@@ -1952,7 +1934,7 @@ void FGTower::doThresholdETACalc() {
        // Do the approach list first
        for(twrItr = appList.begin(); twrItr != appList.end(); twrItr++) {
                TowerPlaneRec* tpr = *twrItr;
-               if(!(tpr->isUser)) tpr->pos = tpr->planePtr->GetPos();
+               if(!(tpr->isUser)) tpr->pos = tpr->planePtr->getPos();
                //cout << "APP: ";
                CalcETA(tpr);
        }       
@@ -1960,7 +1942,7 @@ void FGTower::doThresholdETACalc() {
        //cout << "Circuit list size is " << circuitList.size() << '\n';
        for(twrItr = circuitList.begin(); twrItr != circuitList.end(); twrItr++) {
                TowerPlaneRec* tpr = *twrItr;
-               if(!(tpr->isUser)) tpr->pos = tpr->planePtr->GetPos();
+               if(!(tpr->isUser)) tpr->pos = tpr->planePtr->getPos();
                //cout << "CIRC: ";
                CalcETA(tpr);
        }
@@ -2051,7 +2033,7 @@ void FGTower::ContactAtHoldShort(const PlaneRec& plane, FGAIPlane* requestee, to
        t->clearedToLineUp = false;
        t->clearedToTakeOff = false;
        t->opType = operation;
-       t->pos = requestee->GetPos();
+       t->pos = requestee->getPos();
        
        //cout << "Hold Short reported by " << plane.callsign << '\n';
        SG_LOG(SG_ATC, SG_BULK, "Hold Short reported by " << plane.callsign);
@@ -2083,7 +2065,7 @@ void FGTower::RegisterAIPlane(const PlaneRec& plane, FGAIPlane* ai, const tower_
        t->planePtr = ai;
        t->opType = op;
        t->leg = lg;
-       t->pos = ai->GetPos();
+       t->pos = ai->getPos();
        
        CalcETA(t);
        
@@ -2117,9 +2099,9 @@ void FGTower::VFRArrivalContact(const string& ID, const LandingType& opt) {
                        //cout << "NOT t\n";
                        t = new TowerPlaneRec;
                        t->isUser = true;
-                       t->pos.setlon(user_lon_node->getDoubleValue());
-                       t->pos.setlat(user_lat_node->getDoubleValue());
-                       t->pos.setelev(user_elev_node->getDoubleValue());
+                       t->pos.setLongitudeDeg(user_lon_node->getDoubleValue());
+                       t->pos.setLatitudeDeg(user_lat_node->getDoubleValue());
+                       t->pos.setElevationM(user_elev_node->getDoubleValue());
                } else {
                        //cout << "IS t\n";
                        // Oops - the plane is already registered with this tower - maybe we took off and flew a giant circuit without
@@ -2163,7 +2145,7 @@ void FGTower::VFRArrivalContact(const PlaneRec& plane, FGAIPlane* requestee, con
        t->plane = plane;
        t->planePtr = requestee;
        t->landingType = lt;
-       t->pos = requestee->GetPos();
+       t->pos = requestee->getPos();
        
        //cout << "Hold Short reported by " << plane.callsign << '\n';
        SG_LOG(SG_ATC, SG_BULK, "VFR arrival contact made by " << plane.callsign);
@@ -2389,12 +2371,12 @@ void FGTower::ReportDownwind(const string& ID) {
                RemoveFromAppList(ID);
                t->leg = DOWNWIND;
                if(t->isUser) {
-                       t->pos.setlon(user_lon_node->getDoubleValue());
-                       t->pos.setlat(user_lat_node->getDoubleValue());
-                       t->pos.setelev(user_elev_node->getDoubleValue());
+                       t->pos.setLongitudeDeg(user_lon_node->getDoubleValue());
+                       t->pos.setLatitudeDeg(user_lat_node->getDoubleValue());
+                       t->pos.setElevationM(user_elev_node->getDoubleValue());
                } else {
                        // ASSERT(t->planePtr != NULL);
-                       t->pos = t->planePtr->GetPos();
+                       t->pos = t->planePtr->getPos();
                }
                CalcETA(t);
                AddToCircuitList(t);
@@ -2418,12 +2400,12 @@ void FGTower::ReportGoingAround(const string& ID) {
                RemoveFromAppList(ID);
                t->leg = CLIMBOUT;
                if(t->isUser) {
-                       t->pos.setlon(user_lon_node->getDoubleValue());
-                       t->pos.setlat(user_lat_node->getDoubleValue());
-                       t->pos.setelev(user_elev_node->getDoubleValue());
+                       t->pos.setLongitudeDeg(user_lon_node->getDoubleValue());
+                       t->pos.setLatitudeDeg(user_lat_node->getDoubleValue());
+                       t->pos.setElevationM(user_elev_node->getDoubleValue());
                } else {
                        // ASSERT(t->planePtr != NULL);
-                       t->pos = t->planePtr->GetPos();
+                       t->pos = t->planePtr->getPos();
                }
                CalcETA(t);
                AddToCircuitList(t);
@@ -2546,7 +2528,7 @@ string FGTower::GenText(const string& m, int c) {
                                        if (rwyOccupied) {
                                                tmp = "Ready for take-off";
                                        } else {
-                                               if (OnAnyRunway(Point3D(user_lon_node->getDoubleValue(),
+                                               if (OnAnyRunway(SGGeod::fromDegM(user_lon_node->getDoubleValue(),
                                                                user_lat_node->getDoubleValue(), 0.0),true)) {
                                                        tmp = "Request take-off clearance";
                                                } else {
@@ -2558,7 +2540,7 @@ string FGTower::GenText(const string& m, int c) {
                                else if ( strcmp ( tag, "@MI" ) == 0 ) {
                                        char buf[10];
                                        //sprintf( buf, "%3.1f", tpars.miles );
-                                       int dist_miles = (int)dclGetHorizontalSeparation(Point3D(lon, lat, elev), Point3D(user_lon_node->getDoubleValue(), user_lat_node->getDoubleValue(), user_elev_node->getDoubleValue())) / 1600;
+                                       int dist_miles = (int)dclGetHorizontalSeparation(SGGeod::fromDegM(lon, lat, elev), SGGeod::fromDegM(user_lon_node->getDoubleValue(), user_lat_node->getDoubleValue(), user_elev_node->getDoubleValue())) / 1600;
                                        sprintf(buf, "%i", dist_miles);
                                        strcat( &dum[0], &buf[0] );
                                }
@@ -2578,7 +2560,7 @@ string FGTower::GenText(const string& m, int c) {
                                        }
                                }
                                else if(strcmp(tag, "@CD") == 0) {      // @CD = compass direction
-                                       double h = GetHeadingFromTo(Point3D(lon, lat, elev), Point3D(user_lon_node->getDoubleValue(), user_lat_node->getDoubleValue(), user_elev_node->getDoubleValue()));
+                                       double h = GetHeadingFromTo(SGGeod::fromDegM(lon, lat, elev), SGGeod::fromDegM(user_lon_node->getDoubleValue(), user_lat_node->getDoubleValue(), user_elev_node->getDoubleValue()));
                                        while(h < 0.0) h += 360.0;
                                        while(h > 360.0) h -= 360.0;
                                        if(h < 22.5 || h > 337.5) {
index 2a4b5afc4b32c876c5f39cc7a704fbd8c87e3029..6a08f27c83d45d11cf881190332f5ba4d89f1ea9 100644 (file)
@@ -22,9 +22,8 @@
 #define _FG_TOWER_HXX
 
 #include <simgear/compiler.h>
-#include <simgear/math/point3d.hxx>
+#include <simgear/math/SGMath.hxx>
 #include <simgear/misc/sgstream.hxx>
-#include <plib/sg.h>
 
 #include <iosfwd>
 #include <string>
@@ -71,13 +70,13 @@ public:
        
        TowerPlaneRec();
        TowerPlaneRec(const PlaneRec& p);
-       TowerPlaneRec(const Point3D& pt);
-       TowerPlaneRec(const PlaneRec& p, const Point3D& pt);
+       TowerPlaneRec(const SGGeod& pt);
+       TowerPlaneRec(const PlaneRec& p, const SGGeod& pt);
        
        FGAIPlane* planePtr;    // This might move to the planeRec eventually
        PlaneRec plane;
        
-       Point3D pos;
+       SGGeod pos;
        double eta;             // seconds
        double dist_out;        // meters from theshold
        bool clearedToLand;
@@ -214,10 +213,10 @@ private:
        
        // Figure out if a given position lies on the active runway
        // Might have to change when we consider more than one active rwy.
-       bool OnActiveRunway(const Point3D& pt);
+       bool OnActiveRunway(const SGGeod& pt);
        
        // Figure out if a given position lies on a runway or not
-       bool OnAnyRunway(const Point3D& pt, bool onGround);
+       bool OnAnyRunway(const SGGeod& pt, bool onGround);
        
        // Calculate the eta of a plane to the threshold.
        // For ground traffic this is the fastest they can get there.
index 3ca71bef36b114948f5634f18b8337fed6dc4fb7..0b307402464a3a6d55d68fb8ef79f414afa8b1ca 100644 (file)
@@ -12,8 +12,6 @@
 #include <iostream>
 #include <string>
 
-#include <plib/sg.h>
-
 #include <simgear/math/sg_geodesy.hxx>
 
 
index fe8079075a0a6216a2d9bce5de31991350163ef3..b70f680be021dc00c616196e26b70acde1758109 100644 (file)
@@ -26,7 +26,6 @@
 
 #include <simgear/compiler.h>
 
-#include <plib/sg.h>
 #include <plib/ul.h>
 
 #include <Environment/environment_mgr.hxx>
@@ -561,4 +560,4 @@ int FGAirportDynamics::getGroundFrequency(int leg) {
 FGAIFlightPlan *FGAirportDynamics::getSID(string activeRunway, double heading)
 {
    return SIDs.getBest(activeRunway, heading);
-}
\ No newline at end of file
+}
index 9df9b5625d81ed7735a5d0d512224c4ddcc8dab0..877357229f0e12c878cc9136a405ec3bb446a1d8 100644 (file)
 #include <math.h>
 #include <algorithm>
 
-//#include <plib/sg.h>
-//#include <plib/ul.h>
-
-//#include <Environment/environment_mgr.hxx>
-//#include <Environment/environment.hxx>
-//#include <simgear/misc/sg_path.hxx>
-//#include <simgear/props/props.hxx>
-//#include <simgear/structure/subsystem_mgr.hxx>
 #include <simgear/debug/logstream.hxx>
 #include <simgear/route/waypoint.hxx>
-//#include <Main/globals.hxx>
-//#include <Main/fg_props.hxx>
-//#include <Airports/runways.hxx>
 
 #include <Airports/dynamics.hxx>
 
 #include <AIModel/AIFlightPlan.hxx>
 
-//#include <string>
-
 #include "groundnetwork.hxx"
 
 /***************************************************************************
index 525241d5917a45ce51282c7865b7d040835cc248..d1fb6512f5978c4d78c09b7a940807f76931beab 100644 (file)
 #  include <config.h>
 #endif
 
-//#include <algorithm>
-
 #include <simgear/compiler.h>
 
-//#include <plib/sg.h>
-//#include <plib/ul.h>
-
-//#include <Environment/environment_mgr.hxx>
-//#include <Environment/environment.hxx>
-//#include <simgear/misc/sg_path.hxx>
-//#include <simgear/props/props.hxx>
-//#include <simgear/structure/subsystem_mgr.hxx>
-//#include <simgear/debug/logstream.hxx>
-//#include <Main/globals.hxx>
-//#include <Main/fg_props.hxx>
-//#include <Airports/runways.hxx>
-
 #include <string>
 
 #include "parking.hxx"
index 3572275c0d8534d9683e274c5b692c1832fed748..af715ac3552b98a791d8486f522b98968be44ae7 100644 (file)
 #endif
 
 #include <math.h>
-//#include <algorithm>
 
 #include <simgear/compiler.h>
 
-//#include <plib/sg.h>
-//#include <plib/ul.h>
-
-//#include <Environment/environment_mgr.hxx>
-//#include <Environment/environment.hxx>
-//#include <simgear/misc/sg_path.hxx>
-//#include <simgear/props/props.hxx>
-//#include <simgear/structure/subsystem_mgr.hxx>
 #include <simgear/debug/logstream.hxx>
 #include <Main/globals.hxx>
-//#include <Main/fg_props.hxx>
 #include <Airports/runways.hxx>
 
 #include "runwayprefs.hxx"
index 7da4fa1a85a15588d8641a4f8c363fc52ac63d4a..6a1334cc10f40f53c30f4e31f01655f436a4446c 100644 (file)
@@ -313,7 +313,7 @@ double fgGetAirportElev( const string& id )
 
 
 // get airport position
-Point3D fgGetAirportPos( const string& id )
+SGGeod fgGetAirportPos( const string& id )
 {
     SG_LOG( SG_ATC, SG_BULK,
             "Finding position for airport: " << id );
@@ -321,8 +321,8 @@ Point3D fgGetAirportPos( const string& id )
     const FGAirport *a = fgFindAirportID( id);
 
     if (a) {
-        return Point3D(a->getLongitude(), a->getLatitude(), a->getElevation());
+        return SGGeod::fromDegM(a->getLongitude(), a->getLatitude(), a->getElevation());
     } else {
-        return Point3D(0.0, 0.0, -9999.0);
+        return SGGeod::fromDegM(0.0, 0.0, -9999.0);
     }
 }
index e9eb1fc7fd6187c8e9a907a467b9e1928f2bc6cf..3865ce718f57cb4a144ed09c7ecd0214e800c7eb 100644 (file)
@@ -33,7 +33,6 @@
 
 #include <simgear/constants.h>
 #include <simgear/debug/logstream.hxx>
-#include <simgear/math/polar3d.hxx>
 #include <simgear/props/props.hxx>
 #include <simgear/timing/sg_time.hxx>
 
index 831aa00f59c77817ce5a8e1c4c9850dc5a0769f8..0ce27ec3003883ce621793cc2cb23a435f16090b 100644 (file)
@@ -62,8 +62,6 @@ namespace osg {
 #include <Main/globals.hxx>
 #include <Main/viewmgr.hxx>
 
-#include <plib/sg.h>
-
 class FGRunway;
 
 using std::deque;
index 28522e9b8f072972a5357f8908205b99662efb63..858c3716f9dacedbe41d83b45632508ae74f0bcc 100644 (file)
@@ -7,7 +7,6 @@
 #include <stdlib.h>
 #include <stdio.h>
 
-#include <plib/sg.h>
 #include "hud.hxx"
 
 #ifdef USE_HUD_TextList
index 321d20d3e581afa8a7565e539e3416b267a5fd0b..f73718b0781baa5a6238509b85c5c7a304d81eb8 100644 (file)
@@ -30,8 +30,6 @@
 #include <Aircraft/aircraft.hxx>
 #include <Environment/environment.hxx>
 #include <Environment/environment_mgr.hxx>
-#include <simgear/math/sg_geodesy.hxx>
-#include <simgear/math/polar3d.hxx>
 #include <ATCDCL/ATCutils.hxx>
 
 #include <osg/GLU>
index c51752c5544e501021675d19a1cab0aaf6d746be..dfb8824aca57b866923eaac8004c17cee3a188a0 100644 (file)
@@ -27,8 +27,6 @@
 
 #include <math.h>
 
-#include <plib/sg.h>
-
 #include <simgear/constants.h>
 #include <simgear/debug/logstream.hxx>
 #include <simgear/math/interpolater.hxx>
index 558f39ddbc1339838a3ffe38673ba7d97b636a60..b3b7e6b9f2ce00869c782156a9d708f8ecad3995 100644 (file)
@@ -26,7 +26,6 @@
 #endif
 
 #include <simgear/math/sg_geodesy.hxx>
-#include <simgear/math/polar3d.hxx>
 
 #include <Aircraft/controls.hxx>
 #include <Main/globals.hxx>
index 81b532b5d78459c295ab0ca024ec3caa23f34209..1ac7f9d7a055bc3a72808bb635fb77db621d6253 100644 (file)
@@ -26,7 +26,6 @@
 #endif
 
 #include <simgear/math/sg_geodesy.hxx>
-#include <simgear/math/polar3d.hxx>
 
 #include <Aircraft/controls.hxx>
 #include <Main/globals.hxx>
index 0751a4a4fd108b315a89fdb7f1c0ec61b5fef06f..fcd1ca7d3159610f78cfe0287692792ad2077cfd 100644 (file)
@@ -8,7 +8,6 @@
 #endif
 
 #include <plib/puAux.h>
-#include <plib/sg.h>
 
 #include <simgear/compiler.h>  // for SG_USING_STD
 #include <simgear/props/props.hxx>
index 4f8f0523f71c27a6f1e17e63e804600e3cd9c2e0..fbf4baed34c7fc16333ad7fed9317cafd3175e19 100644 (file)
@@ -38,8 +38,6 @@ using std::vector;
 
 #include <osg/State>
 
-#include <plib/sg.h>
-
 #include <simgear/math/SGLimits.hxx>
 #include <simgear/constants.h>
 #include <simgear/structure/subsystem_mgr.hxx>
index b263150f3c912c5c6d38e7f8b54a32093300c0a3..5c788e949757306690c5fc2a95f3e2e2f11dd311 100644 (file)
@@ -25,7 +25,6 @@
 
 #include <simgear/compiler.h>
 #include <simgear/math/sg_geodesy.hxx>
-#include <simgear/math/polar3d.hxx>
 #include <osg/GLU>
 
 #include <Main/globals.hxx>
index 6ee1c21ac40f60df68db2c24ec6c96f9e1969020..f4308bbb3225fbbbfd85761b083dccaac8b83972 100644 (file)
@@ -45,7 +45,7 @@
 
 #include <ATCDCL/ATCProjection.hxx>
 #include <Main/fg_props.hxx>
-#include <simgear/math/point3d.hxx>
+#include <simgear/math/SGMath.hxx>
 #include "Airports/simple.hxx"
 
 using std::cout;
@@ -559,12 +559,12 @@ void KLN89::DrawMap(bool draw_avs) {
        double mapScaleMeters = _mapScale * (_mapScaleUnits == 0 ? SG_NM_TO_METER : 1000);
        
        // TODO - use an aligned projection when either DTK or TK up!
-       FGATCAlignedProjection mapProj(Point3D(_gpsLon * SG_RADIANS_TO_DEGREES, _gpsLat * SG_RADIANS_TO_DEGREES, 0.0), _mapHeading);
+       FGATCAlignedProjection mapProj(SGGeod::fromRad(_gpsLon, _gpsLat), _mapHeading);
        
        double meter_per_pix = (_mapOrientation == 0 ? mapScaleMeters / 20.0f : mapScaleMeters / 29.0f);
        
-       Point3D bottomLeft = mapProj.ConvertFromLocal(Point3D(gps_max(-57.0 * meter_per_pix, -50000), gps_max((_mapOrientation == 0 ? -20.0 * meter_per_pix : -11.0 * meter_per_pix), -25000), 0.0));
-       Point3D topRight = mapProj.ConvertFromLocal(Point3D(gps_min(54.0 * meter_per_pix, 50000), gps_min((_mapOrientation == 0 ? 20.0 * meter_per_pix : 29.0 * meter_per_pix), 25000), 0.0));
+       SGGeod bottomLeft = mapProj.ConvertFromLocal(SGVec3d(gps_max(-57.0 * meter_per_pix, -50000), gps_max((_mapOrientation == 0 ? -20.0 * meter_per_pix : -11.0 * meter_per_pix), -25000), 0.0));
+       SGGeod topRight = mapProj.ConvertFromLocal(SGVec3d(gps_min(54.0 * meter_per_pix, 50000), gps_min((_mapOrientation == 0 ? 20.0 * meter_per_pix : 29.0 * meter_per_pix), 25000), 0.0));
        
        // Draw Airport labels first (but not one's that are waypoints)
        // Draw Airports first (but not one's that are waypoints)
@@ -646,8 +646,8 @@ void KLN89::DrawMap(bool draw_avs) {
                for(unsigned int i=1; i<_activeFP->waypoints.size(); ++i) {
                        GPSWaypoint* wp0 = _activeFP->waypoints[i-1];
                        GPSWaypoint* wp1 = _activeFP->waypoints[i];
-                       Point3D p0 = mapProj.ConvertToLocal(Point3D(wp0->lon * SG_RADIANS_TO_DEGREES, wp0->lat * SG_RADIANS_TO_DEGREES, 0.0));
-                       Point3D p1 = mapProj.ConvertToLocal(Point3D(wp1->lon * SG_RADIANS_TO_DEGREES, wp1->lat * SG_RADIANS_TO_DEGREES, 0.0));
+                       SGVec3d p0 = mapProj.ConvertToLocal(SGGeod::fromRad(wp0->lon, wp0->lat));
+                       SGVec3d p1 = mapProj.ConvertToLocal(SGGeod::fromRad(wp1->lon, wp1->lat));
                        int mx0 = int(p0.x() / meter_per_pix) + 56;
                        int my0 = int(p0.y() / meter_per_pix) + (_mapOrientation == 0 ? 19 : 10);
                        int mx1 = int(p1.x() / meter_per_pix) + 56;
index fd245f754e788245edc7aa53a1bde06c3d821c65..97c8e982161e6244e5db7ee27fd487717d950306 100644 (file)
@@ -53,8 +53,6 @@
 #include <simgear/debug/logstream.hxx>
 #include <simgear/structure/exception.hxx>
 #include <simgear/structure/event_mgr.hxx>
-#include <simgear/math/polar3d.hxx>
-#include <simgear/math/sg_geodesy.hxx>
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/misc/interpolator.hxx>
 #include <simgear/scene/material/matlib.hxx>
index d05e8274ca4ef107996deed1ebd09f3297e4440a..cc88839fe6008a419898f14cd5fe9d3c7ebc44e8 100644 (file)
@@ -37,8 +37,6 @@
 
 #include <simgear/debug/logstream.hxx>
 #include <simgear/constants.h>
-#include <simgear/math/polar3d.hxx>
-#include <simgear/math/sg_geodesy.hxx>
 #include <simgear/scene/model/placement.hxx>
 #include <simgear/math/vector.hxx>
 
index 17610d6b4fc7cd306368dd30d4eae8653aa9bda0..950eace8315ac46253e8deffc90a0d6c05fdc0ef 100644 (file)
@@ -27,8 +27,6 @@
 
 #include <string.h>            // strcmp
 
-#include <plib/sg.h>
-
 #include <simgear/compiler.h>
 
 #include <Model/acmodel.hxx>
index 84448b866b3314a292d142a4a17c80f5c71de851..6ac60caaaeb7b41b16b3b70d2526ecd4c6a78e4f 100644 (file)
@@ -7,8 +7,6 @@
 
 #include <vector>
 
-#include <plib/sg.h>
-
 #include <Cockpit/panel.hxx>
 #include <Cockpit/panel_io.hxx>
 #include "panelnode.hxx"
index 2499da2cfac3a30de22a7f7bdbfee77537b90f2b..352eb576535a4495bd8aa92a081bd57f58c3a305 100644 (file)
@@ -37,7 +37,6 @@
 
 #include <vector>
 
-#include <plib/sg.h>
 #include <simgear/compiler.h>
 #include <simgear/props/props.hxx>
 #include <simgear/math/SGMath.hxx>
index 26c92bb89160b8764dcdb6828c59d32a3295ab7a..41093a26ceb87f87dd8650bbe983bccf0982fa8f 100644 (file)
@@ -32,8 +32,6 @@
 
 #include <simgear/constants.h>
 #include <simgear/debug/logstream.hxx>
-#include <simgear/math/polar3d.hxx>
-#include <simgear/math/sg_geodesy.hxx>
 #include <simgear/math/vector.hxx>
 #include <simgear/structure/exception.hxx>
 #include <simgear/scene/model/modellib.hxx>
index 56db6204cba1cba31b04cd9b3c1462584190046a..40d237b43e68fae957a8a0c76276fb555022f80c 100644 (file)
 #include <string>
 #include <vector>
 
-#include <plib/sg.h>
-
 #include <simgear/compiler.h>
-#include <simgear/math/polar3d.hxx>
-#include <simgear/math/sg_geodesy.hxx>
 #include <simgear/props/props.hxx>
 #include <simgear/route/waypoint.hxx>
 #include <simgear/structure/subsystem_mgr.hxx>
index 07d0cd0ab2626f0ac1c4842f8f8377ff4c3f171f..5abcc755c6e63f8af6b3ca36dbfc0f783275e54a 100644 (file)
 #include <vector>
 #include <algorithm>
 
-#include <plib/sg.h>
 #include <plib/ul.h>
 
 #include <simgear/compiler.h>
-#include <simgear/math/polar3d.hxx>
-#include <simgear/math/sg_geodesy.hxx>
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/props/props.hxx>
 #include <simgear/route/waypoint.hxx>