From: daveluff Date: Tue, 23 Sep 2003 15:01:53 +0000 (+0000) Subject: Implement two convienience functions. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6665dcce822c959aa4910268c821f1fe160b5d10;p=flightgear.git Implement two convienience functions. --- diff --git a/src/ATC/ATCProjection.cxx b/src/ATC/ATCProjection.cxx index 3a3a5f765..bce25f7f1 100644 --- a/src/ATC/ATCProjection.cxx +++ b/src/ATC/ATCProjection.cxx @@ -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)); } diff --git a/src/ATC/ATCProjection.hxx b/src/ATC/ATCProjection.hxx index 137b39893..04c31ce00 100644 --- a/src/ATC/ATCProjection.hxx +++ b/src/ATC/ATCProjection.hxx @@ -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: