Helpers.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef IGNITION_MATH_FUNCTIONS_HH_
18 #define IGNITION_MATH_FUNCTIONS_HH_
19 
20 #include <cmath>
21 #include <algorithm>
22 #include <limits>
23 #include <string>
24 #include <iostream>
25 #include <vector>
26 #include <tuple>
27 #include <cstdint>
28 
29 #include <ignition/math/System.hh>
30 
33 #define IGN_DBL_MAX ignition::math::DPRCT_MAX_D
34 
37 #define IGN_DBL_MIN ignition::math::DPRCT_MIN_D
38 
41 #define IGN_DBL_LOW ignition::math::DPRCT_LOW_D
42 
45 #define IGN_DBL_INF ignition::math::DPRCT_INF_D
46 
49 #define IGN_FLT_MAX ignition::math::DPRCT_MAX_F
50 
53 #define IGN_FLT_MIN ignition::math::DPRCT_MIN_F
54 
57 #define IGN_FLT_LOW ignition::math::DPRCT_LOW_F
58 
61 #define IGN_FLT_INF ignition::math::DPRCT_INF_F
62 
65 #define IGN_UINT16_MAX ignition::math::DPRCT_MAX_UI16
66 
69 #define IGN_UINT16_MIN ignition::math::DPRCT_MIN_UI16
70 
74 #define IGN_UINT16_LOW ignition::math::DPRCT_LOW_UI16
75 
78 #define IGN_UINT16_INF ignition::math::DPRCT_INF_UI16
79 
82 #define IGN_INT16_MAX ignition::math::DPRCT_MAX_I16
83 
86 #define IGN_INT16_MIN ignition::math::DPRCT_MIN_I16
87 
91 #define IGN_INT16_LOW ignition::math::DPRCT_LOW_I16
92 
95 #define IGN_INT16_INF ignition::math::DPRCT_INF_I16
96 
99 #define IGN_UINT32_MAX ignition::math::DPRCT_MAX_UI32
100 
103 #define IGN_UINT32_MIN ignition::math::DPRCT_MIN_UI32
104 
108 #define IGN_UINT32_LOW ignition::math::DPRCT_LOW_UI32
109 
112 #define IGN_UINT32_INF ignition::math::DPRCT_INF_UI32
113 
116 #define IGN_INT32_MAX ignition::math::DPRCT_MAX_I32
117 
120 #define IGN_INT32_MIN ignition::math::DPRCT_MIN_I32
121 
125 #define IGN_INT32_LOW ignition::math::DPRCT_LOW_I32
126 
129 #define IGN_INT32_INF ignition::math::DPRCT_INF_I32
130 
133 #define IGN_UINT64_MAX ignition::math::DPRCT_MAX_UI64
134 
137 #define IGN_UINT64_MIN ignition::math::DPRCT_MIN_UI64
138 
142 #define IGN_UINT64_LOW ignition::math::DPRCT_LOW_UI64
143 
146 #define IGN_UINT64_INF ignition::math::DPRCT_INF_UI64
147 
150 #define IGN_INT64_MAX ignition::math::DPRCT_MAX_I64
151 
154 #define IGN_INT64_MIN ignition::math::DPRCT_MIN_I64
155 
159 #define IGN_INT64_LOW ignition::math::DPRCT_LOW_I64
160 
163 #define IGN_INT64_INF ignition::math::DPRCT_INF_I64
164 
167 #ifdef M_PI
168 #define IGN_PI M_PI
169 #define IGN_PI_2 M_PI_2
170 #define IGN_PI_4 M_PI_4
171 #define IGN_SQRT2 M_SQRT2
172 #else
173 #define IGN_PI 3.14159265358979323846
174 #define IGN_PI_2 1.57079632679489661923
175 #define IGN_PI_4 0.78539816339744830962
176 #define IGN_SQRT2 1.41421356237309504880
177 #endif
178 
182 #if defined __FLT_EVAL_METHOD__ && __FLT_EVAL_METHOD__ == 2
183 #define IGN_FP_VOLATILE volatile
184 #else
185 #define IGN_FP_VOLATILE
186 #endif
187 
190 #define IGN_SPHERE_VOLUME(_radius) (4.0*IGN_PI*std::pow(_radius, 3)/3.0)
191 
195 #define IGN_CYLINDER_VOLUME(_r, _l) (_l * IGN_PI * std::pow(_r, 2))
196 
201 #define IGN_BOX_VOLUME(_x, _y, _z) (_x *_y * _z)
202 
205 #define IGN_BOX_VOLUME_V(_v) (_v.X() *_v.Y() * _v.Z())
206 
207 namespace ignition
208 {
210  namespace math
211  {
213  static const size_t IGN_ZERO_SIZE_T = 0u;
214 
216  static const size_t IGN_ONE_SIZE_T = 1u;
217 
219  static const size_t IGN_TWO_SIZE_T = 2u;
220 
222  static const size_t IGN_THREE_SIZE_T = 3u;
223 
225  static const size_t IGN_FOUR_SIZE_T = 4u;
226 
228  static const size_t IGN_FIVE_SIZE_T = 5u;
229 
231  static const size_t IGN_SIX_SIZE_T = 6u;
232 
234  static const size_t IGN_SEVEN_SIZE_T = 7u;
235 
237  static const size_t IGN_EIGHT_SIZE_T = 8u;
238 
240  static const size_t IGN_NINE_SIZE_T = 9u;
241 
243  static const double MAX_D = std::numeric_limits<double>::max();
244 
246  static const double MIN_D = std::numeric_limits<double>::min();
247 
249  static const double LOW_D = std::numeric_limits<double>::lowest();
250 
252  static const double INF_D = std::numeric_limits<double>::infinity();
253 
255  static const double NAN_D = std::numeric_limits<double>::quiet_NaN();
256 
258  static const float MAX_F = std::numeric_limits<float>::max();
259 
261  static const float MIN_F = std::numeric_limits<float>::min();
262 
264  static const float LOW_F = std::numeric_limits<float>::lowest();
265 
267  static const float INF_F = std::numeric_limits<float>::infinity();
268 
270  static const float NAN_F = std::numeric_limits<float>::quiet_NaN();
271 
273  static const uint16_t MAX_UI16 = std::numeric_limits<uint16_t>::max();
274 
276  static const uint16_t MIN_UI16 = std::numeric_limits<uint16_t>::min();
277 
280  static const uint16_t LOW_UI16 = std::numeric_limits<uint16_t>::lowest();
281 
283  static const uint16_t INF_UI16 = std::numeric_limits<uint16_t>::infinity();
284 
286  static const int16_t MAX_I16 = std::numeric_limits<int16_t>::max();
287 
289  static const int16_t MIN_I16 = std::numeric_limits<int16_t>::min();
290 
293  static const int16_t LOW_I16 = std::numeric_limits<int16_t>::lowest();
294 
296  static const int16_t INF_I16 = std::numeric_limits<int16_t>::infinity();
297 
299  static const uint32_t MAX_UI32 = std::numeric_limits<uint32_t>::max();
300 
302  static const uint32_t MIN_UI32 = std::numeric_limits<uint32_t>::min();
303 
306  static const uint32_t LOW_UI32 = std::numeric_limits<uint32_t>::lowest();
307 
309  static const uint32_t INF_UI32 = std::numeric_limits<uint32_t>::infinity();
310 
312  static const int32_t MAX_I32 = std::numeric_limits<int32_t>::max();
313 
315  static const int32_t MIN_I32 = std::numeric_limits<int32_t>::min();
316 
319  static const int32_t LOW_I32 = std::numeric_limits<int32_t>::lowest();
320 
322  static const int32_t INF_I32 = std::numeric_limits<int32_t>::infinity();
323 
325  static const uint64_t MAX_UI64 = std::numeric_limits<uint64_t>::max();
326 
328  static const uint64_t MIN_UI64 = std::numeric_limits<uint64_t>::min();
329 
332  static const uint64_t LOW_UI64 = std::numeric_limits<uint64_t>::lowest();
333 
335  static const uint64_t INF_UI64 = std::numeric_limits<uint64_t>::infinity();
336 
338  static const int64_t MAX_I64 = std::numeric_limits<int64_t>::max();
339 
341  static const int64_t MIN_I64 = std::numeric_limits<int64_t>::min();
342 
345  static const int64_t LOW_I64 = std::numeric_limits<int64_t>::lowest();
346 
348  static const int64_t INF_I64 = std::numeric_limits<int64_t>::infinity();
349 
351  static const int NAN_I = std::numeric_limits<int>::quiet_NaN();
352 
353  // variables created to deprecate macros in this file
354  static const double IGN_DEPRECATED(2) DPRCT_MAX_D = MAX_D;
355  static const double IGN_DEPRECATED(2) DPRCT_MIN_D = MIN_D;
356  static const double IGN_DEPRECATED(2) DPRCT_LOW_D = LOW_D;
357  static const double IGN_DEPRECATED(2) DPRCT_INF_D = INF_D;
358  static const float IGN_DEPRECATED(2) DPRCT_MAX_F = MAX_F;
359  static const float IGN_DEPRECATED(2) DPRCT_MIN_F = MIN_F;
360  static const float IGN_DEPRECATED(2) DPRCT_LOW_F = LOW_F;
361  static const float IGN_DEPRECATED(2) DPRCT_INF_F = INF_F;
362  static const uint16_t IGN_DEPRECATED(2) DPRCT_MAX_UI16 = MAX_UI16;
363  static const uint16_t IGN_DEPRECATED(2) DPRCT_MIN_UI16 = MIN_UI16;
364  static const uint16_t IGN_DEPRECATED(2) DPRCT_LOW_UI16 = LOW_UI16;
365  static const uint16_t IGN_DEPRECATED(2) DPRCT_INF_UI16 = INF_UI16;
366  static const int16_t IGN_DEPRECATED(2) DPRCT_MAX_I16 = MAX_I16;
367  static const int16_t IGN_DEPRECATED(2) DPRCT_MIN_I16 = MIN_I16;
368  static const int16_t IGN_DEPRECATED(2) DPRCT_LOW_I16 = LOW_I16;
369  static const int16_t IGN_DEPRECATED(2) DPRCT_INF_I16 = INF_I16;
370  static const uint32_t IGN_DEPRECATED(2) DPRCT_MAX_UI32 = MAX_UI32;
371  static const uint32_t IGN_DEPRECATED(2) DPRCT_MIN_UI32 = MIN_UI32;
372  static const uint32_t IGN_DEPRECATED(2) DPRCT_LOW_UI32 = LOW_UI32;
373  static const uint32_t IGN_DEPRECATED(2) DPRCT_INF_UI32 = INF_UI32;
374  static const int32_t IGN_DEPRECATED(2) DPRCT_MAX_I32 = MAX_I32;
375  static const int32_t IGN_DEPRECATED(2) DPRCT_MIN_I32 = MIN_I32;
376  static const int32_t IGN_DEPRECATED(2) DPRCT_LOW_I32 = LOW_I32;
377  static const int32_t IGN_DEPRECATED(2) DPRCT_INF_I32 = INF_I32;
378  static const uint64_t IGN_DEPRECATED(2) DPRCT_MAX_UI64 = MAX_UI64;
379  static const uint64_t IGN_DEPRECATED(2) DPRCT_MIN_UI64 = MIN_UI64;
380  static const uint64_t IGN_DEPRECATED(2) DPRCT_LOW_UI64 = LOW_UI64;
381  static const uint64_t IGN_DEPRECATED(2) DPRCT_INF_UI64 = INF_UI64;
382  static const int64_t IGN_DEPRECATED(2) DPRCT_MAX_I64 = MAX_I64;
383  static const int64_t IGN_DEPRECATED(2) DPRCT_MIN_I64 = MIN_I64;
384  static const int64_t IGN_DEPRECATED(2) DPRCT_LOW_I64 = LOW_I64;
385  static const int64_t IGN_DEPRECATED(2) DPRCT_INF_I64 = INF_I64;
386 
391  template<typename T>
392  inline T clamp(T _v, T _min, T _max)
393  {
394  return std::max(std::min(_v, _max), _min);
395  }
396 
400  inline bool isnan(float _v)
401  {
402  return (std::isnan)(_v);
403  }
404 
408  inline bool isnan(double _v)
409  {
410  return (std::isnan)(_v);
411  }
412 
416  inline float fixnan(float _v)
417  {
418  return isnan(_v) || std::isinf(_v) ? 0.0f : _v;
419  }
420 
424  inline double fixnan(double _v)
425  {
426  return isnan(_v) || std::isinf(_v) ? 0.0 : _v;
427  }
428 
432  inline bool isEven(const int _v)
433  {
434  return !(_v % 2);
435  }
436 
440  inline bool isEven(const unsigned int _v)
441  {
442  return !(_v % 2);
443  }
444 
448  inline bool isOdd(const int _v)
449  {
450  return (_v % 2) != 0;
451  }
452 
456  inline bool isOdd(const unsigned int _v)
457  {
458  return (_v % 2) != 0;
459  }
460 
467  template<typename T>
468  inline int sgn(T _value)
469  {
470  return (T(0) < _value) - (_value < T(0));
471  }
472 
479  template<typename T>
480  inline int signum(T _value)
481  {
482  return sgn(_value);
483  }
484 
488  template<typename T>
489  inline T mean(const std::vector<T> &_values)
490  {
491  T sum = 0;
492  for (unsigned int i = 0; i < _values.size(); ++i)
493  sum += _values[i];
494  return sum / _values.size();
495  }
496 
500  template<typename T>
501  inline T variance(const std::vector<T> &_values)
502  {
503  T avg = mean<T>(_values);
504 
505  T sum = 0;
506  for (unsigned int i = 0; i < _values.size(); ++i)
507  sum += (_values[i] - avg) * (_values[i] - avg);
508  return sum / _values.size();
509  }
510 
514  template<typename T>
515  inline T max(const std::vector<T> &_values)
516  {
518  for (unsigned int i = 0; i < _values.size(); ++i)
519  if (_values[i] > max)
520  max = _values[i];
521  return max;
522  }
523 
527  template<typename T>
528  inline T min(const std::vector<T> &_values)
529  {
531  for (unsigned int i = 0; i < _values.size(); ++i)
532  if (_values[i] < min)
533  min = _values[i];
534  return min;
535  }
536 
541  template<typename T>
542  inline bool equal(const T &_a, const T &_b,
543  const T &_epsilon = T(1e-6))
544  {
545  IGN_FP_VOLATILE T diff = std::abs(_a - _b);
546  return diff <= _epsilon;
547  }
548 
553  template<typename T>
554  inline bool lessOrNearEqual(const T &_a, const T &_b,
555  const T &_epsilon = 1e-6)
556  {
557  return _a < _b + _epsilon;
558  }
559 
564  template<typename T>
565  inline bool greaterOrNearEqual(const T &_a, const T &_b,
566  const T &_epsilon = 1e-6)
567  {
568  return _a > _b - _epsilon;
569  }
570 
575  template<typename T>
576  inline T precision(const T &_a, const unsigned int &_precision)
577  {
578  auto p = std::pow(10, _precision);
579  return static_cast<T>(std::round(_a * p) / p);
580  }
581 
585  template<typename T>
586  inline void sort2(T &_a, T &_b)
587  {
588  using std::swap;
589  if (_b < _a)
590  swap(_a, _b);
591  }
592 
597  template<typename T>
598  inline void sort3(T &_a, T &_b, T &_c)
599  {
600  // _a <= _b
601  sort2(_a, _b);
602  // _a <= _c, _b <= _c
603  sort2(_b, _c);
604  // _a <= _b <= _c
605  sort2(_a, _b);
606  }
607 
611  inline bool isPowerOfTwo(unsigned int _x)
612  {
613  return ((_x != 0) && ((_x & (~_x + 1)) == _x));
614  }
615 
621  inline unsigned int roundUpPowerOfTwo(unsigned int _x)
622  {
623  if (_x == 0)
624  return 1;
625 
626  if (isPowerOfTwo(_x))
627  return _x;
628 
629  while (_x & (_x - 1))
630  _x = _x & (_x - 1);
631 
632  _x = _x << 1;
633 
634  return _x;
635  }
636 
640  inline int parseInt(const std::string &_input)
641  {
642  const char *p = _input.c_str();
643  if (!*p || *p == '?')
644  return NAN_I;
645 
646  int s = 1;
647  while (*p == ' ')
648  p++;
649 
650  if (*p == '-')
651  {
652  s = -1;
653  p++;
654  }
655 
656  int acc = 0;
657  while (*p >= '0' && *p <= '9')
658  acc = acc * 10 + *p++ - '0';
659 
660  if (*p)
661  {
662  std::cerr << "Invalid int numeric format[" << _input << "]\n";
663  return NAN_I;
664  }
665 
666  return s * acc;
667  }
668 
673  inline double parseFloat(const std::string &_input)
674  {
675  const char *p = _input.c_str();
676  if (!*p || *p == '?')
677  return NAN_D;
678  int s = 1;
679  while (*p == ' ')
680  p++;
681 
682  if (*p == '-')
683  {
684  s = -1;
685  p++;
686  }
687 
688  double acc = 0;
689  while (*p >= '0' && *p <= '9')
690  acc = acc * 10 + *p++ - '0';
691 
692  if (*p == '.')
693  {
694  double k = 0.1;
695  p++;
696  while (*p >= '0' && *p <= '9')
697  {
698  acc += (*p++ - '0') * k;
699  k *= 0.1;
700  }
701  }
702  if (*p == 'e')
703  {
704  int es = 1;
705  int f = 0;
706  p++;
707  if (*p == '-')
708  {
709  es = -1;
710  p++;
711  }
712  else if (*p == '+')
713  {
714  es = 1;
715  p++;
716  }
717  while (*p >= '0' && *p <= '9')
718  f = f * 10 + *p++ - '0';
719 
720  acc *= pow(10, f*es);
721  }
722 
723  if (*p)
724  {
725  std::cerr << "Invalid double numeric format[" << _input << "]\n";
726  return NAN_D;
727  }
728  return s * acc;
729  }
730 
731 
732  // Degrade precision on Windows, which cannot handle 'long double'
733  // values properly. See the implementation of Unpair.
734  // 32 bit ARM processors also define 'long double' to be the same
735  // size as 'double', and must also be degraded
736 #if defined _MSC_VER || defined __arm__
737  using PairInput = uint16_t;
738  using PairOutput = uint32_t;
739 #else
740  using PairInput = uint32_t;
741  using PairOutput = uint64_t;
742 #endif
743 
753  PairOutput IGNITION_VISIBLE Pair(const PairInput _a, const PairInput _b);
754 
766  std::tuple<PairInput, PairInput> IGNITION_VISIBLE Unpair(
767  const PairOutput _key);
768  }
769 }
770 
771 #endif
static const float NAN_F
Returns the representation of a quiet not a number (NAN)
Definition: Helpers.hh:270
static const size_t IGN_ONE_SIZE_T
size_t type with a value of 1
Definition: Helpers.hh:216
std::tuple< PairInput, PairInput > IGNITION_VISIBLE Unpair(const PairOutput _key)
The reverse of the Pair function.
static const uint16_t MAX_UI16
16bit unsigned integer maximum value
Definition: Helpers.hh:273
static const size_t IGN_SIX_SIZE_T
size_t type with a value of 6
Definition: Helpers.hh:231
static const uint16_t MIN_UI16
16bit unsigned integer minimum value
Definition: Helpers.hh:276
static const double NAN_D
Returns the representation of a quiet not a number (NAN)
Definition: Helpers.hh:255
T precision(const T &_a, const unsigned int &_precision)
get value at a specified precision
Definition: Helpers.hh:576
static const uint16_t INF_UI16
16-bit unsigned integer positive infinite value
Definition: Helpers.hh:283
T mean(const std::vector< T > &_values)
get mean of vector of values
Definition: Helpers.hh:489
static const size_t IGN_THREE_SIZE_T
size_t type with a value of 3
Definition: Helpers.hh:222
static const int32_t INF_I32
32-bit unsigned integer positive infinite value
Definition: Helpers.hh:322
static const size_t IGN_ZERO_SIZE_T
size_t type with a value of 0
Definition: Helpers.hh:213
bool isnan(float _v)
check if a float is NaN
Definition: Helpers.hh:400
static const uint32_t MIN_UI32
32bit unsigned integer minimum value
Definition: Helpers.hh:302
unsigned int roundUpPowerOfTwo(unsigned int _x)
Get the smallest power of two that is greater or equal to a given value.
Definition: Helpers.hh:621
static const size_t IGN_EIGHT_SIZE_T
size_t type with a value of 8
Definition: Helpers.hh:237
T max(const std::vector< T > &_values)
get the maximum value of vector of values
Definition: Helpers.hh:515
static const double MAX_D
Double maximum value. This value will be similar to 1.79769e+308.
Definition: Helpers.hh:243
uint64_t PairOutput
Definition: Helpers.hh:741
bool equal(const T &_a, const T &_b, const T &_epsilon=T(1e-6))
check if two values are equal, within a tolerance
Definition: Helpers.hh:542
static const int32_t MIN_I32
32bit unsigned integer minimum value
Definition: Helpers.hh:315
static const double INF_D
Double positive infinite value.
Definition: Helpers.hh:252
static const int16_t INF_I16
16-bit unsigned integer positive infinite value
Definition: Helpers.hh:296
static const int32_t LOW_I32
32bit unsigned integer lowest value.
Definition: Helpers.hh:319
bool isOdd(const int _v)
Check if parameter is odd.
Definition: Helpers.hh:448
static const uint32_t INF_UI32
32-bit unsigned integer positive infinite value
Definition: Helpers.hh:309
static const uint16_t LOW_UI16
16bit unsigned integer lowest value.
Definition: Helpers.hh:280
static const size_t IGN_NINE_SIZE_T
size_t type with a value of 9
Definition: Helpers.hh:240
bool greaterOrNearEqual(const T &_a, const T &_b, const T &_epsilon=1e-6)
inequality test, within a tolerance
Definition: Helpers.hh:565
T variance(const std::vector< T > &_values)
get variance of vector of values
Definition: Helpers.hh:501
static const int16_t MIN_I16
16bit unsigned integer minimum value
Definition: Helpers.hh:289
static const double MIN_D
Double min value. This value will be similar to 2.22507e-308.
Definition: Helpers.hh:246
static const float MIN_F
Float minimum value. This value will be similar to 1.17549e-38.
Definition: Helpers.hh:261
static const int32_t MAX_I32
32bit unsigned integer maximum value
Definition: Helpers.hh:312
#define IGN_FP_VOLATILE
Define IGN_FP_VOLATILE for FP equality comparisons Use volatile parameters when checking floating poi...
Definition: Helpers.hh:185
static const uint64_t LOW_UI64
64bit unsigned integer lowest value.
Definition: Helpers.hh:332
#define IGNITION_VISIBLE
Use to represent "symbol visible" if supported.
Definition: System.hh:59
bool isPowerOfTwo(unsigned int _x)
Is this a power of 2?
Definition: Helpers.hh:611
static const float LOW_F
Float low value, equivalent to -MAX_F.
Definition: Helpers.hh:264
static const uint32_t MAX_UI32
32bit unsigned integer maximum value
Definition: Helpers.hh:299
uint32_t PairInput
Definition: Helpers.hh:740
static const float MAX_F
Float maximum value. This value will be similar to 3.40282e+38.
Definition: Helpers.hh:258
static const size_t IGN_TWO_SIZE_T
size_t type with a value of 2
Definition: Helpers.hh:219
int sgn(T _value)
The signum function.
Definition: Helpers.hh:468
static const int16_t MAX_I16
16bit unsigned integer maximum value
Definition: Helpers.hh:286
int signum(T _value)
The signum function.
Definition: Helpers.hh:480
static const double IGN_DEPRECATED(2) DPRCT_MAX_D
PairOutput IGNITION_VISIBLE Pair(const PairInput _a, const PairInput _b)
A pairing function that maps two values to a unique third value.
bool isEven(const int _v)
Check if parameter is even.
Definition: Helpers.hh:432
static const int NAN_I
Returns the representation of a quiet not a number (NAN)
Definition: Helpers.hh:351
static const float INF_F
float positive infinite value
Definition: Helpers.hh:267
static const uint64_t INF_UI64
64-bit unsigned integer positive infinite value
Definition: Helpers.hh:335
static const size_t IGN_FOUR_SIZE_T
size_t type with a value of 4
Definition: Helpers.hh:225
static const int64_t INF_I64
64-bit unsigned integer positive infinite value
Definition: Helpers.hh:348
static const int64_t MAX_I64
64bit unsigned integer maximum value
Definition: Helpers.hh:338
double parseFloat(const std::string &_input)
parse string into float
Definition: Helpers.hh:673
void sort2(T &_a, T &_b)
Sort two numbers, such that _a <= _b.
Definition: Helpers.hh:586
static const uint64_t MIN_UI64
64bit unsigned integer minimum value
Definition: Helpers.hh:328
static const size_t IGN_FIVE_SIZE_T
size_t type with a value of 5
Definition: Helpers.hh:228
Definition: Angle.hh:38
float fixnan(float _v)
Fix a nan value.
Definition: Helpers.hh:416
static const double LOW_D
Double low value, equivalent to -MAX_D.
Definition: Helpers.hh:249
static const uint64_t MAX_UI64
64bit unsigned integer maximum value
Definition: Helpers.hh:325
static const int64_t LOW_I64
64bit unsigned integer lowest value.
Definition: Helpers.hh:345
static const int64_t MIN_I64
64bit unsigned integer minimum value
Definition: Helpers.hh:341
int parseInt(const std::string &_input)
parse string into an integer
Definition: Helpers.hh:640
bool lessOrNearEqual(const T &_a, const T &_b, const T &_epsilon=1e-6)
inequality test, within a tolerance
Definition: Helpers.hh:554
T min(const std::vector< T > &_values)
get the minimum value of vector of values
Definition: Helpers.hh:528
T clamp(T _v, T _min, T _max)
Simple clamping function.
Definition: Helpers.hh:392
bool isnan(double _v)
check if a double is NaN
Definition: Helpers.hh:408
static const uint32_t LOW_UI32
32bit unsigned integer lowest value.
Definition: Helpers.hh:306
static const size_t IGN_SEVEN_SIZE_T
size_t type with a value of 7
Definition: Helpers.hh:234
void sort3(T &_a, T &_b, T &_c)
Sort three numbers, such that _a <= _b <= _c.
Definition: Helpers.hh:598
static const int16_t LOW_I16
16bit unsigned integer lowest value.
Definition: Helpers.hh:293