Main MRPT website > C++ reference
MRPT logo
conversions.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 #ifndef conversions_H
29 #define conversions_H
30 
31 #include <mrpt/utils/utils_defs.h>
33 
35 
37 
38 
39 namespace mrpt
40 {
41  /** This namespace provides topography helper functions, coordinate transformations.
42  * \ingroup mrpt_topography_grp
43  */
44  namespace topography
45  {
46  using namespace std;
47  using namespace mrpt::utils;
48 
49  /** \addtogroup mrpt_topography_grp
50  * @{ */
51 
52  /** @name Topography coordinate conversion functions
53  @{ */
54 
55  /** Coordinates transformation from longitude/latitude/height to ENU (East-North-Up) X/Y/Z coordinates
56  * The WGS84 ellipsoid is used for the transformation. The coordinates are in 3D
57  * relative to some user-provided point, with local X axis being east-ward, Y north-ward, Z up-ward.
58  * For an explanation, refer to http://en.wikipedia.org/wiki/Reference_ellipsoid
59  * \sa coordinatesTransformation_WGS84_geocentric, ENU_axes_from_WGS84, ENUToGeocentric
60  */
62  const TGeodeticCoords &in_coords,
63  mrpt::math::TPoint3D &out_ENU_point,
64  const TGeodeticCoords &in_coords_origin );
65 
66  /** ENU to geocentric coordinates.
67  * \sa geodeticToENU_WGS84
68  */
70  const mrpt::math::TPoint3D &in_ENU_point,
71  const TGeodeticCoords &in_coords_origin,
72  TGeocentricCoords &out_coords,
73  const TEllipsoid &ellip );
74 
75  /** Coordinates transformation from longitude/latitude/height to geocentric X/Y/Z coordinates (with a WGS84 geoid).
76  * The WGS84 ellipsoid is used for the transformation. The coordinates are in 3D
77  * where the reference is the center of the Earth.
78  * For an explanation, refer to http://en.wikipedia.org/wiki/Reference_ellipsoid
79  * \sa geodeticToENU_WGS84
80  */
82  const TGeodeticCoords &in_coords,
83  mrpt::math::TPoint3D &out_point );
84 
85  /** Coordinates transformation from longitude/latitude/height to geocentric X/Y/Z coordinates (with an specified geoid).
86  * \sa geocentricToGeodetic
87  */
89  const TGeodeticCoords &in_coords,
90  TGeocentricCoords &out_point,
91  const TEllipsoid &ellip );
92 
93  /** Coordinates transformation from geocentric X/Y/Z coordinates to longitude/latitude/height.
94  * \sa geodeticToGeocentric
95  */
97  const TGeocentricCoords &in_point,
98  TGeodeticCoords &out_coords,
99  const TEllipsoid &ellip = TEllipsoid::Ellipsoid_WGS84() );
100 
101  /** 7-parameter Bursa-Wolf transformation:
102  * [ X Y Z ]_WGS84 = [ dX dY dZ ] + ( 1 + dS ) [ 1 RZ -RY; -RZ 1 RX; RY -RX 1 ] [ X Y Z ]_local
103  * \sa transform10params
104  */
106  const mrpt::math::TPoint3D &in_point,
107  const TDatum7Params &in_datum,
108  mrpt::math::TPoint3D &out_point);
109 
111  const mrpt::math::TPoint3D &in_point,
112  const TDatum7Params_TOPCON &in_datum,
113  mrpt::math::TPoint3D &out_point);
114 
115  /** 10-parameter Molodensky-Badekas transformation:
116  * [ X Y Z ]_WGS84 = [ dX dY dZ ] + ( 1 + dS ) [ 1 RZ -RY; -RZ 1 RX; RY -RX 1 ] [ X-Xp Y-Yp Z-Zp ]_local + [Xp Yp Zp]
117  * \sa transform7params
118  */
120  const mrpt::math::TPoint3D &in_point,
121  const TDatum10Params &in_datum,
122  mrpt::math::TPoint3D &out_point);
123 
124  /** Helmert 2D transformation:
125  * [ X Y ]_WGS84 = [ dX dY ] + ( 1 + dS ) [ cos(alpha) -sin(alpha); sin(alpha) cos(alpha) ] [ X-Xp Y-Yp Z-Zp ]_local + [Xp Yp Zp]
126  * \sa transformHelmert3D
127  */
129  const mrpt::math::TPoint2D &p,
130  const TDatumHelmert2D &d,
132 
134  const mrpt::math::TPoint2D &p,
135  const TDatumHelmert2D_TOPCON &d,
137 
138  /** Helmert3D transformation:
139  * [ X Y Z ]_WGS84 = [ dX dY dZ ] + ( 1 + dS ) [ 1 -RZ RY; RZ 1 -RX; -RY RX 1 ] [ X Y Z ]_local
140  * \sa transformHelmert2D
141  */
143  const mrpt::math::TPoint3D &p,
144  const TDatumHelmert3D &d,
146 
148  const mrpt::math::TPoint3D &p,
149  const TDatumHelmert3D_TOPCON &d,
151 
152  /** 1D transformation:
153  * [ Z ]_WGS84 = (dy * X - dx * Y + Z)*(1+e)+DZ
154  */
156  const mrpt::math::TPoint3D &p,
157  const TDatum1DTransf &d,
159 
160  /** Interpolation:
161  * [ Z ]_WGS84 = (dy * X - dx * Y + Z)*(1+e)+DZ
162  */
164  const mrpt::math::TPoint3D &p,
165  const TDatumTransfInterpolation &d,
167 
168  /** Returns the Geodetic coordinates of the UTM input point.
169  * \param X: East coordinate of the input point.
170  * \param Y: North coordinate of the input point.
171  * \param zone: time zone (Spanish: "huso").
172  * \param hem: hemisphere ('N'/'n' for North or 'S'/s' for South ). An exception will be raised on any other value.
173  * \param ellip: the reference ellipsoid used for the transformation (default: WGS84)
174  * \param out_lat Out latitude, in degrees.
175  * \param out_lon Out longitude, in degrees.
176  */
178  double X,
179  double Y,
180  int zone,
181  char hem,
182  double &out_lon /*degrees*/,
183  double &out_lat /*degrees*/,
185 
186  /** Returns the Geodetic coordinates of the UTM input point.
187  * \param UTMCoords: UTM input coordinates.
188  * \param zone: time zone (Spanish: "huso").
189  * \param hem: hemisphere ('N'/'n' for North or 'S'/s' for South ). An exception will be raised on any other value.
190  * \param GeodeticCoords: Out geodetic coordinates.
191  * \param ellip: the reference ellipsoid used for the transformation (default: WGS84)
192  */
193  inline void UTMToGeodetic(
194  const TUTMCoords &UTMCoords,
195  const int &zone,
196  const char &hem,
197  TGeodeticCoords &GeodeticCoords,
199  {
200  UTMToGeodetic( UTMCoords.x, UTMCoords.y, zone, hem, GeodeticCoords.lon.decimal_value, GeodeticCoords.lat.decimal_value, ellip );
201  GeodeticCoords.height = UTMCoords.z;
202  }
203 
204  /** Convert latitude and longitude coordinates into UTM coordinates, computing the corresponding UTM zone and latitude band.
205  * This method is based on public code by Gabriel Ruiz Martinez and Rafael Palacios.
206  * Example:
207  * \code
208  * Input:
209  * Lat=40.3154333 Lon=-3.4857166
210  * Output:
211  * x = 458731
212  * y = 4462881
213  * utm_zone = 30
214  * utm_band = T
215  * \endcode
216  * \sa http://www.mathworks.com/matlabcentral/fileexchange/10915
217  */
219  double in_latitude_degrees,
220  double in_longitude_degrees,
221  double &out_UTM_x,
222  double &out_UTM_y,
223  int &out_UTM_zone,
224  char &out_UTM_latitude_band,
225  TEllipsoid ellip = TEllipsoid::Ellipsoid_WGS84());
226 
228  const TGeodeticCoords &GeodeticCoords,
229  TUTMCoords &UTMCoords,
230  int &UTMZone,
231  char &UTMLatitudeBand,
232  TEllipsoid ellip = TEllipsoid::Ellipsoid_WGS84());
233 
234 
235  /** Convert latitude and longitude coordinates into UTM coordinates, computing the corresponding UTM zone and latitude band.
236  * This method is based on public code by Gabriel Ruiz Martinez and Rafael Palacios.
237  * Example:
238  * \code
239  * Input:
240  * Lat=40.3154333 Lon=-3.4857166
241  * Output:
242  * x = 458731
243  * y = 4462881
244  * utm_zone = 30
245  * utm_band = T
246  * \endcode
247  * \sa http://www.mathworks.com/matlabcentral/fileexchange/10915
248  */
249  inline void GeodeticToUTM(
250  const TGeodeticCoords &GeodeticCoords,
251  TUTMCoords &UTMCoords,
252  int &UTMZone,
253  char &UTMLatitudeBand,
255  {
256  GeodeticToUTM( GeodeticCoords.lat, GeodeticCoords.lon, UTMCoords.x, UTMCoords.y, UTMZone, UTMLatitudeBand, ellip );
257  UTMCoords.z = GeodeticCoords.height;
258  }
259 
260  /** @}
261  ======================================================================= */
262 
263 
264  /** =======================================================================
265  @name Miscellaneous
266  @{ */
267 
268  /** Returns the East-North-Up (ENU) coordinate system associated to the given point.
269  * This is the reference employed in geodeticToENU_WGS84
270  * \param only_angles If set to true, the (x,y,z) fields will be left zeroed.
271  * \sa geodeticToENU_WGS84
272  */
274  double in_longitude_reference_degrees,
275  double in_latitude_reference_degrees,
276  double in_height_reference_meters,
277  mrpt::math::TPose3D &out_ENU,
278  bool only_angles = false
279  );
280 
281  /** Returns the East-North-Up (ENU) coordinate system associated to the given point.
282  * This is the reference employed in coordinatesTransformation_WGS84
283  * \param only_angles If set to true, the (x,y,z) fields will be left zeroed.
284  * \sa geodeticToENU_WGS84
285  */
286  inline void ENU_axes_from_WGS84(
287  const TGeodeticCoords &in_coords,
288  mrpt::math::TPose3D &out_ENU,
289  bool only_angles = false
290  )
291  {
292  ENU_axes_from_WGS84(in_coords.lon,in_coords.lat,in_coords.height, out_ENU,only_angles);
293  }
294 
295  /** @}
296  ======================================================================= */
297 
298  /** @} */ // end of grouping
299 
300  } // End of namespace
301 
302 } // End of namespace
303 
304 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013