MRPT  2.0.4
conversions.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <mrpt/math/TPoint3D.h>
13 #include <vector>
14 
15 namespace mrpt
16 {
17 /** This namespace provides topography helper functions, coordinate
18  * transformations.
19  * \ingroup mrpt_topography_grp
20  */
21 namespace topography
22 {
23 /** \addtogroup mrpt_topography_grp
24  * @{ */
25 
26 /** @name Topography coordinate conversion functions
27  @{ */
28 
29 /** Coordinates transformation from longitude/latitude/height to ENU
30  * (East-North-Up) X/Y/Z coordinates
31  * The WGS84 ellipsoid is used for the transformation. The coordinates are in
32  * 3D
33  * relative to some user-provided point, with local X axis being east-ward, Y
34  * north-ward, Z up-ward.
35  * For an explanation, refer to
36  * http://en.wikipedia.org/wiki/Reference_ellipsoid
37  * \sa coordinatesTransformation_WGS84_geocentric, ENU_axes_from_WGS84,
38  * ENUToGeocentric
39  * \note The "Up" (Z) direction in ENU is the normal to the ellipsoid, which
40  * coincides with the direction of an increasing geodetic height.
41  */
43  const TGeodeticCoords& in_coords, mrpt::math::TPoint3D& out_ENU_point,
44  const TGeodeticCoords& in_coords_origin);
45 
46 /** ENU to geocentric coordinates. \sa geodeticToENU_WGS84 */
47 void ENUToGeocentric(
48  const mrpt::math::TPoint3D& in_ENU_point,
49  const TGeodeticCoords& in_coords_origin, TGeocentricCoords& out_coords,
50  const TEllipsoid& ellip);
51 
52 /** ENU to EFEC (Geocentric) coordinates \sa ENUToGeocentric,
53  * geodeticToENU_WGS84 */
55  const mrpt::math::TPoint3D& in_geocentric_point,
56  mrpt::math::TPoint3D& out_ENU_point,
57  const TGeodeticCoords& in_coords_origin);
58 
59 /** \overload More efficient for converting a pointcloud */
61  const std::vector<mrpt::math::TPoint3D>& in_geocentric_points,
62  std::vector<mrpt::math::TPoint3D>& out_ENU_points,
63  const TGeodeticCoords& in_coords_origin);
64 
65 /** Coordinates transformation from longitude/latitude/height to geocentric
66  * X/Y/Z coordinates (with a WGS84 geoid).
67  * The WGS84 ellipsoid is used for the transformation. The coordinates are in
68  * 3D
69  * where the reference is the center of the Earth.
70  * For an explanation, refer to
71  * http://en.wikipedia.org/wiki/Reference_ellipsoid
72  * \sa geodeticToENU_WGS84
73  */
75  const TGeodeticCoords& in_coords, mrpt::math::TPoint3D& out_point);
76 
77 /** Coordinates transformation from longitude/latitude/height to geocentric
78  * X/Y/Z coordinates (with an specified geoid).
79  * \sa geocentricToGeodetic
80  */
82  const TGeodeticCoords& in_coords, TGeocentricCoords& out_point,
83  const TEllipsoid& ellip);
84 
85 /** Coordinates transformation from geocentric X/Y/Z coordinates to
86  * longitude/latitude/height.
87  * \sa geodeticToGeocentric
88  */
90  const TGeocentricCoords& in_point, TGeodeticCoords& out_coords,
91  const TEllipsoid& ellip = TEllipsoid::Ellipsoid_WGS84());
92 
93 /** 7-parameter Bursa-Wolf transformation:
94  * [ X Y Z ]_WGS84 = [ dX dY dZ ] + ( 1 + dS ) [ 1 RZ -RY; -RZ 1 RX; RY -RX 1
95  * ] [ X Y Z ]_local
96  * \sa transform10params
97  */
98 void transform7params(
99  const mrpt::math::TPoint3D& in_point, const TDatum7Params& in_datum,
100  mrpt::math::TPoint3D& out_point);
101 
103  const mrpt::math::TPoint3D& in_point, const TDatum7Params_TOPCON& in_datum,
104  mrpt::math::TPoint3D& out_point);
105 
106 /** 10-parameter Molodensky-Badekas transformation:
107  * [ X Y Z ]_WGS84 = [ dX dY dZ ] + ( 1 + dS ) [ 1 RZ -RY; -RZ 1 RX; RY -RX 1
108  * ] [ X-Xp Y-Yp Z-Zp ]_local + [Xp Yp Zp]
109  * \sa transform7params
110  */
111 void transform10params(
112  const mrpt::math::TPoint3D& in_point, const TDatum10Params& in_datum,
113  mrpt::math::TPoint3D& out_point);
114 
115 /** Helmert 2D transformation:
116  * [ X Y ]_WGS84 = [ dX dY ] + ( 1 + dS ) [ cos(alpha) -sin(alpha);
117  * sin(alpha) cos(alpha) ] [ X-Xp Y-Yp Z-Zp ]_local + [Xp Yp Zp]
118  * \sa transformHelmert3D
119  */
120 void transformHelmert2D(
121  const mrpt::math::TPoint2D& p, const TDatumHelmert2D& d,
123 
125  const mrpt::math::TPoint2D& p, const TDatumHelmert2D_TOPCON& d,
127 
128 /** Helmert3D transformation:
129  * [ X Y Z ]_WGS84 = [ dX dY dZ ] + ( 1 + dS ) [ 1 -RZ RY; RZ 1 -RX; -RY RX 1
130  * ] [ X Y Z ]_local
131  * \sa transformHelmert2D
132  */
133 void transformHelmert3D(
134  const mrpt::math::TPoint3D& p, const TDatumHelmert3D& d,
136 
138  const mrpt::math::TPoint3D& p, const TDatumHelmert3D_TOPCON& d,
140 
141 /** 1D transformation:
142  * [ Z ]_WGS84 = (dy * X - dx * Y + Z)*(1+e)+DZ
143  */
144 void transform1D(
145  const mrpt::math::TPoint3D& p, const TDatum1DTransf& d,
147 
148 /** Interpolation:
149  * [ Z ]_WGS84 = (dy * X - dx * Y + Z)*(1+e)+DZ
150  */
154 
155 /** Returns the Geodetic coordinates of the UTM input point.
156  * \param X: East coordinate of the input point.
157  * \param Y: North coordinate of the input point.
158  * \param zone: time zone (Spanish: "huso").
159  * \param hem: hemisphere ('N'/'n' for North or 'S'/s' for South ). An
160  * exception will be raised on any other value.
161  * \param ellip: the reference ellipsoid used for the transformation (default:
162  * WGS84)
163  * \param out_lat Out latitude, in degrees.
164  * \param out_lon Out longitude, in degrees.
165  */
166 void UTMToGeodetic(
167  double X, double Y, int zone, char hem, double& out_lon /*degrees*/,
168  double& out_lat /*degrees*/,
169  const TEllipsoid& ellip = TEllipsoid::Ellipsoid_WGS84());
170 
171 /** Returns the Geodetic coordinates of the UTM input point.
172  * \param UTMCoords: UTM input coordinates.
173  * \param zone: time zone (Spanish: "huso").
174  * \param hem: hemisphere ('N'/'n' for North or 'S'/s' for South ). An
175  * exception will be raised on any other value.
176  * \param GeodeticCoords: Out geodetic coordinates.
177  * \param ellip: the reference ellipsoid used for the transformation (default:
178  * WGS84)
179  */
180 inline void UTMToGeodetic(
181  const TUTMCoords& UTMCoords, int zone, char hem,
182  TGeodeticCoords& GeodeticCoords,
183  const TEllipsoid& ellip = TEllipsoid::Ellipsoid_WGS84())
184 {
186  UTMCoords.x, UTMCoords.y, zone, hem, GeodeticCoords.lon.decimal_value,
187  GeodeticCoords.lat.decimal_value, ellip);
188  GeodeticCoords.height = UTMCoords.z;
189 }
190 
191 /** Convert latitude and longitude coordinates into UTM coordinates, computing
192  * the corresponding UTM zone and latitude band.
193  * This method is based on public code by Gabriel Ruiz Martinez and Rafael
194  * 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  */
207 void GeodeticToUTM(
208  double in_latitude_degrees, double in_longitude_degrees, double& out_UTM_x,
209  double& out_UTM_y, int& out_UTM_zone, char& out_UTM_latitude_band,
210  const TEllipsoid& ellip = TEllipsoid::Ellipsoid_WGS84());
211 
212 void geodeticToUTM(
213  const TGeodeticCoords& GeodeticCoords, TUTMCoords& UTMCoords, int& UTMZone,
214  char& UTMLatitudeBand,
215  const TEllipsoid& ellip = TEllipsoid::Ellipsoid_WGS84());
216 
217 /** Convert latitude and longitude coordinates into UTM coordinates, computing
218  * the corresponding UTM zone and latitude band.
219  * This method is based on public code by Gabriel Ruiz Martinez and Rafael
220  * Palacios.
221  * Example:
222  * \code
223  * Input:
224  * Lat=40.3154333 Lon=-3.4857166
225  * Output:
226  * x = 458731
227  * y = 4462881
228  * utm_zone = 30
229  * utm_band = T
230  * \endcode
231  * \sa http://www.mathworks.com/matlabcentral/fileexchange/10915
232  */
233 inline void GeodeticToUTM(
234  const TGeodeticCoords& GeodeticCoords, TUTMCoords& UTMCoords, int& UTMZone,
235  char& UTMLatitudeBand,
236  const TEllipsoid& ellip = TEllipsoid::Ellipsoid_WGS84())
237 {
239  GeodeticCoords.lat, GeodeticCoords.lon, UTMCoords.x, UTMCoords.y,
240  UTMZone, UTMLatitudeBand, ellip);
241  UTMCoords.z = GeodeticCoords.height;
242 }
243 
244 /** @}
245  ======================================================================= */
246 
247 /** =======================================================================
248  @name Miscellaneous
249  @{ */
250 
251 /** Returns the East-North-Up (ENU) coordinate system associated to the given
252  * point.
253  * This is the reference employed in geodeticToENU_WGS84
254  * \param only_angles If set to true, the (x,y,z) fields will be left zeroed.
255  * \note The "Up" (Z) direction in ENU is the normal to the ellipsoid, which
256  * coincides with the direction of an increasing geodetic height.
257  * \sa geodeticToENU_WGS84
258  */
260  double in_longitude_reference_degrees, double in_latitude_reference_degrees,
261  double in_height_reference_meters, mrpt::math::TPose3D& out_ENU,
262  bool only_angles = false);
263 
264 /** \overload */
265 inline void ENU_axes_from_WGS84(
266  const TGeodeticCoords& in_coords, mrpt::math::TPose3D& out_ENU,
267  bool only_angles = false)
268 {
270  in_coords.lon, in_coords.lat, in_coords.height, out_ENU, only_angles);
271 }
272 
273 /** @}
274  ======================================================================= */
275 
276 /** @} */ // end of grouping
277 
278 } // namespace topography
279 
280 } // namespace mrpt
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:333
Parameters for a topographic transfomation.
Definition: data_types.h:301
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:192
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:357
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:372
TCoords lon
Longitude (in degrees)
Definition: data_types.h:209
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.
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:95
T x
X,Y,Z coordinates.
Definition: TPoint3D.h:29
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
mrpt::math::TPoint3D TUTMCoords
Definition: data_types.h:187
Parameters for a topographic transfomation.
Definition: data_types.h:274
Base template for TPoint3D and TPoint3Df.
Definition: TPoint3D.h:37
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).
Definition: TPose3D.h:24
double height
Geodetic height (in meters)
Definition: data_types.h:211
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...
double decimal_value
Also obtained directly through the double(void) operator using a TCoords anywhere were a double is ex...
Definition: data_types.h:29
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:220
Parameters for a topographic transfomation.
Definition: data_types.h:390
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:207
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 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020