]> git.mxchange.org Git - simgear.git/blobdiff - simgear/math/polar3d.hxx
SG-ified logstream.
[simgear.git] / simgear / math / polar3d.hxx
index 8dfc6a447de4d2ad0e2419000b02ed3e1663da66..fd305b48b8244daa7d51f67d77b9f8a5cc3d39a7 100644 (file)
 // Find the Altitude above the Ellipsoid (WGS84) given the Earth
 // Centered Cartesian coordinate vector Distances are specified in
 // meters.
-double fgGeodAltFromCart(const Point3D& cp);
+double sgGeodAltFromCart(const Point3D& cp);
 
 
 // Convert a polar coordinate to a cartesian coordinate.  Lon and Lat
-// must be specified in radians.  The FG convention is for distances
+// must be specified in radians.  The SG convention is for distances
 // to be specified in meters
-inline Point3D fgPolarToCart3d(const Point3D& p) {
+inline Point3D sgPolarToCart3d(const Point3D& p) {
     double tmp = cos( p.lat() ) * p.radius();
 
     return Point3D( cos( p.lon() ) * tmp,
@@ -57,9 +57,9 @@ inline Point3D fgPolarToCart3d(const Point3D& p) {
 
 // Convert a cartesian coordinate to polar coordinates (lon/lat
 // specified in radians.  Distances are specified in meters.
-inline Point3D fgCartToPolar3d(const Point3D& cp) {
+inline Point3D sgCartToPolar3d(const Point3D& cp) {
     return Point3D( atan2( cp.y(), cp.x() ),
-                   FG_PI_2 - 
+                   SGD_PI_2 - 
                    atan2( sqrt(cp.x()*cp.x() + cp.y()*cp.y()), cp.z() ),
                    sqrt(cp.x()*cp.x() + cp.y()*cp.y() + cp.z()*cp.z()) );
 }
@@ -83,17 +83,18 @@ inline Point3D calc_gc_lon_lat( const Point3D& orig, double course,
     // printf("calc_lon_lat()  offset.theta = %.2f offset.dist = %.2f\n",
     //        offset.theta, offset.dist);
 
-    dist *= METER_TO_NM * NM_TO_RAD;
+    dist *= SG_METER_TO_NM * SG_NM_TO_RAD;
     
     result.sety( asin( sin(orig.y()) * cos(dist) + 
                       cos(orig.y()) * sin(dist) * cos(course) ) );
 
-    if ( cos(result.y()) < FG_EPSILON ) {
+    if ( cos(result.y()) < SG_EPSILON ) {
         result.setx( orig.x() );      // endpoint a pole
     } else {
         result.setx( 
            fmod(orig.x() - asin( sin(course) * sin(dist) / 
-                                 cos(result.y()) ) + FG_PI, FG_2PI) - FG_PI );
+                                 cos(result.y()) )
+                 + SGD_PI, SGD_2PI) - SGD_PI );
     }
 
     return result;
@@ -132,10 +133,10 @@ inline void calc_gc_course_dist( const Point3D& start, const Point3D& dest,
 
     double tc1;
 
-    if ( cos(start.y()) < FG_EPSILON ) {
+    if ( cos(start.y()) < SG_EPSILON ) {
        // EPS a small number ~ machine precision
        if ( start.y() > 0 ) {
-           tc1 = FG_PI;        // starting from N pole
+           tc1 = SGD_PI;        // starting from N pole
        } else {
            tc1 = 0;            // starting from S pole
        }
@@ -149,11 +150,11 @@ inline void calc_gc_course_dist( const Point3D& start, const Point3D& dest,
     if ( sin( dest.x() - start.x() ) < 0 ) {
         tc1 = tmp5;
     } else {
-        tc1 = 2 * FG_PI - tmp5;
+        tc1 = 2 * SGD_PI - tmp5;
     }
 
     *course = tc1;
-    *dist = d * RAD_TO_NM * NM_TO_METER;
+    *dist = d * SG_RAD_TO_NM * SG_NM_TO_METER;
 }
 
 #endif // _POLAR_HXX