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



Page generated by Doxygen 1.8.11 for MRPT 1.3.2 SVN: at Wed May 25 02:34:21 UTC 2016