Main MRPT website > C++ reference
MRPT logo
conversions.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2014, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 #ifndef conversions_H
10 #define conversions_H
11 
12 #include <mrpt/utils/utils_defs.h>
14 
16 
18 
19 
20 namespace mrpt
21 {
22  /** This namespace provides topography helper functions, coordinate transformations.
23  * \ingroup mrpt_topography_grp
24  */
25  namespace topography
26  {
27  using namespace std;
28  using namespace mrpt::utils;
29 
30  /** \addtogroup mrpt_topography_grp
31  * @{ */
32 
33  /** @name Topography coordinate conversion functions
34  @{ */
35 
36  /** Coordinates transformation from longitude/latitude/height to ENU (East-North-Up) X/Y/Z coordinates
37  * The WGS84 ellipsoid is used for the transformation. The coordinates are in 3D
38  * relative to some user-provided point, with local X axis being east-ward, Y north-ward, Z up-ward.
39  * For an explanation, refer to http://en.wikipedia.org/wiki/Reference_ellipsoid
40  * \sa coordinatesTransformation_WGS84_geocentric, ENU_axes_from_WGS84, ENUToGeocentric
41  * \note The "Up" (Z) direction in ENU is the normal to the ellipsoid, which coincides with the direction of an increasing geodetic height.
42  */
44  const TGeodeticCoords &in_coords,
45  mrpt::math::TPoint3D &out_ENU_point,
46  const TGeodeticCoords &in_coords_origin );
47 
48  /** ENU to geocentric coordinates.
49  * \sa geodeticToENU_WGS84
50  */
52  const mrpt::math::TPoint3D &in_ENU_point,
53  const TGeodeticCoords &in_coords_origin,
54  TGeocentricCoords &out_coords,
55  const TEllipsoid &ellip );
56 
57  /** Coordinates transformation from longitude/latitude/height to geocentric X/Y/Z coordinates (with a WGS84 geoid).
58  * The WGS84 ellipsoid is used for the transformation. The coordinates are in 3D
59  * where the reference is the center of the Earth.
60  * For an explanation, refer to http://en.wikipedia.org/wiki/Reference_ellipsoid
61  * \sa geodeticToENU_WGS84
62  */
64  const TGeodeticCoords &in_coords,
65  mrpt::math::TPoint3D &out_point );
66 
67  /** Coordinates transformation from longitude/latitude/height to geocentric X/Y/Z coordinates (with an specified geoid).
68  * \sa geocentricToGeodetic
69  */
71  const TGeodeticCoords &in_coords,
72  TGeocentricCoords &out_point,
73  const TEllipsoid &ellip );
74 
75  /** Coordinates transformation from geocentric X/Y/Z coordinates to longitude/latitude/height.
76  * \sa geodeticToGeocentric
77  */
79  const TGeocentricCoords &in_point,
80  TGeodeticCoords &out_coords,
81  const TEllipsoid &ellip = TEllipsoid::Ellipsoid_WGS84() );
82 
83  /** 7-parameter Bursa-Wolf transformation:
84  * [ X Y Z ]_WGS84 = [ dX dY dZ ] + ( 1 + dS ) [ 1 RZ -RY; -RZ 1 RX; RY -RX 1 ] [ X Y Z ]_local
85  * \sa transform10params
86  */
88  const mrpt::math::TPoint3D &in_point,
89  const TDatum7Params &in_datum,
90  mrpt::math::TPoint3D &out_point);
91 
93  const mrpt::math::TPoint3D &in_point,
94  const TDatum7Params_TOPCON &in_datum,
95  mrpt::math::TPoint3D &out_point);
96 
97  /** 10-parameter Molodensky-Badekas transformation:
98  * [ 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]
99  * \sa transform7params
100  */
102  const mrpt::math::TPoint3D &in_point,
103  const TDatum10Params &in_datum,
104  mrpt::math::TPoint3D &out_point);
105 
106  /** Helmert 2D transformation:
107  * [ 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]
108  * \sa transformHelmert3D
109  */
111  const mrpt::math::TPoint2D &p,
112  const TDatumHelmert2D &d,
114 
116  const mrpt::math::TPoint2D &p,
117  const TDatumHelmert2D_TOPCON &d,
119 
120  /** Helmert3D transformation:
121  * [ X Y Z ]_WGS84 = [ dX dY dZ ] + ( 1 + dS ) [ 1 -RZ RY; RZ 1 -RX; -RY RX 1 ] [ X Y Z ]_local
122  * \sa transformHelmert2D
123  */
125  const mrpt::math::TPoint3D &p,
126  const TDatumHelmert3D &d,
128 
130  const mrpt::math::TPoint3D &p,
131  const TDatumHelmert3D_TOPCON &d,
133 
134  /** 1D transformation:
135  * [ Z ]_WGS84 = (dy * X - dx * Y + Z)*(1+e)+DZ
136  */
138  const mrpt::math::TPoint3D &p,
139  const TDatum1DTransf &d,
141 
142  /** Interpolation:
143  * [ Z ]_WGS84 = (dy * X - dx * Y + Z)*(1+e)+DZ
144  */
146  const mrpt::math::TPoint3D &p,
147  const TDatumTransfInterpolation &d,
149 
150  /** Returns the Geodetic coordinates of the UTM input point.
151  * \param X: East coordinate of the input point.
152  * \param Y: North coordinate of the input point.
153  * \param zone: time zone (Spanish: "huso").
154  * \param hem: hemisphere ('N'/'n' for North or 'S'/s' for South ). An exception will be raised on any other value.
155  * \param ellip: the reference ellipsoid used for the transformation (default: WGS84)
156  * \param out_lat Out latitude, in degrees.
157  * \param out_lon Out longitude, in degrees.
158  */
160  double X,
161  double Y,
162  int zone,
163  char hem,
164  double &out_lon /*degrees*/,
165  double &out_lat /*degrees*/,
167 
168  /** Returns the Geodetic coordinates of the UTM input point.
169  * \param UTMCoords: UTM input coordinates.
170  * \param zone: time zone (Spanish: "huso").
171  * \param hem: hemisphere ('N'/'n' for North or 'S'/s' for South ). An exception will be raised on any other value.
172  * \param GeodeticCoords: Out geodetic coordinates.
173  * \param ellip: the reference ellipsoid used for the transformation (default: WGS84)
174  */
175  inline void UTMToGeodetic(
176  const TUTMCoords &UTMCoords,
177  const int &zone,
178  const char &hem,
179  TGeodeticCoords &GeodeticCoords,
181  {
182  UTMToGeodetic( UTMCoords.x, UTMCoords.y, zone, hem, GeodeticCoords.lon.decimal_value, GeodeticCoords.lat.decimal_value, ellip );
183  GeodeticCoords.height = UTMCoords.z;
184  }
185 
186  /** Convert latitude and longitude coordinates into UTM coordinates, computing the corresponding UTM zone and latitude band.
187  * This method is based on public code by Gabriel Ruiz Martinez and Rafael Palacios.
188  * Example:
189  * \code
190  * Input:
191  * Lat=40.3154333 Lon=-3.4857166
192  * Output:
193  * x = 458731
194  * y = 4462881
195  * utm_zone = 30
196  * utm_band = T
197  * \endcode
198  * \sa http://www.mathworks.com/matlabcentral/fileexchange/10915
199  */
201  double in_latitude_degrees,
202  double in_longitude_degrees,
203  double &out_UTM_x,
204  double &out_UTM_y,
205  int &out_UTM_zone,
206  char &out_UTM_latitude_band,
207  TEllipsoid ellip = TEllipsoid::Ellipsoid_WGS84());
208 
210  const TGeodeticCoords &GeodeticCoords,
211  TUTMCoords &UTMCoords,
212  int &UTMZone,
213  char &UTMLatitudeBand,
214  TEllipsoid ellip = TEllipsoid::Ellipsoid_WGS84());
215 
216 
217  /** Convert latitude and longitude coordinates into UTM coordinates, computing the corresponding UTM zone and latitude band.
218  * This method is based on public code by Gabriel Ruiz Martinez and Rafael Palacios.
219  * Example:
220  * \code
221  * Input:
222  * Lat=40.3154333 Lon=-3.4857166
223  * Output:
224  * x = 458731
225  * y = 4462881
226  * utm_zone = 30
227  * utm_band = T
228  * \endcode
229  * \sa http://www.mathworks.com/matlabcentral/fileexchange/10915
230  */
231  inline void GeodeticToUTM(
232  const TGeodeticCoords &GeodeticCoords,
233  TUTMCoords &UTMCoords,
234  int &UTMZone,
235  char &UTMLatitudeBand,
237  {
238  GeodeticToUTM( GeodeticCoords.lat, GeodeticCoords.lon, UTMCoords.x, UTMCoords.y, UTMZone, UTMLatitudeBand, ellip );
239  UTMCoords.z = GeodeticCoords.height;
240  }
241 
242  /** @}
243  ======================================================================= */
244 
245 
246  /** =======================================================================
247  @name Miscellaneous
248  @{ */
249 
250  /** Returns the East-North-Up (ENU) coordinate system associated to the given point.
251  * This is the reference employed in geodeticToENU_WGS84
252  * \param only_angles If set to true, the (x,y,z) fields will be left zeroed.
253  * \note The "Up" (Z) direction in ENU is the normal to the ellipsoid, which coincides with the direction of an increasing geodetic height.
254  * \sa geodeticToENU_WGS84
255  */
257  double in_longitude_reference_degrees,
258  double in_latitude_reference_degrees,
259  double in_height_reference_meters,
260  mrpt::math::TPose3D &out_ENU,
261  bool only_angles = false
262  );
263 
264  /** \overload */
265  inline void ENU_axes_from_WGS84(
266  const TGeodeticCoords &in_coords,
267  mrpt::math::TPose3D &out_ENU,
268  bool only_angles = false
269  )
270  {
271  ENU_axes_from_WGS84(in_coords.lon,in_coords.lat,in_coords.height, out_ENU,only_angles);
272  }
273 
274  /** @}
275  ======================================================================= */
276 
277  /** @} */ // end of grouping
278 
279  } // End of namespace
280 
281 } // End of namespace
282 
283 #endif
void TOPO_IMPEXP transform1D(const mrpt::math::TPoint3D &p, const TDatum1DTransf &d, mrpt::math::TPoint3D &o)
1D transformation: [ Z ]_WGS84 = (dy * X - dx * Y + Z)*(1+e)+DZ
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
Parameters for a topographic transfomation.
Definition: data_types.h:241
Parameters for a topographic transfomation.
Definition: data_types.h:209
void TOPO_IMPEXP transform7params(const mrpt::math::TPoint3D &in_point, const TDatum7Params &in_datum, mrpt::math::TPoint3D &out_point)
7-parameter Bursa-Wolf transformation: [ X Y Z ]_WGS84 = [ dX dY dZ ] + ( 1 + dS ) [ 1 RZ -RY; -RZ 1 ...
void TOPO_IMPEXP ENUToGeocentric(const mrpt::math::TPoint3D &in_ENU_point, const TGeodeticCoords &in_coords_origin, TGeocentricCoords &out_coords, const TEllipsoid &ellip)
ENU to geocentric coordinates.
A set of geodetic coordinates: latitude, longitude and height, defined over a given geoid (typically...
Definition: data_types.h:125
STL namespace.
double z
Z coordinate.
void TOPO_IMPEXP geodeticToGeocentric_WGS84(const TGeodeticCoords &in_coords, mrpt::math::TPoint3D &out_point)
Coordinates transformation from longitude/latitude/height to geocentric X/Y/Z coordinates (with a WGS...
void TOPO_IMPEXP geodeticToENU_WGS84(const TGeodeticCoords &in_coords, mrpt::math::TPoint3D &out_ENU_point, const TGeodeticCoords &in_coords_origin)
Coordinates transformation from longitude/latitude/height to ENU (East-North-Up) X/Y/Z coordinates Th...
Parameters for a topographic transfomation.
Definition: data_types.h:263
Parameters for a topographic transfomation.
Definition: data_types.h:276
void TOPO_IMPEXP geocentricToGeodetic(const TGeocentricCoords &in_point, TGeodeticCoords &out_coords, const TEllipsoid &ellip=TEllipsoid::Ellipsoid_WGS84())
Coordinates transformation from geocentric X/Y/Z coordinates to longitude/latitude/height.
void TOPO_IMPEXP transfInterpolation(const mrpt::math::TPoint3D &p, const TDatumTransfInterpolation &d, mrpt::math::TPoint3D &o)
Interpolation: [ Z ]_WGS84 = (dy * X - dx * Y + Z)*(1+e)+DZ.
void TOPO_IMPEXP transformHelmert2D(const mrpt::math::TPoint2D &p, const TDatumHelmert2D &d, mrpt::math::TPoint2D &o)
Helmert 2D transformation: [ X Y ]_WGS84 = [ dX dY ] + ( 1 + dS ) [ cos(alpha) -sin(alpha); sin(alpha...
TCoords lon
Longitude (in degrees)
Definition: data_types.h:133
void TOPO_IMPEXP UTMToGeodetic(double X, double Y, int zone, char hem, double &out_lon, double &out_lat, TEllipsoid ellip=TEllipsoid::Ellipsoid_WGS84())
Returns the Geodetic coordinates of the UTM input point.
void TOPO_IMPEXP transform7params_TOPCON(const mrpt::math::TPoint3D &in_point, const TDatum7Params_TOPCON &in_datum, mrpt::math::TPoint3D &out_point)
void TOPO_IMPEXP geodeticToUTM(const TGeodeticCoords &GeodeticCoords, TUTMCoords &UTMCoords, int &UTMZone, char &UTMLatitudeBand, TEllipsoid ellip=TEllipsoid::Ellipsoid_WGS84())
double x
X coordinate.
void TOPO_IMPEXP geodeticToGeocentric(const TGeodeticCoords &in_coords, TGeocentricCoords &out_point, const TEllipsoid &ellip)
Coordinates transformation from longitude/latitude/height to geocentric X/Y/Z coordinates (with an sp...
static TEllipsoid Ellipsoid_WGS84()
Definition: data_types.h:96
void TOPO_IMPEXP transformHelmert2D_TOPCON(const mrpt::math::TPoint2D &p, const TDatumHelmert2D_TOPCON &d, mrpt::math::TPoint2D &o)
void TOPO_IMPEXP transform10params(const mrpt::math::TPoint3D &in_point, const TDatum10Params &in_datum, mrpt::math::TPoint3D &out_point)
10-parameter Molodensky-Badekas transformation: [ X Y Z ]_WGS84 = [ dX dY dZ ] + ( 1 + dS ) [ 1 RZ -R...
void TOPO_IMPEXP ENU_axes_from_WGS84(double in_longitude_reference_degrees, double in_latitude_reference_degrees, double in_height_reference_meters, mrpt::math::TPose3D &out_ENU, bool only_angles=false)
Returns the East-North-Up (ENU) coordinate system associated to the given point.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Parameters for a topographic transfomation.
Definition: data_types.h:185
void TOPO_IMPEXP transformHelmert3D_TOPCON(const mrpt::math::TPoint3D &p, const TDatumHelmert3D_TOPCON &d, mrpt::math::TPoint3D &o)
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
double height
Geodetic height (in meters)
Definition: data_types.h:134
void TOPO_IMPEXP GeodeticToUTM(double in_latitude_degrees, double in_longitude_degrees, double &out_UTM_x, double &out_UTM_y, int &out_UTM_zone, char &out_UTM_latitude_band, TEllipsoid ellip=TEllipsoid::Ellipsoid_WGS84())
Convert latitude and longitude coordinates into UTM coordinates, computing the corresponding UTM zone...
mrpt::math::TPoint3D TUTMCoords
Definition: data_types.h:121
double y
Y coordinate.
Lightweight 3D point.
double decimal_value
Also obtained directly through the double(void) operator using a TCoords anywhere were a double is ex...
Definition: data_types.h:35
Parameters for a topographic transfomation.
Definition: data_types.h:144
Lightweight 2D point.
Parameters for a topographic transfomation.
Definition: data_types.h:293
TCoords lat
Latitude (in degrees)
Definition: data_types.h:132
void TOPO_IMPEXP transformHelmert3D(const mrpt::math::TPoint3D &p, const TDatumHelmert3D &d, mrpt::math::TPoint3D &o)
Helmert3D transformation: [ X Y Z ]_WGS84 = [ dX dY dZ ] + ( 1 + dS ) [ 1 -RZ RY; RZ 1 -RX; -RY RX 1 ...



Page generated by Doxygen 1.8.14 for MRPT 1.1.0 SVN: at lun oct 28 00:54:49 CET 2019 Hosted on:
SourceForge.net Logo