Main MRPT website > C++ reference for MRPT 1.5.9
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-2017, 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  /** \addtogroup mrpt_topography_grp
28  * @{ */
29 
30  /** @name Topography coordinate conversion functions
31  @{ */
32 
33  /** Coordinates transformation from longitude/latitude/height to ENU (East-North-Up) X/Y/Z coordinates
34  * The WGS84 ellipsoid is used for the transformation. The coordinates are in 3D
35  * relative to some user-provided point, with local X axis being east-ward, Y north-ward, Z up-ward.
36  * For an explanation, refer to http://en.wikipedia.org/wiki/Reference_ellipsoid
37  * \sa coordinatesTransformation_WGS84_geocentric, ENU_axes_from_WGS84, ENUToGeocentric
38  * \note The "Up" (Z) direction in ENU is the normal to the ellipsoid, which coincides with the direction of an increasing geodetic height.
39  */
41  const TGeodeticCoords &in_coords,
42  mrpt::math::TPoint3D &out_ENU_point,
43  const TGeodeticCoords &in_coords_origin );
44 
45  /** ENU to geocentric coordinates. \sa geodeticToENU_WGS84 */
47  const mrpt::math::TPoint3D &in_ENU_point,
48  const TGeodeticCoords &in_coords_origin,
49  TGeocentricCoords &out_coords,
50  const TEllipsoid &ellip );
51 
52  /** ENU to EFEC (Geocentric) coordinates \sa ENUToGeocentric, geodeticToENU_WGS84 */
54  const mrpt::math::TPoint3D &in_geocentric_point,
55  mrpt::math::TPoint3D &out_ENU_point,
56  const TGeodeticCoords &in_coords_origin );
57 
58  /** \overload More efficient for converting a pointcloud */
60  const std::vector<mrpt::math::TPoint3D> &in_geocentric_points,
61  std::vector<mrpt::math::TPoint3D> &out_ENU_points,
62  const TGeodeticCoords &in_coords_origin );
63 
64  /** Coordinates transformation from longitude/latitude/height to geocentric X/Y/Z coordinates (with a WGS84 geoid).
65  * The WGS84 ellipsoid is used for the transformation. The coordinates are in 3D
66  * where the reference is the center of the Earth.
67  * For an explanation, refer to http://en.wikipedia.org/wiki/Reference_ellipsoid
68  * \sa geodeticToENU_WGS84
69  */
71  const TGeodeticCoords &in_coords,
72  mrpt::math::TPoint3D &out_point );
73 
74  /** Coordinates transformation from longitude/latitude/height to geocentric X/Y/Z coordinates (with an specified geoid).
75  * \sa geocentricToGeodetic
76  */
78  const TGeodeticCoords &in_coords,
79  TGeocentricCoords &out_point,
80  const TEllipsoid &ellip );
81 
82  /** Coordinates transformation from geocentric X/Y/Z coordinates to longitude/latitude/height.
83  * \sa geodeticToGeocentric
84  */
86  const TGeocentricCoords &in_point,
87  TGeodeticCoords &out_coords,
88  const TEllipsoid &ellip = TEllipsoid::Ellipsoid_WGS84() );
89 
90  /** 7-parameter Bursa-Wolf transformation:
91  * [ X Y Z ]_WGS84 = [ dX dY dZ ] + ( 1 + dS ) [ 1 RZ -RY; -RZ 1 RX; RY -RX 1 ] [ X Y Z ]_local
92  * \sa transform10params
93  */
95  const mrpt::math::TPoint3D &in_point,
96  const TDatum7Params &in_datum,
97  mrpt::math::TPoint3D &out_point);
98 
100  const mrpt::math::TPoint3D &in_point,
101  const TDatum7Params_TOPCON &in_datum,
102  mrpt::math::TPoint3D &out_point);
103 
104  /** 10-parameter Molodensky-Badekas transformation:
105  * [ 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]
106  * \sa transform7params
107  */
109  const mrpt::math::TPoint3D &in_point,
110  const TDatum10Params &in_datum,
111  mrpt::math::TPoint3D &out_point);
112 
113  /** Helmert 2D transformation:
114  * [ 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]
115  * \sa transformHelmert3D
116  */
118  const mrpt::math::TPoint2D &p,
119  const TDatumHelmert2D &d,
121 
123  const mrpt::math::TPoint2D &p,
124  const TDatumHelmert2D_TOPCON &d,
126 
127  /** Helmert3D transformation:
128  * [ X Y Z ]_WGS84 = [ dX dY dZ ] + ( 1 + dS ) [ 1 -RZ RY; RZ 1 -RX; -RY RX 1 ] [ X Y Z ]_local
129  * \sa transformHelmert2D
130  */
132  const mrpt::math::TPoint3D &p,
133  const TDatumHelmert3D &d,
135 
137  const mrpt::math::TPoint3D &p,
138  const TDatumHelmert3D_TOPCON &d,
140 
141  /** 1D transformation:
142  * [ Z ]_WGS84 = (dy * X - dx * Y + Z)*(1+e)+DZ
143  */
145  const mrpt::math::TPoint3D &p,
146  const TDatum1DTransf &d,
148 
149  /** Interpolation:
150  * [ Z ]_WGS84 = (dy * X - dx * Y + Z)*(1+e)+DZ
151  */
153  const mrpt::math::TPoint3D &p,
154  const TDatumTransfInterpolation &d,
156 
157  /** Returns the Geodetic coordinates of the UTM input point.
158  * \param X: East coordinate of the input point.
159  * \param Y: North coordinate of the input point.
160  * \param zone: time zone (Spanish: "huso").
161  * \param hem: hemisphere ('N'/'n' for North or 'S'/s' for South ). An exception will be raised on any other value.
162  * \param ellip: the reference ellipsoid used for the transformation (default: WGS84)
163  * \param out_lat Out latitude, in degrees.
164  * \param out_lon Out longitude, in degrees.
165  */
167  double X,
168  double Y,
169  int zone,
170  char hem,
171  double &out_lon /*degrees*/,
172  double &out_lat /*degrees*/,
173  const TEllipsoid &ellip = TEllipsoid::Ellipsoid_WGS84() );
174 
175  /** Returns the Geodetic coordinates of the UTM input point.
176  * \param UTMCoords: UTM input coordinates.
177  * \param zone: time zone (Spanish: "huso").
178  * \param hem: hemisphere ('N'/'n' for North or 'S'/s' for South ). An exception will be raised on any other value.
179  * \param GeodeticCoords: Out geodetic coordinates.
180  * \param ellip: the reference ellipsoid used for the transformation (default: WGS84)
181  */
182  inline void UTMToGeodetic(
183  const TUTMCoords &UTMCoords,
184  const int &zone,
185  const char &hem,
186  TGeodeticCoords &GeodeticCoords,
187  const TEllipsoid &ellip = TEllipsoid::Ellipsoid_WGS84() )
188  {
189  UTMToGeodetic( UTMCoords.x, UTMCoords.y, zone, hem, GeodeticCoords.lon.decimal_value, GeodeticCoords.lat.decimal_value, ellip );
190  GeodeticCoords.height = UTMCoords.z;
191  }
192 
193  /** Convert latitude and longitude coordinates into UTM coordinates, computing the corresponding UTM zone and latitude band.
194  * This method is based on public code by Gabriel Ruiz Martinez and Rafael Palacios.
195  * Example:
196  * \code
197  * Input:
198  * Lat=40.3154333 Lon=-3.4857166
199  * Output:
200  * x = 458731
201  * y = 4462881
202  * utm_zone = 30
203  * utm_band = T
204  * \endcode
205  * \sa http://www.mathworks.com/matlabcentral/fileexchange/10915
206  */
208  double in_latitude_degrees,
209  double in_longitude_degrees,
210  double &out_UTM_x,
211  double &out_UTM_y,
212  int &out_UTM_zone,
213  char &out_UTM_latitude_band,
214  const TEllipsoid &ellip = TEllipsoid::Ellipsoid_WGS84());
215 
217  const TGeodeticCoords &GeodeticCoords,
218  TUTMCoords &UTMCoords,
219  int &UTMZone,
220  char &UTMLatitudeBand,
221  const TEllipsoid &ellip = TEllipsoid::Ellipsoid_WGS84());
222 
223 
224  /** Convert latitude and longitude coordinates into UTM coordinates, computing the corresponding UTM zone and latitude band.
225  * This method is based on public code by Gabriel Ruiz Martinez and Rafael Palacios.
226  * Example:
227  * \code
228  * Input:
229  * Lat=40.3154333 Lon=-3.4857166
230  * Output:
231  * x = 458731
232  * y = 4462881
233  * utm_zone = 30
234  * utm_band = T
235  * \endcode
236  * \sa http://www.mathworks.com/matlabcentral/fileexchange/10915
237  */
238  inline void GeodeticToUTM(
239  const TGeodeticCoords &GeodeticCoords,
240  TUTMCoords &UTMCoords,
241  int &UTMZone,
242  char &UTMLatitudeBand,
243  const TEllipsoid &ellip = TEllipsoid::Ellipsoid_WGS84())
244  {
245  GeodeticToUTM( GeodeticCoords.lat, GeodeticCoords.lon, UTMCoords.x, UTMCoords.y, UTMZone, UTMLatitudeBand, ellip );
246  UTMCoords.z = GeodeticCoords.height;
247  }
248 
249  /** @}
250  ======================================================================= */
251 
252 
253  /** =======================================================================
254  @name Miscellaneous
255  @{ */
256 
257  /** Returns the East-North-Up (ENU) coordinate system associated to the given point.
258  * This is the reference employed in geodeticToENU_WGS84
259  * \param only_angles If set to true, the (x,y,z) fields will be left zeroed.
260  * \note The "Up" (Z) direction in ENU is the normal to the ellipsoid, which coincides with the direction of an increasing geodetic height.
261  * \sa geodeticToENU_WGS84
262  */
264  double in_longitude_reference_degrees,
265  double in_latitude_reference_degrees,
266  double in_height_reference_meters,
267  mrpt::math::TPose3D &out_ENU,
268  bool only_angles = false
269  );
270 
271  /** \overload */
272  inline void ENU_axes_from_WGS84(
273  const TGeodeticCoords &in_coords,
274  mrpt::math::TPose3D &out_ENU,
275  bool only_angles = false
276  )
277  {
278  ENU_axes_from_WGS84(in_coords.lon,in_coords.lat,in_coords.height, out_ENU,only_angles);
279  }
280 
281  /** @}
282  ======================================================================= */
283 
284  /** @} */ // end of grouping
285 
286  } // End of namespace
287 
288 } // End of namespace
289 
290 #endif
void TOPO_IMPEXP transformHelmert2D_TOPCON(const mrpt::math::TPoint2D &p, const TDatumHelmert2D_TOPCON &d, mrpt::math::TPoint2D &o)
Helmert 2D transformation: [ X Y ]_WGS84 = [ dX dY ] + ( 1 + dS ) [ cos(alpha) -sin(alpha); sin(alpha...
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...
Parameters for a topographic transfomation.
Definition: data_types.h:237
Parameters for a topographic transfomation.
Definition: data_types.h:205
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 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.
A set of geodetic coordinates: latitude, longitude and height, defined over a given geoid (typically...
Definition: data_types.h:121
double z
X,Y,Z coordinates.
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
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...
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...
void TOPO_IMPEXP geocentricToENU_WGS84(const mrpt::math::TPoint3D &in_geocentric_point, mrpt::math::TPoint3D &out_ENU_point, const TGeodeticCoords &in_coords_origin)
ENU to EFEC (Geocentric) coordinates.
Definition: conversions.cpp:51
void TOPO_IMPEXP transformHelmert3D_TOPCON(const mrpt::math::TPoint3D &p, const TDatumHelmert3D_TOPCON &d, mrpt::math::TPoint3D &o)
Helmert 3D transformation: [ X Y ]_WGS84 = [ dX dY ] + ( 1 + dS ) [ cos(alpha) -sin(alpha); sin(alpha...
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...
Parameters for a topographic transfomation.
Definition: data_types.h:259
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.
Parameters for a topographic transfomation.
Definition: data_types.h:272
TCoords lon
Longitude (in degrees)
Definition: data_types.h:129
void TOPO_IMPEXP geodeticToUTM(const TGeodeticCoords &GeodeticCoords, TUTMCoords &UTMCoords, int &UTMZone, char &UTMLatitudeBand, const TEllipsoid &ellip=TEllipsoid::Ellipsoid_WGS84())
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 UTMToGeodetic(double X, double Y, int zone, char hem, double &out_lon, double &out_lat, const TEllipsoid &ellip=TEllipsoid::Ellipsoid_WGS84())
Returns the Geodetic coordinates of the UTM input point.
static TEllipsoid Ellipsoid_WGS84()
Definition: data_types.h:92
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Parameters for a topographic transfomation.
Definition: data_types.h:181
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.
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
double height
Geodetic height (in meters)
Definition: data_types.h:130
mrpt::math::TPoint3D TUTMCoords
Definition: data_types.h:117
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...
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:32
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, const TEllipsoid &ellip=TEllipsoid::Ellipsoid_WGS84())
Convert latitude and longitude coordinates into UTM coordinates, computing the corresponding UTM zone...
Parameters for a topographic transfomation.
Definition: data_types.h:140
Lightweight 2D point.
Parameters for a topographic transfomation.
Definition: data_types.h:289
GLfloat GLfloat p
Definition: glext.h:5587
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 ...
TCoords lat
Latitude (in degrees)
Definition: data_types.h:128
void TOPO_IMPEXP transform7params_TOPCON(const mrpt::math::TPoint3D &in_point, const TDatum7Params_TOPCON &in_datum, mrpt::math::TPoint3D &out_point)
7-parameter Bursa-Wolf transformation TOPCON: [ X Y Z ]_WGS84 = [ dX dY dZ ] + ( 1 + dS ) [ 1 RZ -RY;...



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020