Main MRPT website > C++ reference for MRPT 1.9.9
data_types.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 data_types_H
10 #define data_types_H
11 
13 
14 namespace mrpt
15 {
16 namespace topography
17 {
18 /** \addtogroup mrpt_topography_grp
19  * @{ */
20 
21 /** @name Data structures
22  @{ */
23 
24 /** A coordinate that is stored as a simple "decimal" angle in degrees, but can
25  * be retrieved/set in the form of DEGREES + arc-MINUTES + arc-SECONDS.
26  */
27 struct TCoords
28 {
29  // Only keep one of the possible representations:
30  /** Also obtained directly through the double(void) operator using a TCoords
31  * anywhere were a double is expected. */
32  double decimal_value;
33 
34  inline TCoords(const int _deg, const int _min, const double _sec)
35  {
36  setDegMinSec(_deg, _min, _sec);
37  }
38  inline TCoords(const double dec) { setFromDecimal(dec); }
39  inline TCoords() { setFromDecimal(0); }
40  /** Automatic conversion to a double value (read-only) */
41  inline operator double(void) const { return decimal_value; }
42  /** Automatic conversion to a double value (read-only) */
43  inline operator double&(void) { return decimal_value; }
44  /** Set from a decimal value (XX.YYYYY) in degrees. */
45  inline void setFromDecimal(const double dec) { decimal_value = dec; }
46  /** Get the decimal value (XX.YYYYY), in degrees - you can also use the
47  * automatic conversion between TCoords and a double. */
48  inline double getDecimalValue() const { return decimal_value; }
49  /** Return the Deg Min' Sec'' representation of this value. */
50  inline void getDegMinSec(int& degrees, int& minutes, double& seconds) const
51  {
52  double aux = std::abs(decimal_value);
53  degrees = (int)aux;
54  minutes = (int)((aux - degrees) * 60.0f);
55  seconds = ((aux - degrees) * 60.0f - minutes) * 60.0f;
56  if (decimal_value < 0) degrees = -degrees;
57  }
58 
59  /** Set the coordinate from its Deg Min' Deg'' parts. */
60  inline void setDegMinSec(
61  const int degrees, const int minutes, const double seconds)
62  {
63  decimal_value = std::abs(degrees) + minutes / 60.0 + seconds / 3600.0;
64  if (degrees < 0) decimal_value = -decimal_value;
65  }
66 
67  /** Return a std::string in the format "DEGdeg MIN' SEC''" */
68  inline std::string getAsString() const
69  {
70  int deg, min;
71  double sec;
72  getDegMinSec(deg, min, sec);
73  return mrpt::format("%ddeg %d' %.04f''", deg, min, sec);
74  }
75 };
76 
77 bool operator==(const TCoords& a, const TCoords& o);
78 bool operator!=(const TCoords& a, const TCoords& o);
79 
80 std::ostream& operator<<(std::ostream& out, const TCoords& o);
81 
82 struct TEllipsoid
83 {
84  inline TEllipsoid() : sa(6378137.0), sb(6356752.314245), name("WGS84") {}
85  inline TEllipsoid(
86  const double _sa, const double _sb, const std::string& _name)
87  : sa(_sa), sb(_sb), name(_name)
88  {
89  }
90 
91  /** largest semiaxis of the reference ellipsoid (in meters) */
92  double sa;
93  /** smallest semiaxis of the reference ellipsoid (in meters) */
94  double sb;
95  /** the ellipsoid name */
97 
98  static inline TEllipsoid Ellipsoid_WGS84()
99  {
100  return TEllipsoid(6378137.000, 6356752.314245, "WGS84");
101  }
102  static inline TEllipsoid Ellipsoid_WGS72()
103  {
104  return TEllipsoid(6378135.000, 6356750.519915, "WGS72");
105  }
106  static inline TEllipsoid Ellipsoid_WGS66()
107  {
108  return TEllipsoid(6378145.000, 6356759.769356, "WGS66");
109  }
111  {
112  return TEllipsoid(6376896.000, 6355834.846700, "Walbeck_1817");
113  }
115  {
116  return TEllipsoid(6378160.000, 6356774.720000, "Sudamericano_1969");
117  }
119  {
120  return TEllipsoid(
121  6378157.500, 6356772.200000, "Nuevo_Internacional_1967");
122  }
124  {
125  return TEllipsoid(
126  6378150.000, 6356768.337303, "Mercury_Modificado_1968");
127  }
129  {
130  return TEllipsoid(6378166.000, 6356784.283666, "Mercury_1960");
131  }
133  {
134  return TEllipsoid(6378245.000, 6356863.018800, "Krasovsky_1940");
135  }
137  {
138  return TEllipsoid(6378388.000, 6356911.946130, "Internacional_1924");
139  }
141  {
142  return TEllipsoid(6378388.000, 6356911.946130, "Internacional_1909");
143  }
145  {
146  return TEllipsoid(6378270.000, 6356794.343479, "Hough_1960");
147  }
149  {
150  return TEllipsoid(6378200.000, 6356818.170000, "Helmert_1906");
151  }
153  {
154  return TEllipsoid(6378388.000, 6356911.946130, "Hayford_1909");
155  }
156  static inline TEllipsoid Ellipsoid_GRS80()
157  {
158  return TEllipsoid(6378137.000, 6356752.314140, "GRS80");
159  }
161  {
162  return TEllipsoid(6378150.000, 6356768.330000, "Fischer_1968");
163  }
165  {
166  return TEllipsoid(6378166.000, 6356784.280000, "Fischer_1960");
167  }
169  {
170  return TEllipsoid(6378249.145, 6356514.869550, "Clarke_1880");
171  }
173  {
174  return TEllipsoid(6378206.400, 6356583.800000, "Clarke_1866");
175  }
177  {
178  return TEllipsoid(6377397.155, 6356078.962840, "Bessel_1841");
179  }
181  {
182  return TEllipsoid(6377340.189, 6356034.447900, "Airy_Modificado_1965");
183  }
185  {
186  return TEllipsoid(6377563.396, 6356256.910000, "Airy_1830");
187  }
188 };
189 
192 
193 /** A set of geodetic coordinates: latitude, longitude and height, defined over
194  * a given geoid (typically, WGS84) */
196 {
197  TGeodeticCoords() : lat(0), lon(0), height(0) {}
198  TGeodeticCoords(const double _lat, const double _lon, const double _height)
199  : lat(_lat), lon(_lon), height(_height)
200  {
201  }
202 
203  inline bool isClear() const
204  {
205  return lat.getDecimalValue() == 0 && lon.getDecimalValue() == 0 &&
206  height == 0;
207  }
208 
209  /** Latitude (in degrees) */
211  /** Longitude (in degrees) */
213  /** Geodetic height (in meters) */
214  double height;
215 };
216 
217 bool operator==(const TGeodeticCoords& a, const TGeodeticCoords& o);
218 bool operator!=(const TGeodeticCoords& a, const TGeodeticCoords& o);
219 
220 /** Parameters for a topographic transfomation
221  * \sa TDatum10Params, transform7params
222  */
224 {
225  /** Deltas (X,Y,Z) */
226  double dX, dY, dZ;
227  /** Rotation components (in secs) */
228  double Rx, Ry, Rz;
229  /** Scale factor (in ppm) (Scale is 1+dS/1e6) */
230  double dS;
231 
233  const double _dX, const double _dY, const double _dZ, const double _Rx,
234  const double _Ry, const double _Rz, const double _dS)
235  : dX(_dX), dY(_dY), dZ(_dZ)
236  {
237  Rx = mrpt::DEG2RAD(_Rx / 60 / 60);
238  Ry = mrpt::DEG2RAD(_Ry / 60 / 60);
239  Rz = mrpt::DEG2RAD(_Rz / 60 / 60);
240  dS = _dS * 1e-6;
241  }
242 };
243 
245 {
246  /** Deltas (X,Y,Z) */
247  double dX, dY, dZ;
248  double m11, m12, m13, m21, m22, m23, m31, m32, m33;
249  /** Scale factor (in ppm) (Scale is 1+dS/1e6) */
250  double dS;
251 
253  const double _dX, const double _dY, const double _dZ, const double _m11,
254  const double _m12, const double _m13, const double _m21,
255  const double _m22, const double _m23, const double _m31,
256  const double _m32, const double _m33, const double _dS)
257  : dX(_dX),
258  dY(_dY),
259  dZ(_dZ),
260  m11(_m11),
261  m12(_m12),
262  m13(_m13),
263  m21(_m21),
264  m22(_m22),
265  m23(_m23),
266  m31(_m31),
267  m32(_m32),
268  m33(_m33)
269  {
270  dS = _dS * 1e-6;
271  }
272 };
273 
274 /** Parameters for a topographic transfomation
275  * \sa TDatum7Params, transform10params
276  */
278 {
279  /** Deltas (X,Y,Z) */
280  double dX, dY, dZ;
281  /** To be substracted to the input point */
282  double Xp, Yp, Zp;
283  /** Rotation components */
284  double Rx, Ry, Rz;
285  /** Scale factor (Scale is 1+dS) */
286  double dS;
287 
289  const double _dX, const double _dY, const double _dZ, const double _Xp,
290  const double _Yp, const double _Zp, const double _Rx, const double _Ry,
291  const double _Rz, const double _dS)
292  : dX(_dX), dY(_dY), dZ(_dZ), Xp(_Xp), Yp(_Yp), Zp(_Zp)
293  {
294  Rx = mrpt::DEG2RAD(_Rx / 60 / 60);
295  Ry = mrpt::DEG2RAD(_Ry / 60 / 60);
296  Rz = mrpt::DEG2RAD(_Rz / 60 / 60);
297  dS = _dS * 1e-6;
298  }
299 };
300 
301 /** Parameters for a topographic transfomation
302  * \sa TDatumHelmert3D, transformHelmert2D
303  */
305 {
306  /** Deltas [X,Y] */
307  double dX, dY;
308  double alpha; // The rotation about Z-axis (degrees)
309  double dS; // Scale factor (Scale is 1+dS)
310  double Xp, Yp; // Coordinates of the rotation point
311 
313  const double _dX, const double _dY, const double _alpha,
314  const double _dS, const double _Xp, const double _Yp)
315  : dX(_dX), dY(_dY), Xp(_Xp), Yp(_Yp)
316  {
317  alpha = mrpt::DEG2RAD(_alpha);
318  dS = _dS * 1e-6;
319  }
320 };
321 
323 {
324  double a, b, c, d;
325 
327  const double _a, const double _b, const double _c, const double _d)
328  : a(_a), b(_b), c(_c), d(_d)
329  {
330  }
331 };
332 
333 /** Parameters for a topographic transfomation
334  * \sa TDatumHelmert2D, transformHelmert3D
335  */
337 {
338  /** Deltas (X,Y,Z) */
339  double dX, dY, dZ;
340  /** Rotation components */
341  double Rx, Ry, Rz;
342  /** Scale factor (Scale is 1+dS) */
343  double dS;
344 
346  const double _dX, const double _dY, const double _dZ, const double _Rx,
347  const double _Ry, const double _Rz, const double _dS)
348  : dX(_dX), dY(_dY), dZ(_dZ)
349  {
350  Rx = mrpt::DEG2RAD(_Rx / 60 / 60);
351  Ry = mrpt::DEG2RAD(_Ry / 60 / 60);
352  Rz = mrpt::DEG2RAD(_Rz / 60 / 60);
353  dS = _dS * 1e-6;
354  }
355 };
356 
357 /** Parameters for a topographic transfomation
358  * \sa TDatumHelmert2D, transformHelmert3D
359  */
361 {
362  double a, b, c, d, e, f, g;
363 
365  const double _a, const double _b, const double _c, const double _d,
366  const double _e, const double _f, const double _g)
367  : a(_a), b(_b), c(_c), d(_d), e(_e), f(_f), g(_g)
368  {
369  }
370 };
371 
372 /** Parameters for a topographic transfomation
373  * \sa transform1D
374  */
376 {
377  /** Deltas (X,Y,Z) */
378  double dX, dY, DZ;
379  /** Scale factor (Scale is 1+dS) */
380  double dS;
381 
383  const double _dX, const double _dY, const double _DZ, const double _dS)
384  : dX(_dX), dY(_dY), DZ(_DZ)
385  {
386  dS = _dS * 1e-6;
387  }
388 };
389 
390 /** Parameters for a topographic transfomation
391  * \sa transform1D
392  */
394 {
395  /** Deltas (X,Y,Z) */
396  double dX, dY;
397  /** Scale factor in X and Y */
398  double dSx, dSy;
399  /** Distortion angle */
400  double beta;
401 
403  const double _dX, const double _dY, const double _dSx,
404  const double _dSy, const double _beta)
405  : dX(_dX), dY(_dY)
406  {
407  dSx = _dSx * 1e-6;
408  dSy = _dSy * 1e-6;
409  beta = mrpt::DEG2RAD(_beta / 60 / 60);
410  }
411 };
412 
413 /** @} */
414 
415 /** @} */ // end of grouping
416 
417 } // End of namespace
418 
419 } // End of namespace
420 
421 #endif
double sa
largest semiaxis of the reference ellipsoid (in meters)
Definition: data_types.h:92
GLclampf GLclampf GLclampf alpha
Definition: glext.h:3525
static TEllipsoid Ellipsoid_Fischer_1968()
Definition: data_types.h:160
double getDecimalValue() const
Get the decimal value (XX.YYYYY), in degrees - you can also use the automatic conversion between TCoo...
Definition: data_types.h:48
static TEllipsoid Ellipsoid_Fischer_1960()
Definition: data_types.h:164
double dX
Deltas (X,Y,Z)
Definition: data_types.h:226
double dX
Deltas (X,Y,Z)
Definition: data_types.h:280
static TEllipsoid Ellipsoid_Sudamericano_1969()
Definition: data_types.h:114
#define min(a, b)
static TEllipsoid Ellipsoid_Airy_1830()
Definition: data_types.h:184
TDatum1DTransf(const double _dX, const double _dY, const double _DZ, const double _dS)
Definition: data_types.h:382
double dS
Scale factor (in ppm) (Scale is 1+dS/1e6)
Definition: data_types.h:250
Parameters for a topographic transfomation.
Definition: data_types.h:336
TDatum7Params(const double _dX, const double _dY, const double _dZ, const double _Rx, const double _Ry, const double _Rz, const double _dS)
Definition: data_types.h:232
Parameters for a topographic transfomation.
Definition: data_types.h:304
double Rx
Rotation components.
Definition: data_types.h:284
double DEG2RAD(const double x)
Degrees to radians.
std::string name
the ellipsoid name
Definition: data_types.h:96
TDatumHelmert3D(const double _dX, const double _dY, const double _dZ, const double _Rx, const double _Ry, const double _Rz, const double _dS)
Definition: data_types.h:345
A set of geodetic coordinates: latitude, longitude and height, defined over a given geoid (typically...
Definition: data_types.h:195
double dS
Scale factor (in ppm) (Scale is 1+dS/1e6)
Definition: data_types.h:230
TEllipsoid(const double _sa, const double _sb, const std::string &_name)
Definition: data_types.h:85
bool operator!=(const TCoords &a, const TCoords &o)
Definition: conversions.cpp:27
bool operator==(const TCoords &a, const TCoords &o)
Definition: conversions.cpp:23
double dS
Scale factor (Scale is 1+dS)
Definition: data_types.h:380
static TEllipsoid Ellipsoid_Krasovsky_1940()
Definition: data_types.h:132
double Xp
To be substracted to the input point.
Definition: data_types.h:282
void getDegMinSec(int &degrees, int &minutes, double &seconds) const
Return the Deg Min&#39; Sec&#39;&#39; representation of this value.
Definition: data_types.h:50
double Rx
Rotation components.
Definition: data_types.h:341
void setFromDecimal(const double dec)
Set from a decimal value (XX.YYYYY) in degrees.
Definition: data_types.h:45
A coordinate that is stored as a simple "decimal" angle in degrees, but can be retrieved/set in the f...
Definition: data_types.h:27
double dSx
Scale factor in X and Y.
Definition: data_types.h:398
std::string getAsString() const
Return a std::string in the format "DEGdeg MIN&#39; SEC&#39;&#39;".
Definition: data_types.h:68
TDatumHelmert2D_TOPCON(const double _a, const double _b, const double _c, const double _d)
Definition: data_types.h:326
double Rx
Rotation components (in secs)
Definition: data_types.h:228
Parameters for a topographic transfomation.
Definition: data_types.h:360
static TEllipsoid Ellipsoid_WGS66()
Definition: data_types.h:106
double sb
smallest semiaxis of the reference ellipsoid (in meters)
Definition: data_types.h:94
Parameters for a topographic transfomation.
Definition: data_types.h:375
static TEllipsoid Ellipsoid_Nuevo_Internacional_1967()
Definition: data_types.h:118
TCoords lon
Longitude (in degrees)
Definition: data_types.h:212
static TEllipsoid Ellipsoid_Helmert_1906()
Definition: data_types.h:148
static TEllipsoid Ellipsoid_Internacional_1909()
Definition: data_types.h:140
const GLubyte * c
Definition: glext.h:6313
static TEllipsoid Ellipsoid_Mercury_1960()
Definition: data_types.h:128
static TEllipsoid Ellipsoid_Mercury_Modificado_1968()
Definition: data_types.h:123
static TEllipsoid Ellipsoid_WGS72()
Definition: data_types.h:102
GLubyte g
Definition: glext.h:6279
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Definition: format.cpp:16
GLubyte GLubyte b
Definition: glext.h:6279
double dS
Scale factor (Scale is 1+dS)
Definition: data_types.h:286
static TEllipsoid Ellipsoid_Hough_1960()
Definition: data_types.h:144
static TEllipsoid Ellipsoid_Walbeck_1817()
Definition: data_types.h:110
static TEllipsoid Ellipsoid_Clarke_1880()
Definition: data_types.h:168
static TEllipsoid Ellipsoid_GRS80()
Definition: data_types.h:156
GLsizei const GLchar ** string
Definition: glext.h:4101
double dS
Scale factor (Scale is 1+dS)
Definition: data_types.h:343
static TEllipsoid Ellipsoid_WGS84()
Definition: data_types.h:98
TCoords(const int _deg, const int _min, const double _sec)
Definition: data_types.h:34
TDatum10Params(const double _dX, const double _dY, const double _dZ, const double _Xp, const double _Yp, const double _Zp, const double _Rx, const double _Ry, const double _Rz, const double _dS)
Definition: data_types.h:288
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
TCoords(const double dec)
Definition: data_types.h:38
TGeodeticCoords(const double _lat, const double _lon, const double _height)
Definition: data_types.h:198
TDatumTransfInterpolation(const double _dX, const double _dY, const double _dSx, const double _dSy, const double _beta)
Definition: data_types.h:402
static TEllipsoid Ellipsoid_Hayford_1909()
Definition: data_types.h:152
Parameters for a topographic transfomation.
Definition: data_types.h:277
TDatum7Params_TOPCON(const double _dX, const double _dY, const double _dZ, const double _m11, const double _m12, const double _m13, const double _m21, const double _m22, const double _m23, const double _m31, const double _m32, const double _m33, const double _dS)
Definition: data_types.h:252
TDatumHelmert2D(const double _dX, const double _dY, const double _alpha, const double _dS, const double _Xp, const double _Yp)
Definition: data_types.h:312
std::ostream & operator<<(std::ostream &out, const TCoords &o)
Definition: conversions.cpp:52
double dX
Deltas (X,Y,Z)
Definition: data_types.h:339
void setDegMinSec(const int degrees, const int minutes, const double seconds)
Set the coordinate from its Deg Min&#39; Deg&#39;&#39; parts.
Definition: data_types.h:60
GLuint const GLchar * name
Definition: glext.h:4054
double height
Geodetic height (in meters)
Definition: data_types.h:214
static TEllipsoid Ellipsoid_Clarke_1866()
Definition: data_types.h:172
static TEllipsoid Ellipsoid_Bessel_1841()
Definition: data_types.h:176
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
TDatumHelmert3D_TOPCON(const double _a, const double _b, const double _c, const double _d, const double _e, const double _f, const double _g)
Definition: data_types.h:364
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
static TEllipsoid Ellipsoid_Internacional_1924()
Definition: data_types.h:136
GLenum GLsizei GLsizei height
Definition: glext.h:3554
Parameters for a topographic transfomation.
Definition: data_types.h:223
Parameters for a topographic transfomation.
Definition: data_types.h:393
GLubyte GLubyte GLubyte a
Definition: glext.h:6279
TCoords lat
Latitude (in degrees)
Definition: data_types.h:210
static TEllipsoid Ellipsoid_Airy_Modificado_1965()
Definition: data_types.h:180
double dX
Deltas (X,Y,Z)
Definition: data_types.h:378



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019