Main MRPT website > C++ reference for MRPT 1.9.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-2018, 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 
13 
15 
16 namespace mrpt
17 {
18 /** This namespace provides topography helper functions, coordinate
19  * transformations.
20  * \ingroup mrpt_topography_grp
21  */
22 namespace topography
23 {
24 /** \addtogroup mrpt_topography_grp
25  * @{ */
26 
27 /** @name Topography coordinate conversion functions
28  @{ */
29 
30 /** Coordinates transformation from longitude/latitude/height to ENU
31  * (East-North-Up) X/Y/Z coordinates
32  * The WGS84 ellipsoid is used for the transformation. The coordinates are in
33  * 3D
34  * relative to some user-provided point, with local X axis being east-ward, Y
35  * north-ward, Z up-ward.
36  * For an explanation, refer to
37  * http://en.wikipedia.org/wiki/Reference_ellipsoid
38  * \sa coordinatesTransformation_WGS84_geocentric, ENU_axes_from_WGS84,
39  * ENUToGeocentric
40  * \note The "Up" (Z) direction in ENU is the normal to the ellipsoid, which
41  * coincides with the direction of an increasing geodetic height.
42  */
44  const TGeodeticCoords& in_coords, mrpt::math::TPoint3D& out_ENU_point,
45  const TGeodeticCoords& in_coords_origin);
46 
47 /** ENU to geocentric coordinates. \sa geodeticToENU_WGS84 */
48 void ENUToGeocentric(
49  const mrpt::math::TPoint3D& in_ENU_point,
50  const TGeodeticCoords& in_coords_origin, TGeocentricCoords& out_coords,
51  const TEllipsoid& ellip);
52 
53 /** ENU to EFEC (Geocentric) coordinates \sa ENUToGeocentric,
54  * geodeticToENU_WGS84 */
56  const mrpt::math::TPoint3D& in_geocentric_point,
57  mrpt::math::TPoint3D& out_ENU_point,
58  const TGeodeticCoords& in_coords_origin);
59 
60 /** \overload More efficient for converting a pointcloud */
62  const std::vector<mrpt::math::TPoint3D>& in_geocentric_points,
63  std::vector<mrpt::math::TPoint3D>& out_ENU_points,
64  const TGeodeticCoords& in_coords_origin);
65 
66 /** Coordinates transformation from longitude/latitude/height to geocentric
67  * X/Y/Z coordinates (with a WGS84 geoid).
68  * The WGS84 ellipsoid is used for the transformation. The coordinates are in
69  * 3D
70  * where the reference is the center of the Earth.
71  * For an explanation, refer to
72  * http://en.wikipedia.org/wiki/Reference_ellipsoid
73  * \sa geodeticToENU_WGS84
74  */
76  const TGeodeticCoords& in_coords, mrpt::math::TPoint3D& out_point);
77 
78 /** Coordinates transformation from longitude/latitude/height to geocentric
79  * X/Y/Z coordinates (with an specified geoid).
80  * \sa geocentricToGeodetic
81  */
83  const TGeodeticCoords& in_coords, TGeocentricCoords& out_point,
84  const TEllipsoid& ellip);
85 
86 /** Coordinates transformation from geocentric X/Y/Z coordinates to
87  * longitude/latitude/height.
88  * \sa geodeticToGeocentric
89  */
91  const TGeocentricCoords& in_point, TGeodeticCoords& out_coords,
92  const TEllipsoid& ellip = TEllipsoid::Ellipsoid_WGS84());
93 
94 /** 7-parameter Bursa-Wolf transformation:
95  * [ X Y Z ]_WGS84 = [ dX dY dZ ] + ( 1 + dS ) [ 1 RZ -RY; -RZ 1 RX; RY -RX 1
96  * ] [ X Y Z ]_local
97  * \sa transform10params
98  */
99 void transform7params(
100  const mrpt::math::TPoint3D& in_point, const TDatum7Params& in_datum,
101  mrpt::math::TPoint3D& out_point);
102 
104  const mrpt::math::TPoint3D& in_point, const TDatum7Params_TOPCON& in_datum,
105  mrpt::math::TPoint3D& out_point);
106 
107 /** 10-parameter Molodensky-Badekas transformation:
108  * [ X Y Z ]_WGS84 = [ dX dY dZ ] + ( 1 + dS ) [ 1 RZ -RY; -RZ 1 RX; RY -RX 1
109  * ] [ X-Xp Y-Yp Z-Zp ]_local + [Xp Yp Zp]
110  * \sa transform7params
111  */
112 void transform10params(
113  const mrpt::math::TPoint3D& in_point, const TDatum10Params& in_datum,
114  mrpt::math::TPoint3D& out_point);
115 
116 /** Helmert 2D transformation:
117  * [ X Y ]_WGS84 = [ dX dY ] + ( 1 + dS ) [ cos(alpha) -sin(alpha);
118  * sin(alpha) cos(alpha) ] [ X-Xp Y-Yp Z-Zp ]_local + [Xp Yp Zp]
119  * \sa transformHelmert3D
120  */
121 void transformHelmert2D(
122  const mrpt::math::TPoint2D& p, const TDatumHelmert2D& d,
124 
128 
129 /** Helmert3D transformation:
130  * [ X Y Z ]_WGS84 = [ dX dY dZ ] + ( 1 + dS ) [ 1 -RZ RY; RZ 1 -RX; -RY RX 1
131  * ] [ X Y Z ]_local
132  * \sa transformHelmert2D
133  */
134 void transformHelmert3D(
135  const mrpt::math::TPoint3D& p, const TDatumHelmert3D& d,
137 
141 
142 /** 1D transformation:
143  * [ Z ]_WGS84 = (dy * X - dx * Y + Z)*(1+e)+DZ
144  */
145 void transform1D(
146  const mrpt::math::TPoint3D& p, const TDatum1DTransf& d,
148 
149 /** Interpolation:
150  * [ Z ]_WGS84 = (dy * X - dx * Y + Z)*(1+e)+DZ
151  */
155 
156 /** Returns the Geodetic coordinates of the UTM input point.
157  * \param X: East coordinate of the input point.
158  * \param Y: North coordinate of the input point.
159  * \param zone: time zone (Spanish: "huso").
160  * \param hem: hemisphere ('N'/'n' for North or 'S'/s' for South ). An
161  * exception will be raised on any other value.
162  * \param ellip: the reference ellipsoid used for the transformation (default:
163  * WGS84)
164  * \param out_lat Out latitude, in degrees.
165  * \param out_lon Out longitude, in degrees.
166  */
167 void UTMToGeodetic(
168  double X, double Y, int zone, char hem, double& out_lon /*degrees*/,
169  double& out_lat /*degrees*/,
170  const TEllipsoid& ellip = TEllipsoid::Ellipsoid_WGS84());
171 
172 /** Returns the Geodetic coordinates of the UTM input point.
173  * \param UTMCoords: UTM input coordinates.
174  * \param zone: time zone (Spanish: "huso").
175  * \param hem: hemisphere ('N'/'n' for North or 'S'/s' for South ). An
176  * exception will be raised on any other value.
177  * \param GeodeticCoords: Out geodetic coordinates.
178  * \param ellip: the reference ellipsoid used for the transformation (default:
179  * WGS84)
180  */
181 inline void UTMToGeodetic(
182  const TUTMCoords& UTMCoords, const int& zone, const char& hem,
183  TGeodeticCoords& GeodeticCoords,
184  const TEllipsoid& ellip = TEllipsoid::Ellipsoid_WGS84())
185 {
187  UTMCoords.x, UTMCoords.y, zone, hem, GeodeticCoords.lon.decimal_value,
188  GeodeticCoords.lat.decimal_value, ellip);
189  GeodeticCoords.height = UTMCoords.z;
190 }
191 
192 /** Convert latitude and longitude coordinates into UTM coordinates, computing
193  * the corresponding UTM zone and latitude band.
194  * This method is based on public code by Gabriel Ruiz Martinez and Rafael
195  * Palacios.
196  * Example:
197  * \code
198  * Input:
199  * Lat=40.3154333 Lon=-3.4857166
200  * Output:
201  * x = 458731
202  * y = 4462881
203  * utm_zone = 30
204  * utm_band = T
205  * \endcode
206  * \sa http://www.mathworks.com/matlabcentral/fileexchange/10915
207  */
208 void GeodeticToUTM(
209  double in_latitude_degrees, double in_longitude_degrees, double& out_UTM_x,
210  double& out_UTM_y, int& out_UTM_zone, char& out_UTM_latitude_band,
211  const TEllipsoid& ellip = TEllipsoid::Ellipsoid_WGS84());
212 
213 void geodeticToUTM(
214  const TGeodeticCoords& GeodeticCoords, TUTMCoords& UTMCoords, int& UTMZone,
215  char& UTMLatitudeBand,
216  const TEllipsoid& ellip = TEllipsoid::Ellipsoid_WGS84());
217 
218 /** Convert latitude and longitude coordinates into UTM coordinates, computing
219  * the corresponding UTM zone and latitude band.
220  * This method is based on public code by Gabriel Ruiz Martinez and Rafael
221  * Palacios.
222  * Example:
223  * \code
224  * Input:
225  * Lat=40.3154333 Lon=-3.4857166
226  * Output:
227  * x = 458731
228  * y = 4462881
229  * utm_zone = 30
230  * utm_band = T
231  * \endcode
232  * \sa http://www.mathworks.com/matlabcentral/fileexchange/10915
233  */
234 inline void GeodeticToUTM(
235  const TGeodeticCoords& GeodeticCoords, TUTMCoords& UTMCoords, int& UTMZone,
236  char& UTMLatitudeBand,
237  const TEllipsoid& ellip = TEllipsoid::Ellipsoid_WGS84())
238 {
240  GeodeticCoords.lat, GeodeticCoords.lon, UTMCoords.x, UTMCoords.y,
241  UTMZone, UTMLatitudeBand, ellip);
242  UTMCoords.z = GeodeticCoords.height;
243 }
244 
245 /** @}
246  ======================================================================= */
247 
248 /** =======================================================================
249  @name Miscellaneous
250  @{ */
251 
252 /** Returns the East-North-Up (ENU) coordinate system associated to the given
253  * point.
254  * This is the reference employed in geodeticToENU_WGS84
255  * \param only_angles If set to true, the (x,y,z) fields will be left zeroed.
256  * \note The "Up" (Z) direction in ENU is the normal to the ellipsoid, which
257  * coincides with the direction of an increasing geodetic height.
258  * \sa geodeticToENU_WGS84
259  */
261  double in_longitude_reference_degrees, double in_latitude_reference_degrees,
262  double in_height_reference_meters, mrpt::math::TPose3D& out_ENU,
263  bool only_angles = false);
264 
265 /** \overload */
266 inline void ENU_axes_from_WGS84(
267  const TGeodeticCoords& in_coords, mrpt::math::TPose3D& out_ENU,
268  bool only_angles = false)
269 {
271  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 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 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:336
Parameters for a topographic transfomation.
Definition: data_types.h:304
void 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 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:195
void 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 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 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 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:60
void 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 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:360
void 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:375
TCoords lon
Longitude (in degrees)
Definition: data_types.h:212
void geodeticToUTM(const TGeodeticCoords &GeodeticCoords, TUTMCoords &UTMCoords, int &UTMZone, char &UTMLatitudeBand, const TEllipsoid &ellip=TEllipsoid::Ellipsoid_WGS84())
void 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.
double x
X,Y,Z coordinates.
void 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:98
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
mrpt::math::TPoint3D TUTMCoords
Definition: data_types.h:190
Parameters for a topographic transfomation.
Definition: data_types.h:277
void 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:214
void 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 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:223
Lightweight 2D point.
Parameters for a topographic transfomation.
Definition: data_types.h:393
GLfloat GLfloat p
Definition: glext.h:6305
void 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:210
void 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.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019