#include <math.h>
#include <simgear/constants.h>
-FGATCProjection::FGATCProjection() {
- _origin.setlat(0.0);
- _origin.setlon(0.0);
- _origin.setelev(0.0);
- _correction_factor = cos(_origin.lat() * SG_DEGREES_TO_RADIANS);
-}
-
-FGATCProjection::FGATCProjection(const Point3D& centre) {
- _origin = centre;
- _correction_factor = cos(_origin.lat() * SG_DEGREES_TO_RADIANS);
-}
-
-FGATCProjection::~FGATCProjection() {
-}
-
-void FGATCProjection::Init(const Point3D& centre) {
- _origin = centre;
- _correction_factor = cos(_origin.lat() * SG_DEGREES_TO_RADIANS);
-}
-
-Point3D FGATCProjection::ConvertToLocal(const Point3D& pt) {
- 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;
-
- return(Point3D(x,y,0.0));
-}
-
-Point3D FGATCProjection::ConvertFromLocal(const Point3D& pt) {
- double delta_lat = asin(pt.y() / SG_EQUATORIAL_RADIUS_M) * SG_RADIANS_TO_DEGREES;
- double delta_lon = (asin(pt.x() / SG_EQUATORIAL_RADIUS_M) * SG_RADIANS_TO_DEGREES) / _correction_factor;
-
- return(Point3D(_origin.lon()+delta_lon, _origin.lat()+delta_lat, 0.0));
-}
-
-/**********************************************************************************/
-
FGATCAlignedProjection::FGATCAlignedProjection() {
_origin.setlat(0.0);
_origin.setlon(0.0);
#include <simgear/math/point3d.hxx>
-// FGATCProjection - a class to project an area local to an airport onto an orthogonal co-ordinate system
-class FGATCProjection {
-
-public:
- FGATCProjection();
- FGATCProjection(const Point3D& centre);
- ~FGATCProjection();
-
- void Init(const Point3D& centre);
-
- // Convert a lat/lon co-ordinate (degrees) to the local projection (meters)
- Point3D ConvertToLocal(const Point3D& pt);
-
- // Convert a local projection co-ordinate (meters) to lat/lon (degrees)
- Point3D ConvertFromLocal(const Point3D& pt);
-
-private:
- Point3D _origin; // lat/lon of local area origin
- double _correction_factor; // Reduction in surface distance per degree of longitude due to latitude. Saves having to do a cos() every call.
-
-};
-
-
// 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.
class FGATCAlignedProjection {