Helpers.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2014 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 
464  template<typename T>
465  inline T mean(const std::vector<T> &_values)
466  {
467  T sum = 0;
468  for (unsigned int i = 0; i < _values.size(); ++i)
469  sum += _values[i];
470  return sum / _values.size();
471  }
472 
476  template<typename T>
477  inline T variance(const std::vector<T> &_values)
478  {
479  T avg = mean<T>(_values);
480 
481  T sum = 0;
482  for (unsigned int i = 0; i < _values.size(); ++i)
483  sum += (_values[i] - avg) * (_values[i] - avg);
484  return sum / _values.size();
485  }
486 
490  template<typename T>
491  inline T max(const std::vector<T> &_values)
492  {
494  for (unsigned int i = 0; i < _values.size(); ++i)
495  if (_values[i] > max)
496  max = _values[i];
497  return max;
498  }
499 
503  template<typename T>
504  inline T min(const std::vector<T> &_values)
505  {
507  for (unsigned int i = 0; i < _values.size(); ++i)
508  if (_values[i] < min)
509  min = _values[i];
510  return min;
511  }
512 
517  template<typename T>
518  inline bool equal(const T &_a, const T &_b,
519  const T &_epsilon = 1e-6)
520  {
521  IGN_FP_VOLATILE T diff = std::abs(_a - _b);
522  return diff <= _epsilon;
523  }
524 
529  template<typename T>
530  inline bool lessOrNearEqual(const T &_a, const T &_b,
531  const T &_epsilon = 1e-6)
532  {
533  return _a < _b + _epsilon;
534  }
535 
540  template<typename T>
541  inline bool greaterOrNearEqual(const T &_a, const T &_b,
542  const T &_epsilon = 1e-6)
543  {
544  return _a > _b - _epsilon;
545  }
546 
551  template<typename T>
552  inline T precision(const T &_a, const unsigned int &_precision)
553  {
554  auto p = std::pow(10, _precision);
555  return static_cast<T>(std::round(_a * p) / p);
556  }
557 
561  template<typename T>
562  inline void sort2(T &_a, T &_b)
563  {
564  using std::swap;
565  if (_b < _a)
566  swap(_a, _b);
567  }
568 
573  template<typename T>
574  inline void sort3(T &_a, T &_b, T &_c)
575  {
576  // _a <= _b
577  sort2(_a, _b);
578  // _a <= _c, _b <= _c
579  sort2(_b, _c);
580  // _a <= _b <= _c
581  sort2(_a, _b);
582  }
583 
587  inline bool isPowerOfTwo(unsigned int _x)
588  {
589  return ((_x != 0) && ((_x & (~_x + 1)) == _x));
590  }
591 
597  inline unsigned int roundUpPowerOfTwo(unsigned int _x)
598  {
599  if (_x == 0)
600  return 1;
601 
602  if (isPowerOfTwo(_x))
603  return _x;
604 
605  while (_x & (_x - 1))
606  _x = _x & (_x - 1);
607 
608  _x = _x << 1;
609 
610  return _x;
611  }
612 
616  inline int parseInt(const std::string &_input)
617  {
618  const char *p = _input.c_str();
619  if (!*p || *p == '?')
620  return NAN_I;
621 
622  int s = 1;
623  while (*p == ' ')
624  p++;
625 
626  if (*p == '-')
627  {
628  s = -1;
629  p++;
630  }
631 
632  int acc = 0;
633  while (*p >= '0' && *p <= '9')
634  acc = acc * 10 + *p++ - '0';
635 
636  if (*p)
637  {
638  std::cerr << "Invalid int numeric format[" << _input << "]\n";
639  return NAN_I;
640  }
641 
642  return s * acc;
643  }
644 
649  inline double parseFloat(const std::string &_input)
650  {
651  const char *p = _input.c_str();
652  if (!*p || *p == '?')
653  return NAN_D;
654  int s = 1;
655  while (*p == ' ')
656  p++;
657 
658  if (*p == '-')
659  {
660  s = -1;
661  p++;
662  }
663 
664  double acc = 0;
665  while (*p >= '0' && *p <= '9')
666  acc = acc * 10 + *p++ - '0';
667 
668  if (*p == '.')
669  {
670  double k = 0.1;
671  p++;
672  while (*p >= '0' && *p <= '9')
673  {
674  acc += (*p++ - '0') * k;
675  k *= 0.1;
676  }
677  }
678  if (*p == 'e')
679  {
680  int es = 1;
681  int f = 0;
682  p++;
683  if (*p == '-')
684  {
685  es = -1;
686  p++;
687  }
688  else if (*p == '+')
689  {
690  es = 1;
691  p++;
692  }
693  while (*p >= '0' && *p <= '9')
694  f = f * 10 + *p++ - '0';
695 
696  acc *= pow(10, f*es);
697  }
698 
699  if (*p)
700  {
701  std::cerr << "Invalid double numeric format[" << _input << "]\n";
702  return NAN_D;
703  }
704  return s * acc;
705  }
706 
707 
708  // Degrade precision on Windows, which cannot handle 'long double'
709  // values properly. See the implementation of Unpair.
710  // 32 bit ARM processors also define 'long double' to be the same
711  // size as 'double', and must also be degraded
712 #if defined _MSC_VER || defined __arm__
713  using PairInput = uint16_t;
714  using PairOutput = uint32_t;
715 #else
716  using PairInput = uint32_t;
717  using PairOutput = uint64_t;
718 #endif
719 
729  PairOutput IGNITION_VISIBLE Pair(const PairInput _a, const PairInput _b);
730 
742  std::tuple<PairInput, PairInput> IGNITION_VISIBLE Unpair(
743  const PairOutput _key);
744  }
745 }
746 
747 #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:552
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:465
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:597
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:491
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:717
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:541
T variance(const std::vector< T > &_values)
get variance of vector of values
Definition: Helpers.hh:477
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:587
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:716
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
static const int16_t MAX_I16
16bit unsigned integer maximum value
Definition: Helpers.hh:286
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:649
void sort2(T &_a, T &_b)
Sort two numbers, such that _a <= _b.
Definition: Helpers.hh:562
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
bool equal(const T &_a, const T &_b, const T &_epsilon=1e-6)
check if two values are equal, within a tolerance
Definition: Helpers.hh:518
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:616
bool lessOrNearEqual(const T &_a, const T &_b, const T &_epsilon=1e-6)
inequality test, within a tolerance
Definition: Helpers.hh:530
T min(const std::vector< T > &_values)
get the minimum value of vector of values
Definition: Helpers.hh:504
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:574
static const int16_t LOW_I16
16bit unsigned integer lowest value.
Definition: Helpers.hh:293