00001 #pragma once 00002 /** 00003 * \file NETGeographicLib/LocalCartesian.h 00004 * \brief Header for NETGeographicLib::LocalCartesian class 00005 * 00006 * NETGeographicLib is copyright (c) Scott Heiman (2013) 00007 * GeographicLib is Copyright (c) Charles Karney (2010-2012) 00008 * <charles@karney.com> and licensed under the MIT/X11 License. 00009 * For more information, see 00010 * http://geographiclib.sourceforge.net/ 00011 **********************************************************************/ 00012 00013 namespace NETGeographicLib 00014 { 00015 ref class Geocentric; 00016 /** 00017 * \brief .NET wrapper for GeographicLib::LocalCartesian. 00018 * 00019 * This class allows .NET applications to access GeographicLib::LocalCartesian. 00020 * 00021 * Convert between geodetic coordinates latitude = \e lat, longitude = \e 00022 * lon, height = \e h (measured vertically from the surface of the ellipsoid) 00023 * to local cartesian coordinates (\e x, \e y, \e z). The origin of local 00024 * cartesian coordinate system is at \e lat = \e lat0, \e lon = \e lon0, \e h 00025 * = \e h0. The \e z axis is normal to the ellipsoid; the \e y axis points 00026 * due north. The plane \e z = - \e h0 is tangent to the ellipsoid. 00027 * 00028 * The conversions all take place via geocentric coordinates using a 00029 * Geocentric object. 00030 * 00031 * C# Example: 00032 * \include example-LocalCartesian.cs 00033 * Managed C++ Example: 00034 * \include example-LocalCartesian.cpp 00035 * Visual Basic Example: 00036 * \include example-LocalCartesian.vb 00037 * 00038 * <B>INTERFACE DIFFERENCES:</B><BR> 00039 * Constructors have been provided that assume WGS84 parameters. 00040 * 00041 * The following functions are implemented as properties: 00042 * LatitudeOrigin, LongitudeOrigin, HeightOrigin, MajorRadius, 00043 * and Flattening. 00044 * 00045 * The rotation matrices returned by the Forward and Reverse functions 00046 * are 2D, 3 × 3 arrays rather than vectors. 00047 **********************************************************************/ 00048 public ref class LocalCartesian 00049 { 00050 private: 00051 // the pointer to the GeographicLib::LocalCartesian. 00052 GeographicLib::LocalCartesian* m_pLocalCartesian; 00053 00054 // the finalizer frees the unmanaged memory when the object is destroyed. 00055 !LocalCartesian(void); 00056 public: 00057 00058 /** 00059 * Constructor setting the origin. 00060 * 00061 * @param[in] lat0 latitude at origin (degrees). 00062 * @param[in] lon0 longitude at origin (degrees). 00063 * @param[in] h0 height above ellipsoid at origin (meters); default 0. 00064 * @param[in] earth Geocentric object for the transformation; default 00065 * Geocentric::WGS84. 00066 * 00067 * \e lat0 should be in the range [−90°, 90°]; \e 00068 * lon0 should be in the range [−540°, 540°). 00069 **********************************************************************/ 00070 LocalCartesian(double lat0, double lon0, double h0, 00071 Geocentric^ earth ); 00072 00073 /** 00074 * Constructor setting the origin and assuming a WGS84 ellipsoid. 00075 * 00076 * @param[in] lat0 latitude at origin (degrees). 00077 * @param[in] lon0 longitude at origin (degrees). 00078 * @param[in] h0 height above ellipsoid at origin (meters); default 0. 00079 * 00080 * \e lat0 should be in the range [−90°, 90°]; \e 00081 * lon0 should be in the range [−540°, 540°). 00082 **********************************************************************/ 00083 LocalCartesian(double lat0, double lon0, double h0 ); 00084 00085 /** 00086 * Constructor that uses the provided ellipsoid. 00087 * 00088 * @param[in] earth Geocentric object for the transformation; default 00089 * Geocentric::WGS84. 00090 * 00091 * Sets \e lat0 = 0, \e lon0 = 0, \e h0 = 0. 00092 **********************************************************************/ 00093 LocalCartesian(Geocentric^ earth); 00094 00095 /** 00096 * The default constructor assumes the WGS84 ellipsoid. 00097 * 00098 * Sets \e lat0 = 0, \e lon0 = 0, \e h0 = 0. 00099 **********************************************************************/ 00100 LocalCartesian(); 00101 00102 /** 00103 * The destructor calls the finalizer. 00104 **********************************************************************/ 00105 ~LocalCartesian() 00106 { this->!LocalCartesian(); } 00107 00108 /** 00109 * Reset the origin. 00110 * 00111 * @param[in] lat0 latitude at origin (degrees). 00112 * @param[in] lon0 longitude at origin (degrees). 00113 * @param[in] h0 height above ellipsoid at origin (meters); default 0. 00114 * 00115 * \e lat0 should be in the range [−90°, 90°]; \e 00116 * lon0 should be in the range [−540°, 540°). 00117 **********************************************************************/ 00118 void Reset(double lat0, double lon0, double h0 ); 00119 00120 /** 00121 * Convert from geodetic to local cartesian coordinates. 00122 * 00123 * @param[in] lat latitude of point (degrees). 00124 * @param[in] lon longitude of point (degrees). 00125 * @param[in] h height of point above the ellipsoid (meters). 00126 * @param[out] x local cartesian coordinate (meters). 00127 * @param[out] y local cartesian coordinate (meters). 00128 * @param[out] z local cartesian coordinate (meters). 00129 * 00130 * \e lat should be in the range [−90°, 90°]; \e lon 00131 * should be in the range [−540°, 540°). 00132 **********************************************************************/ 00133 void Forward(double lat, double lon, double h, 00134 [System::Runtime::InteropServices::Out] double% x, 00135 [System::Runtime::InteropServices::Out] double% y, 00136 [System::Runtime::InteropServices::Out] double% z); 00137 00138 /** 00139 * Convert from geodetic to local cartesian coordinates and return rotation 00140 * matrix. 00141 * 00142 * @param[in] lat latitude of point (degrees). 00143 * @param[in] lon longitude of point (degrees). 00144 * @param[in] h height of point above the ellipsoid (meters). 00145 * @param[out] x local cartesian coordinate (meters). 00146 * @param[out] y local cartesian coordinate (meters). 00147 * @param[out] z local cartesian coordinate (meters). 00148 * @param[out] M a 3 × 3 rotation matrix. 00149 * 00150 * \e lat should be in the range [−90°, 90°]; \e lon 00151 * should be in the range [−540°, 540°). 00152 * 00153 * Let \e v be a unit vector located at (\e lat, \e lon, \e h). We can 00154 * express \e v as \e column vectors in one of two ways 00155 * - in east, north, up coordinates (where the components are relative to a 00156 * local coordinate system at (\e lat, \e lon, \e h)); call this 00157 * representation \e v1. 00158 * - in \e x, \e y, \e z coordinates (where the components are relative to 00159 * the local coordinate system at (\e lat0, \e lon0, \e h0)); call this 00160 * representation \e v0. 00161 * . 00162 * Then we have \e v0 = \e M ⋅ \e v1. 00163 **********************************************************************/ 00164 void Forward(double lat, double lon, double h, 00165 [System::Runtime::InteropServices::Out] double% x, 00166 [System::Runtime::InteropServices::Out] double% y, 00167 [System::Runtime::InteropServices::Out] double% z, 00168 [System::Runtime::InteropServices::Out] array<double,2>^% M); 00169 00170 /** 00171 * Convert from local cartesian to geodetic coordinates. 00172 * 00173 * @param[in] x local cartesian coordinate (meters). 00174 * @param[in] y local cartesian coordinate (meters). 00175 * @param[in] z local cartesian coordinate (meters). 00176 * @param[out] lat latitude of point (degrees). 00177 * @param[out] lon longitude of point (degrees). 00178 * @param[out] h height of point above the ellipsoid (meters). 00179 * 00180 * The value of \e lon returned is in the range [−180°, 00181 * 180°). 00182 **********************************************************************/ 00183 void Reverse(double x, double y, double z, 00184 [System::Runtime::InteropServices::Out] double% lat, 00185 [System::Runtime::InteropServices::Out] double% lon, 00186 [System::Runtime::InteropServices::Out] double% h); 00187 00188 /** 00189 * Convert from local cartesian to geodetic coordinates and return rotation 00190 * matrix. 00191 * 00192 * @param[in] x local cartesian coordinate (meters). 00193 * @param[in] y local cartesian coordinate (meters). 00194 * @param[in] z local cartesian coordinate (meters). 00195 * @param[out] lat latitude of point (degrees). 00196 * @param[out] lon longitude of point (degrees). 00197 * @param[out] h height of point above the ellipsoid (meters). 00198 * @param[out] M a 3 × 3 rotation matrix. 00199 * 00200 * Let \e v be a unit vector located at (\e lat, \e lon, \e h). We can 00201 * express \e v as \e column vectors in one of two ways 00202 * - in east, north, up coordinates (where the components are relative to a 00203 * local coordinate system at (\e lat, \e lon, \e h)); call this 00204 * representation \e v1. 00205 * - in \e x, \e y, \e z coordinates (where the components are relative to 00206 * the local coordinate system at (\e lat0, \e lon0, \e h0)); call this 00207 * representation \e v0. 00208 * . 00209 * Then we have \e v1 = \e M<sup>T</sup> ⋅ \e v0, where \e 00210 * M<sup>T</sup> is the transpose of \e M. 00211 **********************************************************************/ 00212 void Reverse(double x, double y, double z, 00213 [System::Runtime::InteropServices::Out] double% lat, 00214 [System::Runtime::InteropServices::Out] double% lon, 00215 [System::Runtime::InteropServices::Out] double% h, 00216 [System::Runtime::InteropServices::Out] array<double,2>^% M); 00217 00218 /** \name Inspector functions 00219 **********************************************************************/ 00220 ///@{ 00221 /** 00222 * @return latitude of the origin (degrees). 00223 **********************************************************************/ 00224 property double LatitudeOrigin { double get(); } 00225 00226 /** 00227 * @return longitude of the origin (degrees). 00228 **********************************************************************/ 00229 property double LongitudeOrigin { double get(); } 00230 00231 /** 00232 * @return height of the origin (meters). 00233 **********************************************************************/ 00234 property double HeightOrigin { double get(); } 00235 00236 /** 00237 * @return \e a the equatorial radius of the ellipsoid (meters). This is 00238 * the value of \e a inherited from the Geocentric object used in the 00239 * constructor. 00240 **********************************************************************/ 00241 property double MajorRadius { double get(); } 00242 00243 /** 00244 * @return \e f the flattening of the ellipsoid. This is the value 00245 * inherited from the Geocentric object used in the constructor. 00246 **********************************************************************/ 00247 property double Flattening { double get(); } 00248 ///@} 00249 }; 00250 } // namespace NETGeographicLib