Main MRPT website > C++ reference
MRPT logo
data_types.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 #ifndef data_types_H
29 #define data_types_H
30 
31 #include <mrpt/utils/utils_defs.h>
33 
35 
36 namespace mrpt
37 {
38  namespace topography
39  {
40  using namespace std;
41  using namespace mrpt::utils;
42 
43  /** \addtogroup mrpt_topography_grp
44  * @{ */
45 
46  /** @name Data structures
47  @{ */
48 
49  /** A coordinate that is stored as a simple "decimal" angle in degrees, but can be retrieved/set in the form of DEGREES + arc-MINUTES + arc-SECONDS.
50  */
52  {
53  // Only keep one of the possible representations:
54  double decimal_value; //!< Also obtained directly through the double(void) operator using a TCoords anywhere were a double is expected.
55 
56  inline TCoords( const int _deg, const int _min, const double _sec ) { setDegMinSec(_deg,_min,_sec); }
57  inline TCoords( const double dec ) { setFromDecimal(dec); }
58  inline TCoords() { setFromDecimal(0); }
59 
60  /** Automatic conversion to a double value (read-only) */
61  inline operator double(void) const { return decimal_value; }
62 
63  /** Automatic conversion to a double value (read-only) */
64  inline operator double& (void) { return decimal_value; }
65 
66  /** Set from a decimal value (XX.YYYYY) in degrees. */
67  inline void setFromDecimal( const double dec ) { decimal_value = dec; }
68 
69  /** Get the decimal value (XX.YYYYY), in degrees - you can also use the automatic conversion between TCoords and a double. */
70  inline double getDecimalValue() const { return decimal_value; }
71 
72  /** Return the Deg Min' Sec'' representation of this value. */
73  inline void getDegMinSec( int &degrees, int &minutes, double &seconds) const
74  {
75  double aux = std::abs(decimal_value);
76  degrees = (int)aux;
77  minutes = (int)((aux - degrees)*60.0f);
78  seconds = ((aux - degrees)*60.0f - minutes)*60.0f;
79  if( decimal_value<0 ) degrees = -degrees;
80  }
81 
82  /** Set the coordinate from its Deg Min' Deg'' parts. */
83  inline void setDegMinSec(const int degrees, const int minutes, const double seconds)
84  {
85  decimal_value = std::abs(degrees)+minutes/60.0+seconds/3600.0;
86  if(degrees<0) decimal_value = - decimal_value;
87  }
88 
89  /** Return a string in the format "DEGdeg MIN' SEC''" */
90  inline std::string getAsString() const
91  {
92  int deg,min;
93  double sec;
94  getDegMinSec( deg,min,sec);
95  return mrpt::format("%ddeg %d' %.010f''",deg,min,sec );
96  }
97 
98  };
99 
100  bool TOPO_IMPEXP operator ==(const TCoords &a, const TCoords &o);
101  bool TOPO_IMPEXP operator !=(const TCoords &a, const TCoords &o);
102 
103  std::ostream TOPO_IMPEXP & operator<<( std::ostream& out, const TCoords &o );
104 
106  {
107  inline TEllipsoid() : sa( 6378137.0 ), sb( 6356752.314245 ), name("WGS84") {}
108  inline TEllipsoid( const double _sa, const double _sb, const string _name ) : sa(_sa), sb(_sb), name(_name) {}
109 
110  double sa; //!< largest semiaxis of the reference ellipsoid (in meters)
111  double sb; //!< smallest semiaxis of the reference ellipsoid (in meters)
112  string name; //!< the ellipsoid name
113 
114 
115  static inline TEllipsoid Ellipsoid_WGS84() { return TEllipsoid( 6378137.000, 6356752.314245, "WGS84" ); }
116  static inline TEllipsoid Ellipsoid_WGS72() { return TEllipsoid( 6378135.000, 6356750.519915, "WGS72" ); }
117  static inline TEllipsoid Ellipsoid_WGS66() { return TEllipsoid( 6378145.000, 6356759.769356, "WGS66" ); }
118  static inline TEllipsoid Ellipsoid_Walbeck_1817() { return TEllipsoid( 6376896.000, 6355834.846700, "Walbeck_1817" ); }
119  static inline TEllipsoid Ellipsoid_Sudamericano_1969() { return TEllipsoid( 6378160.000, 6356774.720000, "Sudamericano_1969" ); }
120  static inline TEllipsoid Ellipsoid_Nuevo_Internacional_1967() {return TEllipsoid( 6378157.500, 6356772.200000, "Nuevo_Internacional_1967" ); }
121  static inline TEllipsoid Ellipsoid_Mercury_Modificado_1968() { return TEllipsoid( 6378150.000, 6356768.337303, "Mercury_Modificado_1968" ); }
122  static inline TEllipsoid Ellipsoid_Mercury_1960() { return TEllipsoid( 6378166.000, 6356784.283666, "Mercury_1960" ); }
123  static inline TEllipsoid Ellipsoid_Krasovsky_1940() { return TEllipsoid( 6378245.000, 6356863.018800, "Krasovsky_1940" ); }
124  static inline TEllipsoid Ellipsoid_Internacional_1924() { return TEllipsoid( 6378388.000, 6356911.946130, "Internacional_1924" ); }
125  static inline TEllipsoid Ellipsoid_Internacional_1909() { return TEllipsoid( 6378388.000, 6356911.946130, "Internacional_1909" ); }
126  static inline TEllipsoid Ellipsoid_Hough_1960() { return TEllipsoid( 6378270.000, 6356794.343479, "Hough_1960" ); }
127  static inline TEllipsoid Ellipsoid_Helmert_1906() { return TEllipsoid( 6378200.000, 6356818.170000, "Helmert_1906" ); }
128  static inline TEllipsoid Ellipsoid_Hayford_1909() { return TEllipsoid( 6378388.000, 6356911.946130, "Hayford_1909" ); }
129  static inline TEllipsoid Ellipsoid_GRS80() { return TEllipsoid( 6378137.000, 6356752.314140, "GRS80" ); }
130  static inline TEllipsoid Ellipsoid_Fischer_1968() { return TEllipsoid( 6378150.000, 6356768.330000, "Fischer_1968" ); }
131  static inline TEllipsoid Ellipsoid_Fischer_1960() { return TEllipsoid( 6378166.000, 6356784.280000, "Fischer_1960" ); }
132  static inline TEllipsoid Ellipsoid_Clarke_1880() { return TEllipsoid( 6378249.145, 6356514.869550, "Clarke_1880" ); }
133  static inline TEllipsoid Ellipsoid_Clarke_1866() { return TEllipsoid( 6378206.400, 6356583.800000, "Clarke_1866" ); }
134  static inline TEllipsoid Ellipsoid_Bessel_1841() { return TEllipsoid( 6377397.155, 6356078.962840, "Bessel_1841" ); }
135  static inline TEllipsoid Ellipsoid_Airy_Modificado_1965() { return TEllipsoid( 6377340.189, 6356034.447900, "Airy_Modificado_1965" ); }
136  static inline TEllipsoid Ellipsoid_Airy_1830() { return TEllipsoid( 6377563.396, 6356256.910000, "Airy_1830" ); }
137  };
138 
139 
142 
143  /** A set of geodetic coordinates: latitude, longitude and height, defined over a given geoid (typically, WGS84) */
145  {
146  TGeodeticCoords() : lat(0),lon(0),height(0) {}
147  TGeodeticCoords(const double _lat, const double _lon, const double _height) : lat(_lat),lon(_lon),height(_height) {}
148 
149  inline bool isClear() const { return lat.getDecimalValue()==0 && lon.getDecimalValue()==0 && height==0; }
150 
151  TCoords lat; //!< Latitude (in degrees)
152  TCoords lon; //!< Longitude (in degrees)
153  double height; //!< Geodetic height (in meters)
154 
155  };
156 
157  bool TOPO_IMPEXP operator ==(const TGeodeticCoords &a, const TGeodeticCoords &o);
158  bool TOPO_IMPEXP operator !=(const TGeodeticCoords &a, const TGeodeticCoords &o);
159 
160  /** Parameters for a topographic transfomation
161  * \sa TDatum10Params, transform7params
162  */
164  {
165  double dX, dY, dZ; //!< Deltas (X,Y,Z)
166  double Rx, Ry, Rz; //!< Rotation components (in secs)
167  double dS; //!< Scale factor (in ppm) (Scale is 1+dS/1e6)
168 
170  const double _dX, const double _dY, const double _dZ,
171  const double _Rx, const double _Ry, const double _Rz,
172  const double _dS ) :
173  dX(_dX), dY(_dY), dZ(_dZ)
174  {
175  Rx = DEG2RAD(_Rx/60/60);
176  Ry = DEG2RAD(_Ry/60/60);
177  Rz = DEG2RAD(_Rz/60/60);
178  dS = _dS*1e-6;
179  }
180  };
181 
183  {
184  double dX, dY, dZ; //!< Deltas (X,Y,Z)
185  double m11, m12, m13, m21, m22, m23, m31, m32, m33;
186  double dS; //!< Scale factor (in ppm) (Scale is 1+dS/1e6)
187 
189  const double _dX, const double _dY, const double _dZ,
190  const double _m11, const double _m12, const double _m13,
191  const double _m21, const double _m22, const double _m23,
192  const double _m31, const double _m32, const double _m33,
193  const double _dS ) :
194  dX(_dX), dY(_dY), dZ(_dZ), m11(_m11), m12(_m12), m13(_m13), m21(_m21), m22(_m22), m23(_m23), m31(_m31), m32(_m32), m33(_m33)
195  {
196  dS = _dS*1e-6;
197  }
198  };
199 
200 
201  /** Parameters for a topographic transfomation
202  * \sa TDatum7Params, transform10params
203  */
205  {
206  double dX, dY, dZ; //!< Deltas (X,Y,Z)
207  double Xp, Yp, Zp; //!< To be substracted to the input point
208  double Rx, Ry, Rz; //!< Rotation components
209  double dS; //!< Scale factor (Scale is 1+dS)
210 
212  const double _dX, const double _dY, const double _dZ,
213  const double _Xp, const double _Yp, const double _Zp,
214  const double _Rx, const double _Ry, const double _Rz,
215  const double _dS ) :
216  dX(_dX), dY(_dY), dZ(_dZ), Xp(_Xp), Yp(_Yp), Zp(_Zp)
217  {
218  Rx = DEG2RAD(_Rx/60/60);
219  Ry = DEG2RAD(_Ry/60/60);
220  Rz = DEG2RAD(_Rz/60/60);
221  dS = _dS*1e-6;
222  }
223  };
224 
225  /** Parameters for a topographic transfomation
226  * \sa TDatumHelmert3D, transformHelmert2D
227  */
229  {
230  double dX, dY; //!< Deltas [X,Y]
231  double alpha; // The rotation about Z-axis (degrees)
232  double dS; // Scale factor (Scale is 1+dS)
233  double Xp, Yp; // Coordinates of the rotation point
234 
236  const double _dX, const double _dY,
237  const double _alpha, const double _dS,
238  const double _Xp, const double _Yp ) :
239  dX(_dX), dY(_dY), Xp(_Xp), Yp(_Yp)
240  {
241  alpha = DEG2RAD(_alpha);
242  dS = _dS*1e-6;
243  }
244  };
245 
247  {
248  double a,b,c,d;
249 
251  const double _a, const double _b,
252  const double _c, const double _d ) :
253  a(_a), b(_b), c(_c), d(_d) {}
254 
255  };
256 
257  /** Parameters for a topographic transfomation
258  * \sa TDatumHelmert2D, transformHelmert3D
259  */
261  {
262  double dX, dY, dZ; //!< Deltas (X,Y,Z)
263  double Rx, Ry, Rz; //!< Rotation components
264  double dS; //!< Scale factor (Scale is 1+dS)
265 
267  const double _dX, const double _dY, const double _dZ,
268  const double _Rx, const double _Ry, const double _Rz,
269  const double _dS ) :
270  dX(_dX), dY(_dY), dZ(_dZ)
271  {
272  Rx = DEG2RAD(_Rx/60/60);
273  Ry = DEG2RAD(_Ry/60/60);
274  Rz = DEG2RAD(_Rz/60/60);
275  dS = _dS*1e-6;
276  }
277  };
278 
279  /** Parameters for a topographic transfomation
280  * \sa TDatumHelmert2D, transformHelmert3D
281  */
283  {
284  double a,b,c,d,e,f,g;
285 
287  const double _a, const double _b, const double _c,
288  const double _d, const double _e, const double _f, const double _g ) :
289  a(_a), b(_b), c(_c), d(_d), e(_e), f(_f), g(_g) { }
290  };
291 
292  /** Parameters for a topographic transfomation
293  * \sa transform1D
294  */
296  {
297  double dX, dY, DZ; //!< Deltas (X,Y,Z)
298  double dS; //!< Scale factor (Scale is 1+dS)
299 
301  const double _dX, const double _dY, const double _DZ,
302  const double _dS ) :
303  dX(_dX), dY(_dY), DZ(_DZ)
304  {
305  dS = _dS*1e-6;
306  }
307  };
308 
309  /** Parameters for a topographic transfomation
310  * \sa transform1D
311  */
313  {
314  double dX, dY; //!< Deltas (X,Y,Z)
315  double dSx, dSy; //!< Scale factor in X and Y
316  double beta; //!< Distortion angle
317 
319  const double _dX, const double _dY,
320  const double _dSx, const double _dSy, const double _beta ) :
321  dX(_dX), dY(_dY)
322  {
323  dSx = _dSx*1e-6;
324  dSy = _dSy*1e-6;
325  beta = DEG2RAD(_beta/60/60);
326  }
327  };
328 
329  /** @} */
330 
331  /** @} */ // end of grouping
332 
333  } // End of namespace
334 
335 } // End of namespace
336 
337 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013