00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://www.mrpt.org/ | 00005 | | 00006 | Copyright (C) 2005-2011 University of Malaga | 00007 | | 00008 | This software was written by the Machine Perception and Intelligent | 00009 | Robotics Lab, University of Malaga (Spain). | 00010 | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> | 00011 | | 00012 | This file is part of the MRPT project. | 00013 | | 00014 | MRPT is free software: you can redistribute it and/or modify | 00015 | it under the terms of the GNU General Public License as published by | 00016 | the Free Software Foundation, either version 3 of the License, or | 00017 | (at your option) any later version. | 00018 | | 00019 | MRPT is distributed in the hope that it will be useful, | 00020 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 00021 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 00022 | GNU General Public License for more details. | 00023 | | 00024 | You should have received a copy of the GNU General Public License | 00025 | along with MRPT. If not, see <http://www.gnu.org/licenses/>. | 00026 | | 00027 +---------------------------------------------------------------------------+ */ 00028 #ifndef conversions_H 00029 #define conversions_H 00030 00031 #include <mrpt/utils/utils_defs.h> 00032 #include <mrpt/math/lightweight_geom_data.h> 00033 00034 #include <mrpt/topography/link_pragmas.h> 00035 00036 #include <mrpt/topography/data_types.h> 00037 00038 00039 namespace mrpt 00040 { 00041 /** This namespace provides topography helper functions, coordinate transformations. 00042 * \ingroup mrpt_topography_grp 00043 */ 00044 namespace topography 00045 { 00046 using namespace std; 00047 using namespace mrpt::utils; 00048 00049 /** \addtogroup mrpt_topography_grp 00050 * @{ */ 00051 00052 /** @name Topography coordinate conversion functions 00053 @{ */ 00054 00055 /** Coordinates transformation from longitude/latitude/height to ENU (East-North-Up) X/Y/Z coordinates 00056 * The WGS84 ellipsoid is used for the transformation. The coordinates are in 3D 00057 * relative to some user-provided point, with local X axis being east-ward, Y north-ward, Z up-ward. 00058 * For an explanation, refer to http://en.wikipedia.org/wiki/Reference_ellipsoid 00059 * \sa coordinatesTransformation_WGS84_geocentric, ENU_axes_from_WGS84, ENUToGeocentric 00060 */ 00061 void TOPO_IMPEXP geodeticToENU_WGS84( 00062 const TGeodeticCoords &in_coords, 00063 mrpt::math::TPoint3D &out_ENU_point, 00064 const TGeodeticCoords &in_coords_origin ); 00065 00066 /** ENU to geocentric coordinates. 00067 * \sa geodeticToENU_WGS84 00068 */ 00069 void TOPO_IMPEXP ENUToGeocentric( 00070 const mrpt::math::TPoint3D &in_ENU_point, 00071 const TGeodeticCoords &in_coords_origin, 00072 TGeocentricCoords &out_coords, 00073 const TEllipsoid &ellip ); 00074 00075 /** Coordinates transformation from longitude/latitude/height to geocentric X/Y/Z coordinates (with a WGS84 geoid). 00076 * The WGS84 ellipsoid is used for the transformation. The coordinates are in 3D 00077 * where the reference is the center of the Earth. 00078 * For an explanation, refer to http://en.wikipedia.org/wiki/Reference_ellipsoid 00079 * \sa geodeticToENU_WGS84 00080 */ 00081 void TOPO_IMPEXP geodeticToGeocentric_WGS84( 00082 const TGeodeticCoords &in_coords, 00083 mrpt::math::TPoint3D &out_point ); 00084 00085 /** Coordinates transformation from longitude/latitude/height to geocentric X/Y/Z coordinates (with an specified geoid). 00086 * \sa geocentricToGeodetic 00087 */ 00088 void TOPO_IMPEXP geodeticToGeocentric( 00089 const TGeodeticCoords &in_coords, 00090 TGeocentricCoords &out_point, 00091 const TEllipsoid &ellip ); 00092 00093 /** Coordinates transformation from geocentric X/Y/Z coordinates to longitude/latitude/height. 00094 * \sa geodeticToGeocentric 00095 */ 00096 void TOPO_IMPEXP geocentricToGeodetic( 00097 const TGeocentricCoords &in_point, 00098 TGeodeticCoords &out_coords, 00099 const TEllipsoid &ellip = TEllipsoid::Ellipsoid_WGS84() ); 00100 00101 /** 7-parameter Bursa-Wolf transformation: 00102 * [ X Y Z ]_WGS84 = [ dX dY dZ ] + ( 1 + dS ) [ 1 RZ -RY; -RZ 1 RX; RY -RX 1 ] [ X Y Z ]_local 00103 * \sa transform10params 00104 */ 00105 void TOPO_IMPEXP transform7params( 00106 const mrpt::math::TPoint3D &in_point, 00107 const TDatum7Params &in_datum, 00108 mrpt::math::TPoint3D &out_point); 00109 00110 void TOPO_IMPEXP transform7params_TOPCON( 00111 const mrpt::math::TPoint3D &in_point, 00112 const TDatum7Params_TOPCON &in_datum, 00113 mrpt::math::TPoint3D &out_point); 00114 00115 /** 10-parameter Molodensky-Badekas transformation: 00116 * [ 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] 00117 * \sa transform7params 00118 */ 00119 void TOPO_IMPEXP transform10params( 00120 const mrpt::math::TPoint3D &in_point, 00121 const TDatum10Params &in_datum, 00122 mrpt::math::TPoint3D &out_point); 00123 00124 /** Helmert 2D transformation: 00125 * [ 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] 00126 * \sa transformHelmert3D 00127 */ 00128 void TOPO_IMPEXP transformHelmert2D( 00129 const mrpt::math::TPoint2D &p, 00130 const TDatumHelmert2D &d, 00131 mrpt::math::TPoint2D &o); 00132 00133 void TOPO_IMPEXP transformHelmert2D_TOPCON( 00134 const mrpt::math::TPoint2D &p, 00135 const TDatumHelmert2D_TOPCON &d, 00136 mrpt::math::TPoint2D &o); 00137 00138 /** Helmert3D transformation: 00139 * [ X Y Z ]_WGS84 = [ dX dY dZ ] + ( 1 + dS ) [ 1 -RZ RY; RZ 1 -RX; -RY RX 1 ] [ X Y Z ]_local 00140 * \sa transformHelmert2D 00141 */ 00142 void TOPO_IMPEXP transformHelmert3D( 00143 const mrpt::math::TPoint3D &p, 00144 const TDatumHelmert3D &d, 00145 mrpt::math::TPoint3D &o); 00146 00147 void TOPO_IMPEXP transformHelmert3D_TOPCON( 00148 const mrpt::math::TPoint3D &p, 00149 const TDatumHelmert3D_TOPCON &d, 00150 mrpt::math::TPoint3D &o); 00151 00152 /** 1D transformation: 00153 * [ Z ]_WGS84 = (dy * X - dx * Y + Z)*(1+e)+DZ 00154 */ 00155 void TOPO_IMPEXP transform1D( 00156 const mrpt::math::TPoint3D &p, 00157 const TDatum1DTransf &d, 00158 mrpt::math::TPoint3D &o); 00159 00160 /** Interpolation: 00161 * [ Z ]_WGS84 = (dy * X - dx * Y + Z)*(1+e)+DZ 00162 */ 00163 void TOPO_IMPEXP transfInterpolation( 00164 const mrpt::math::TPoint3D &p, 00165 const TDatumTransfInterpolation &d, 00166 mrpt::math::TPoint3D &o); 00167 00168 /** Returns the Geodetic coordinates of the UTM input point. 00169 * \param X: East coordinate of the input point. 00170 * \param Y: North coordinate of the input point. 00171 * \param zone: time zone (Spanish: "huso"). 00172 * \param hem: hemisphere ('N'/'n' for North or 'S'/s' for South ). An exception will be raised on any other value. 00173 * \param ellip: the reference ellipsoid used for the transformation (default: WGS84) 00174 * \param out_lat Out latitude, in degrees. 00175 * \param out_lon Out longitude, in degrees. 00176 */ 00177 void TOPO_IMPEXP UTMToGeodetic( 00178 double X, 00179 double Y, 00180 int zone, 00181 char hem, 00182 double &out_lon /*degrees*/, 00183 double &out_lat /*degrees*/, 00184 TEllipsoid ellip = TEllipsoid::Ellipsoid_WGS84() ); 00185 00186 /** Returns the Geodetic coordinates of the UTM input point. 00187 * \param UTMCoords: UTM input coordinates. 00188 * \param zone: time zone (Spanish: "huso"). 00189 * \param hem: hemisphere ('N'/'n' for North or 'S'/s' for South ). An exception will be raised on any other value. 00190 * \param GeodeticCoords: Out geodetic coordinates. 00191 * \param ellip: the reference ellipsoid used for the transformation (default: WGS84) 00192 */ 00193 inline void UTMToGeodetic( 00194 const TUTMCoords &UTMCoords, 00195 const int &zone, 00196 const char &hem, 00197 TGeodeticCoords &GeodeticCoords, 00198 TEllipsoid ellip = TEllipsoid::Ellipsoid_WGS84() ) 00199 { 00200 UTMToGeodetic( UTMCoords.x, UTMCoords.y, zone, hem, GeodeticCoords.lon.decimal_value, GeodeticCoords.lat.decimal_value, ellip ); 00201 GeodeticCoords.height = UTMCoords.z; 00202 } 00203 00204 /** Convert latitude and longitude coordinates into UTM coordinates, computing the corresponding UTM zone and latitude band. 00205 * This method is based on public code by Gabriel Ruiz Martinez and Rafael Palacios. 00206 * Example: 00207 * \code 00208 * Input: 00209 * Lat=40.3154333 Lon=-3.4857166 00210 * Output: 00211 * x = 458731 00212 * y = 4462881 00213 * utm_zone = 30 00214 * utm_band = T 00215 * \endcode 00216 * \sa http://www.mathworks.com/matlabcentral/fileexchange/10915 00217 */ 00218 void TOPO_IMPEXP GeodeticToUTM( 00219 double in_latitude_degrees, 00220 double in_longitude_degrees, 00221 double &out_UTM_x, 00222 double &out_UTM_y, 00223 int &out_UTM_zone, 00224 char &out_UTM_latitude_band, 00225 TEllipsoid ellip = TEllipsoid::Ellipsoid_WGS84()); 00226 00227 void TOPO_IMPEXP geodeticToUTM( 00228 const TGeodeticCoords &GeodeticCoords, 00229 TUTMCoords &UTMCoords, 00230 int &UTMZone, 00231 char &UTMLatitudeBand, 00232 TEllipsoid ellip = TEllipsoid::Ellipsoid_WGS84()); 00233 00234 00235 /** Convert latitude and longitude coordinates into UTM coordinates, computing the corresponding UTM zone and latitude band. 00236 * This method is based on public code by Gabriel Ruiz Martinez and Rafael Palacios. 00237 * Example: 00238 * \code 00239 * Input: 00240 * Lat=40.3154333 Lon=-3.4857166 00241 * Output: 00242 * x = 458731 00243 * y = 4462881 00244 * utm_zone = 30 00245 * utm_band = T 00246 * \endcode 00247 * \sa http://www.mathworks.com/matlabcentral/fileexchange/10915 00248 */ 00249 inline void GeodeticToUTM( 00250 const TGeodeticCoords &GeodeticCoords, 00251 TUTMCoords &UTMCoords, 00252 int &UTMZone, 00253 char &UTMLatitudeBand, 00254 TEllipsoid ellip = TEllipsoid::Ellipsoid_WGS84()) 00255 { 00256 GeodeticToUTM( GeodeticCoords.lat, GeodeticCoords.lon, UTMCoords.x, UTMCoords.y, UTMZone, UTMLatitudeBand, ellip ); 00257 UTMCoords.z = GeodeticCoords.height; 00258 } 00259 00260 /** @} 00261 ======================================================================= */ 00262 00263 00264 /** ======================================================================= 00265 @name Miscellaneous 00266 @{ */ 00267 00268 /** Returns the East-North-Up (ENU) coordinate system associated to the given point. 00269 * This is the reference employed in geodeticToENU_WGS84 00270 * \param only_angles If set to true, the (x,y,z) fields will be left zeroed. 00271 * \sa geodeticToENU_WGS84 00272 */ 00273 void TOPO_IMPEXP ENU_axes_from_WGS84( 00274 double in_longitude_reference_degrees, 00275 double in_latitude_reference_degrees, 00276 double in_height_reference_meters, 00277 mrpt::math::TPose3D &out_ENU, 00278 bool only_angles = false 00279 ); 00280 00281 /** Returns the East-North-Up (ENU) coordinate system associated to the given point. 00282 * This is the reference employed in coordinatesTransformation_WGS84 00283 * \param only_angles If set to true, the (x,y,z) fields will be left zeroed. 00284 * \sa geodeticToENU_WGS84 00285 */ 00286 inline void ENU_axes_from_WGS84( 00287 const TGeodeticCoords &in_coords, 00288 mrpt::math::TPose3D &out_ENU, 00289 bool only_angles = false 00290 ) 00291 { 00292 ENU_axes_from_WGS84(in_coords.lon,in_coords.lat,in_coords.height, out_ENU,only_angles); 00293 } 00294 00295 /** @} 00296 ======================================================================= */ 00297 00298 /** @} */ // end of grouping 00299 00300 } // End of namespace 00301 00302 } // End of namespace 00303 00304 #endif
| Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011 |