]> git.mxchange.org Git - simgear.git/blobdiff - simgear/route/waypoint.cxx
Rename FGSerialPort to SGSerialPort.
[simgear.git] / simgear / route / waypoint.cxx
index 50807ea93c4906dc303febf686f8c5d2be80ba6b..b29d046ba7b55090b367ac2d346411f729f65ae4 100644 (file)
@@ -38,11 +38,6 @@ SGWayPoint::SGWayPoint( const double lon, const double lat, const double alt,
 }
 
 
-SGWayPoint::SGWayPoint() {
-    SGWayPoint( 0.0, 0.0, 0.0, WGS84, "" );
-}
-
-
 // Destructor
 SGWayPoint::~SGWayPoint() {
 }
@@ -55,20 +50,20 @@ SGWayPoint::~SGWayPoint() {
 void SGWayPoint::CourseAndDistance( const double cur_lon,
                                    const double cur_lat,
                                    const double cur_alt,
-                                   double *course, double *distance ) {
+                                   double *course, double *distance ) const {
     if ( mode == WGS84 ) {
        double reverse;
        geo_inverse_wgs_84( cur_alt, cur_lat, cur_lon, target_lat, target_lon,
                            course, &reverse, distance );
     } else if ( mode == SPHERICAL ) {
-       Point3D current( cur_lon * DEG_TO_RAD, cur_lat * DEG_TO_RAD, 0.0 );
-       Point3D target( target_lon * DEG_TO_RAD, target_lat * DEG_TO_RAD, 0.0 );
+       Point3D current( cur_lon * SGD_DEGREES_TO_RADIANS, cur_lat * SGD_DEGREES_TO_RADIANS, 0.0 );
+       Point3D target( target_lon * SGD_DEGREES_TO_RADIANS, target_lat * SGD_DEGREES_TO_RADIANS, 0.0 );
        calc_gc_course_dist( current, target, course, distance );
-       *course = 360.0 - *course * RAD_TO_DEG;
+       *course = 360.0 - *course * SGD_RADIANS_TO_DEGREES;
     } else if ( mode == CARTESIAN ) {
        double dx = target_lon - cur_lon;
        double dy = target_lat - cur_lat;
-       *course = -atan2( dy, dx ) * RAD_TO_DEG - 90;
+       *course = -atan2( dy, dx ) * SGD_RADIANS_TO_DEGREES - 90;
        while ( *course < 0 ) {
            *course += 360.0;
        }
@@ -78,3 +73,12 @@ void SGWayPoint::CourseAndDistance( const double cur_lon,
        *distance = sqrt( dx * dx + dy * dy );
     }
 }
+
+// Calculate course and distances between two waypoints
+void SGWayPoint::CourseAndDistance( const SGWayPoint &wp,
+                       double *course, double *distance ) const {
+    CourseAndDistance( wp.get_target_lon(),
+                      wp.get_target_lat(),
+                      wp.get_target_alt(),
+                      course, distance );
+}