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