]> git.mxchange.org Git - flightgear.git/commitdiff
Implement two convienience functions.
authordaveluff <daveluff>
Tue, 23 Sep 2003 15:01:53 +0000 (15:01 +0000)
committerdaveluff <daveluff>
Tue, 23 Sep 2003 15:01:53 +0000 (15:01 +0000)
src/ATC/ATCProjection.cxx
src/ATC/ATCProjection.hxx

index 3a3a5f765dd2394777368648e1c870e9adde917a..bce25f7f1a149dd59aac3a281b27be5f7895f442 100644 (file)
@@ -53,7 +53,10 @@ Point3D FGATCProjection::ConvertToLocal(Point3D pt) {
 }
 
 Point3D FGATCProjection::ConvertFromLocal(Point3D pt) {
-    return(Point3D(0,0,0));
+       double delta_lat = asin(pt.y() / SG_EQUATORIAL_RADIUS_M) * DCL_RADIANS_TO_DEGREES;
+       double delta_lon = (asin(pt.x() / SG_EQUATORIAL_RADIUS_M) * DCL_RADIANS_TO_DEGREES) / correction_factor;
+       
+    return(Point3D(origin.lon()+delta_lon, origin.lat()+delta_lat, 0.0));
 }
 
 /**********************************************************************************/
@@ -91,7 +94,14 @@ Point3D FGATCAlignedProjection::ConvertToLocal(Point3D pt) {
     return(Point3D(x,y,0.0));
 }
 
-// TODO - IMPLEMENT ME!!!
 Point3D FGATCAlignedProjection::ConvertFromLocal(Point3D pt) {
-    return(Point3D(0,0,0));
+       // de-align
+       double x = (pt.x() + pt.y()*sin(theta)) / cos(theta);
+       double y = (pt.y() - pt.x()*sin(theta)) / cos(theta);
+       
+       // convert from orthogonal to lat/lon
+       double delta_lat = asin(y / SG_EQUATORIAL_RADIUS_M) * DCL_RADIANS_TO_DEGREES;
+       double delta_lon = (asin(x / SG_EQUATORIAL_RADIUS_M) * DCL_RADIANS_TO_DEGREES) / correction_factor;
+       
+    return(Point3D(origin.lon()+delta_lon, origin.lat()+delta_lat, 0.0));
 }
index 137b3989386a0c22657ca76b29dc7691ac53227f..04c31ce0005302afd40630fd4be375d0c83b555f 100644 (file)
@@ -32,10 +32,10 @@ public:
 
     void Init(Point3D centre);
 
-    // Convert a lat/lon co-ordinate to the local projection
+    // Convert a lat/lon co-ordinate (degrees) to the local projection (meters)
     Point3D ConvertToLocal(Point3D pt);
 
-    // Convert a local projection co-ordinate to lat/lon
+    // Convert a local projection co-ordinate (meters) to lat/lon (degrees)
     Point3D ConvertFromLocal(Point3D pt);
 
 private:
@@ -55,10 +55,10 @@ public:
 
     void Init(Point3D centre, double heading);
 
-    // Convert a lat/lon co-ordinate to the local projection
+    // Convert a lat/lon co-ordinate (degrees) to the local projection (meters)
     Point3D ConvertToLocal(Point3D pt);
 
-    // Convert a local projection co-ordinate to lat/lon
+    // Convert a local projection co-ordinate (meters) to lat/lon (degrees)
     Point3D ConvertFromLocal(Point3D pt);
 
 private: