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 */
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
data_types.h
mrpt::topography::TUTMCoords
mrpt::math::TPoint3D TUTMCoords
Definition: data_types.h:190
mrpt::topography::GeodeticToUTM
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...
Definition: conversions.cpp:423
mrpt::topography::TDatumHelmert3D
Parameters for a topographic transfomation.
Definition: data_types.h:336
mrpt::topography::TDatumHelmert2D
Parameters for a topographic transfomation.
Definition: data_types.h:304
mrpt::topography::ENU_axes_from_WGS84
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.
Definition: conversions.cpp:150
mrpt::topography::TDatumTransfInterpolation
Parameters for a topographic transfomation.
Definition: data_types.h:393
mrpt::topography::transform1D
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
Definition: conversions.cpp:627
mrpt::topography::TDatumHelmert2D_TOPCON
Definition: data_types.h:322
mrpt::topography::TDatumHelmert3D_TOPCON
Parameters for a topographic transfomation.
Definition: data_types.h:360
mrpt::topography::geodeticToENU_WGS84
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...
Definition: conversions.cpp:126
mrpt::math::TPoint3D::z
double z
Definition: lightweight_geom_data.h:385
mrpt::topography::TDatum7Params_TOPCON
Definition: data_types.h:244
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::topography::transformHelmert3D
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 ...
Definition: conversions.cpp:601
p
GLfloat GLfloat p
Definition: glext.h:6305
mrpt::topography::transformHelmert2D_TOPCON
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...
Definition: conversions.cpp:588
mrpt::topography::ENUToGeocentric
void ENUToGeocentric(const mrpt::math::TPoint3D &in_ENU_point, const TGeodeticCoords &in_coords_origin, TGeocentricCoords &out_coords, const TEllipsoid &ellip)
ENU to geocentric coordinates.
Definition: conversions.cpp:653
mrpt::topography::geodeticToUTM
void geodeticToUTM(const TGeodeticCoords &GeodeticCoords, TUTMCoords &UTMCoords, int &UTMZone, char &UTMLatitudeBand, const TEllipsoid &ellip=TEllipsoid::Ellipsoid_WGS84())
Definition: conversions.cpp:333
mrpt::topography::TGeodeticCoords::lon
TCoords lon
Longitude (in degrees)
Definition: data_types.h:212
lightweight_geom_data.h
mrpt::topography::TEllipsoid::Ellipsoid_WGS84
static TEllipsoid Ellipsoid_WGS84()
Definition: data_types.h:98
mrpt::topography::transformHelmert3D_TOPCON
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...
Definition: conversions.cpp:614
mrpt::topography::geodeticToGeocentric_WGS84
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...
Definition: conversions.cpp:193
mrpt::topography::TGeodeticCoords
A set of geodetic coordinates: latitude, longitude and height, defined over a given geoid (typically,...
Definition: data_types.h:195
mrpt::topography::TDatum10Params
Parameters for a topographic transfomation.
Definition: data_types.h:277
mrpt::math::TPoint3D::x
double x
X,Y,Z coordinates.
Definition: lightweight_geom_data.h:385
mrpt::topography::UTMToGeodetic
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.
Definition: conversions.cpp:289
mrpt::math::TPose3D
Lightweight 3D pose (three spatial coordinates, plus three angular coordinates).
Definition: lightweight_geom_data.h:603
mrpt::math::TPoint2D
Lightweight 2D point.
Definition: lightweight_geom_data.h:42
mrpt::topography::transformHelmert2D
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...
Definition: conversions.cpp:570
mrpt::math::TPoint3D
Lightweight 3D point.
Definition: lightweight_geom_data.h:378
mrpt::topography::TEllipsoid
Definition: data_types.h:82
mrpt::topography::TGeodeticCoords::height
double height
Geodetic height (in meters)
Definition: data_types.h:214
mrpt::math::TPoint3D::y
double y
Definition: lightweight_geom_data.h:385
mrpt::topography::TDatum1DTransf
Parameters for a topographic transfomation.
Definition: data_types.h:375
mrpt::topography::transform7params
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 ...
Definition: conversions.cpp:518
mrpt::topography::transfInterpolation
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.
Definition: conversions.cpp:641
mrpt::topography::transform7params_TOPCON
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;...
Definition: conversions.cpp:534
mrpt::topography::transform10params
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...
Definition: conversions.cpp:550
mrpt::topography::geocentricToGeodetic
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.
Definition: conversions.cpp:259
mrpt::topography::geocentricToENU_WGS84
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
mrpt::topography::geodeticToGeocentric
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...
Definition: conversions.cpp:228
mrpt::topography::TDatum7Params
Parameters for a topographic transfomation.
Definition: data_types.h:223
mrpt::topography::TGeodeticCoords::lat
TCoords lat
Latitude (in degrees)
Definition: data_types.h:210
mrpt::topography::TCoords::decimal_value
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



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST