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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: c7a3bec24 Sun Mar 29 18:33:13 2020 +0200 at dom mar 29 18:50:38 CEST 2020