NETGeographicLib  1.40
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Pages
LocalCartesian.h
Go to the documentation of this file.
1 #pragma once
2 /**
3  * \file NETGeographicLib/LocalCartesian.h
4  * \brief Header for NETGeographicLib::LocalCartesian class
5  *
6  * NETGeographicLib is copyright (c) Scott Heiman (2013)
7  * GeographicLib is Copyright (c) Charles Karney (2010-2012)
8  * <charles@karney.com> and licensed under the MIT/X11 License.
9  * For more information, see
10  * http://geographiclib.sourceforge.net/
11  **********************************************************************/
12 
13 namespace NETGeographicLib
14 {
15  ref class Geocentric;
16  /**
17  * \brief .NET wrapper for GeographicLib::LocalCartesian.
18  *
19  * This class allows .NET applications to access GeographicLib::LocalCartesian.
20  *
21  * Convert between geodetic coordinates latitude = \e lat, longitude = \e
22  * lon, height = \e h (measured vertically from the surface of the ellipsoid)
23  * to local cartesian coordinates (\e x, \e y, \e z). The origin of local
24  * cartesian coordinate system is at \e lat = \e lat0, \e lon = \e lon0, \e h
25  * = \e h0. The \e z axis is normal to the ellipsoid; the \e y axis points
26  * due north. The plane \e z = - \e h0 is tangent to the ellipsoid.
27  *
28  * The conversions all take place via geocentric coordinates using a
29  * Geocentric object.
30  *
31  * C# Example:
32  * \include example-LocalCartesian.cs
33  * Managed C++ Example:
34  * \include example-LocalCartesian.cpp
35  * Visual Basic Example:
36  * \include example-LocalCartesian.vb
37  *
38  * <B>INTERFACE DIFFERENCES:</B><BR>
39  * Constructors have been provided that assume WGS84 parameters.
40  *
41  * The following functions are implemented as properties:
42  * LatitudeOrigin, LongitudeOrigin, HeightOrigin, MajorRadius,
43  * and Flattening.
44  *
45  * The rotation matrices returned by the Forward and Reverse functions
46  * are 2D, 3 &times; 3 arrays rather than vectors.
47  **********************************************************************/
48  public ref class LocalCartesian
49  {
50  private:
51  // the pointer to the GeographicLib::LocalCartesian.
52  GeographicLib::LocalCartesian* m_pLocalCartesian;
53 
54  // the finalizer frees the unmanaged memory when the object is destroyed.
55  !LocalCartesian(void);
56  public:
57 
58  /**
59  * Constructor setting the origin.
60  *
61  * @param[in] lat0 latitude at origin (degrees).
62  * @param[in] lon0 longitude at origin (degrees).
63  * @param[in] h0 height above ellipsoid at origin (meters); default 0.
64  * @param[in] earth Geocentric object for the transformation; default
65  * Geocentric::WGS84.
66  *
67  * \e lat0 should be in the range [&minus;90&deg;, 90&deg;]; \e
68  * lon0 should be in the range [&minus;540&deg;, 540&deg;).
69  **********************************************************************/
70  LocalCartesian(double lat0, double lon0, double h0,
71  Geocentric^ earth );
72 
73  /**
74  * Constructor setting the origin and assuming a WGS84 ellipsoid.
75  *
76  * @param[in] lat0 latitude at origin (degrees).
77  * @param[in] lon0 longitude at origin (degrees).
78  * @param[in] h0 height above ellipsoid at origin (meters); default 0.
79  *
80  * \e lat0 should be in the range [&minus;90&deg;, 90&deg;]; \e
81  * lon0 should be in the range [&minus;540&deg;, 540&deg;).
82  **********************************************************************/
83  LocalCartesian(double lat0, double lon0, double h0 );
84 
85  /**
86  * Constructor that uses the provided ellipsoid.
87  *
88  * @param[in] earth Geocentric object for the transformation; default
89  * Geocentric::WGS84.
90  *
91  * Sets \e lat0 = 0, \e lon0 = 0, \e h0 = 0.
92  **********************************************************************/
93  LocalCartesian(Geocentric^ earth);
94 
95  /**
96  * The default constructor assumes the WGS84 ellipsoid.
97  *
98  * Sets \e lat0 = 0, \e lon0 = 0, \e h0 = 0.
99  **********************************************************************/
100  LocalCartesian();
101 
102  /**
103  * The destructor calls the finalizer.
104  **********************************************************************/
106  { this->!LocalCartesian(); }
107 
108  /**
109  * Reset the origin.
110  *
111  * @param[in] lat0 latitude at origin (degrees).
112  * @param[in] lon0 longitude at origin (degrees).
113  * @param[in] h0 height above ellipsoid at origin (meters); default 0.
114  *
115  * \e lat0 should be in the range [&minus;90&deg;, 90&deg;]; \e
116  * lon0 should be in the range [&minus;540&deg;, 540&deg;).
117  **********************************************************************/
118  void Reset(double lat0, double lon0, double h0 );
119 
120  /**
121  * Convert from geodetic to local cartesian coordinates.
122  *
123  * @param[in] lat latitude of point (degrees).
124  * @param[in] lon longitude of point (degrees).
125  * @param[in] h height of point above the ellipsoid (meters).
126  * @param[out] x local cartesian coordinate (meters).
127  * @param[out] y local cartesian coordinate (meters).
128  * @param[out] z local cartesian coordinate (meters).
129  *
130  * \e lat should be in the range [&minus;90&deg;, 90&deg;]; \e lon
131  * should be in the range [&minus;540&deg;, 540&deg;).
132  **********************************************************************/
133  void Forward(double lat, double lon, double h,
134  [System::Runtime::InteropServices::Out] double% x,
135  [System::Runtime::InteropServices::Out] double% y,
136  [System::Runtime::InteropServices::Out] double% z);
137 
138  /**
139  * Convert from geodetic to local cartesian coordinates and return rotation
140  * matrix.
141  *
142  * @param[in] lat latitude of point (degrees).
143  * @param[in] lon longitude of point (degrees).
144  * @param[in] h height of point above the ellipsoid (meters).
145  * @param[out] x local cartesian coordinate (meters).
146  * @param[out] y local cartesian coordinate (meters).
147  * @param[out] z local cartesian coordinate (meters).
148  * @param[out] M a 3 &times; 3 rotation matrix.
149  *
150  * \e lat should be in the range [&minus;90&deg;, 90&deg;]; \e lon
151  * should be in the range [&minus;540&deg;, 540&deg;).
152  *
153  * Let \e v be a unit vector located at (\e lat, \e lon, \e h). We can
154  * express \e v as \e column vectors in one of two ways
155  * - in east, north, up coordinates (where the components are relative to a
156  * local coordinate system at (\e lat, \e lon, \e h)); call this
157  * representation \e v1.
158  * - in \e x, \e y, \e z coordinates (where the components are relative to
159  * the local coordinate system at (\e lat0, \e lon0, \e h0)); call this
160  * representation \e v0.
161  * .
162  * Then we have \e v0 = \e M &sdot; \e v1.
163  **********************************************************************/
164  void Forward(double lat, double lon, double h,
165  [System::Runtime::InteropServices::Out] double% x,
166  [System::Runtime::InteropServices::Out] double% y,
167  [System::Runtime::InteropServices::Out] double% z,
168  [System::Runtime::InteropServices::Out] array<double,2>^% M);
169 
170  /**
171  * Convert from local cartesian to geodetic coordinates.
172  *
173  * @param[in] x local cartesian coordinate (meters).
174  * @param[in] y local cartesian coordinate (meters).
175  * @param[in] z local cartesian coordinate (meters).
176  * @param[out] lat latitude of point (degrees).
177  * @param[out] lon longitude of point (degrees).
178  * @param[out] h height of point above the ellipsoid (meters).
179  *
180  * The value of \e lon returned is in the range [&minus;180&deg;,
181  * 180&deg;).
182  **********************************************************************/
183  void Reverse(double x, double y, double z,
184  [System::Runtime::InteropServices::Out] double% lat,
185  [System::Runtime::InteropServices::Out] double% lon,
186  [System::Runtime::InteropServices::Out] double% h);
187 
188  /**
189  * Convert from local cartesian to geodetic coordinates and return rotation
190  * matrix.
191  *
192  * @param[in] x local cartesian coordinate (meters).
193  * @param[in] y local cartesian coordinate (meters).
194  * @param[in] z local cartesian coordinate (meters).
195  * @param[out] lat latitude of point (degrees).
196  * @param[out] lon longitude of point (degrees).
197  * @param[out] h height of point above the ellipsoid (meters).
198  * @param[out] M a 3 &times; 3 rotation matrix.
199  *
200  * Let \e v be a unit vector located at (\e lat, \e lon, \e h). We can
201  * express \e v as \e column vectors in one of two ways
202  * - in east, north, up coordinates (where the components are relative to a
203  * local coordinate system at (\e lat, \e lon, \e h)); call this
204  * representation \e v1.
205  * - in \e x, \e y, \e z coordinates (where the components are relative to
206  * the local coordinate system at (\e lat0, \e lon0, \e h0)); call this
207  * representation \e v0.
208  * .
209  * Then we have \e v1 = \e M<sup>T</sup> &sdot; \e v0, where \e
210  * M<sup>T</sup> is the transpose of \e M.
211  **********************************************************************/
212  void Reverse(double x, double y, double z,
213  [System::Runtime::InteropServices::Out] double% lat,
214  [System::Runtime::InteropServices::Out] double% lon,
215  [System::Runtime::InteropServices::Out] double% h,
216  [System::Runtime::InteropServices::Out] array<double,2>^% M);
217 
218  /** \name Inspector functions
219  **********************************************************************/
220  ///@{
221  /**
222  * @return latitude of the origin (degrees).
223  **********************************************************************/
224  property double LatitudeOrigin { double get(); }
225 
226  /**
227  * @return longitude of the origin (degrees).
228  **********************************************************************/
229  property double LongitudeOrigin { double get(); }
230 
231  /**
232  * @return height of the origin (meters).
233  **********************************************************************/
234  property double HeightOrigin { double get(); }
235 
236  /**
237  * @return \e a the equatorial radius of the ellipsoid (meters). This is
238  * the value of \e a inherited from the Geocentric object used in the
239  * constructor.
240  **********************************************************************/
241  property double MajorRadius { double get(); }
242 
243  /**
244  * @return \e f the flattening of the ellipsoid. This is the value
245  * inherited from the Geocentric object used in the constructor.
246  **********************************************************************/
247  property double Flattening { double get(); }
248  ///@}
249  };
250 } // namespace NETGeographicLib
.NET wrapper for GeographicLib::Geocentric.
Definition: Geocentric.h:68
.NET wrapper for GeographicLib::LocalCartesian.
void Reverse(double x, double y, double z, [System::Runtime::InteropServices::Out] double% lat, [System::Runtime::InteropServices::Out] double% lon, [System::Runtime::InteropServices::Out] double% h)
void Reset(double lat0, double lon0, double h0)
void Forward(double lat, double lon, double h, [System::Runtime::InteropServices::Out] double% x, [System::Runtime::InteropServices::Out] double% y, [System::Runtime::InteropServices::Out] double% z)