Ignition Math

API Reference

5.1.0
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 <utility>
28 #include <cstdint>
29 
30 #include <ignition/math/config.hh>
31 #include "ignition/math/Export.hh"
32 
35 template <typename T>
37 
40 #define IGN_DBL_MAX ignition::math::DPRCT_MAX_D
41 
44 #define IGN_DBL_MIN ignition::math::DPRCT_MIN_D
45 
48 #define IGN_DBL_LOW ignition::math::DPRCT_LOW_D
49 
52 #define IGN_DBL_INF ignition::math::DPRCT_INF_D
53 
56 #define IGN_FLT_MAX ignition::math::DPRCT_MAX_F
57 
60 #define IGN_FLT_MIN ignition::math::DPRCT_MIN_F
61 
64 #define IGN_FLT_LOW ignition::math::DPRCT_LOW_F
65 
68 #define IGN_FLT_INF ignition::math::DPRCT_INF_F
69 
72 #define IGN_UINT16_MAX ignition::math::DPRCT_MAX_UI16
73 
76 #define IGN_UINT16_MIN ignition::math::DPRCT_MIN_UI16
77 
81 #define IGN_UINT16_LOW ignition::math::DPRCT_LOW_UI16
82 
85 #define IGN_UINT16_INF ignition::math::DPRCT_INF_UI16
86 
89 #define IGN_INT16_MAX ignition::math::DPRCT_MAX_I16
90 
93 #define IGN_INT16_MIN ignition::math::DPRCT_MIN_I16
94 
98 #define IGN_INT16_LOW ignition::math::DPRCT_LOW_I16
99 
102 #define IGN_INT16_INF ignition::math::DPRCT_INF_I16
103 
106 #define IGN_UINT32_MAX ignition::math::DPRCT_MAX_UI32
107 
110 #define IGN_UINT32_MIN ignition::math::DPRCT_MIN_UI32
111 
115 #define IGN_UINT32_LOW ignition::math::DPRCT_LOW_UI32
116 
119 #define IGN_UINT32_INF ignition::math::DPRCT_INF_UI32
120 
123 #define IGN_INT32_MAX ignition::math::DPRCT_MAX_I32
124 
127 #define IGN_INT32_MIN ignition::math::DPRCT_MIN_I32
128 
132 #define IGN_INT32_LOW ignition::math::DPRCT_LOW_I32
133 
136 #define IGN_INT32_INF ignition::math::DPRCT_INF_I32
137 
140 #define IGN_UINT64_MAX ignition::math::DPRCT_MAX_UI64
141 
144 #define IGN_UINT64_MIN ignition::math::DPRCT_MIN_UI64
145 
149 #define IGN_UINT64_LOW ignition::math::DPRCT_LOW_UI64
150 
153 #define IGN_UINT64_INF ignition::math::DPRCT_INF_UI64
154 
157 #define IGN_INT64_MAX ignition::math::DPRCT_MAX_I64
158 
161 #define IGN_INT64_MIN ignition::math::DPRCT_MIN_I64
162 
166 #define IGN_INT64_LOW ignition::math::DPRCT_LOW_I64
167 
170 #define IGN_INT64_INF ignition::math::DPRCT_INF_I64
171 
174 #ifdef M_PI
175 #define IGN_PI M_PI
176 #define IGN_PI_2 M_PI_2
177 #define IGN_PI_4 M_PI_4
178 #define IGN_SQRT2 M_SQRT2
179 #else
180 #define IGN_PI 3.14159265358979323846
181 #define IGN_PI_2 1.57079632679489661923
182 #define IGN_PI_4 0.78539816339744830962
183 #define IGN_SQRT2 1.41421356237309504880
184 #endif
185 
189 #if defined __FLT_EVAL_METHOD__ && __FLT_EVAL_METHOD__ == 2
190 #define IGN_FP_VOLATILE volatile
191 #else
192 #define IGN_FP_VOLATILE
193 #endif
194 
197 #define IGN_SPHERE_VOLUME(_radius) (4.0*IGN_PI*std::pow(_radius, 3)/3.0)
198 
202 #define IGN_CYLINDER_VOLUME(_r, _l) (_l * IGN_PI * std::pow(_r, 2))
203 
208 #define IGN_BOX_VOLUME(_x, _y, _z) (_x *_y * _z)
209 
212 #define IGN_BOX_VOLUME_V(_v) (_v.X() *_v.Y() * _v.Z())
213 
214 namespace ignition
215 {
217  namespace math
218  {
219  // Inline bracket to help doxygen filtering.
220  inline namespace IGNITION_MATH_VERSION_NAMESPACE {
221  //
223  static const size_t IGN_ZERO_SIZE_T = 0u;
224 
226  static const size_t IGN_ONE_SIZE_T = 1u;
227 
229  static const size_t IGN_TWO_SIZE_T = 2u;
230 
232  static const size_t IGN_THREE_SIZE_T = 3u;
233 
235  static const size_t IGN_FOUR_SIZE_T = 4u;
236 
238  static const size_t IGN_FIVE_SIZE_T = 5u;
239 
241  static const size_t IGN_SIX_SIZE_T = 6u;
242 
244  static const size_t IGN_SEVEN_SIZE_T = 7u;
245 
247  static const size_t IGN_EIGHT_SIZE_T = 8u;
248 
250  static const size_t IGN_NINE_SIZE_T = 9u;
251 
253  static const double MAX_D = std::numeric_limits<double>::max();
254 
256  static const double MIN_D = std::numeric_limits<double>::min();
257 
260 
263 
266 
268  static const float MAX_F = std::numeric_limits<float>::max();
269 
271  static const float MIN_F = std::numeric_limits<float>::min();
272 
275 
278 
281 
283  static const uint16_t MAX_UI16 = std::numeric_limits<uint16_t>::max();
284 
286  static const uint16_t MIN_UI16 = std::numeric_limits<uint16_t>::min();
287 
291 
294 
296  static const int16_t MAX_I16 = std::numeric_limits<int16_t>::max();
297 
299  static const int16_t MIN_I16 = std::numeric_limits<int16_t>::min();
300 
304 
307 
309  static const uint32_t MAX_UI32 = std::numeric_limits<uint32_t>::max();
310 
312  static const uint32_t MIN_UI32 = std::numeric_limits<uint32_t>::min();
313 
317 
320 
322  static const int32_t MAX_I32 = std::numeric_limits<int32_t>::max();
323 
325  static const int32_t MIN_I32 = std::numeric_limits<int32_t>::min();
326 
330 
333 
335  static const uint64_t MAX_UI64 = std::numeric_limits<uint64_t>::max();
336 
338  static const uint64_t MIN_UI64 = std::numeric_limits<uint64_t>::min();
339 
343 
346 
348  static const int64_t MAX_I64 = std::numeric_limits<int64_t>::max();
349 
351  static const int64_t MIN_I64 = std::numeric_limits<int64_t>::min();
352 
356 
359 
362 
363  // variables created to deprecate macros in this file
364  static const double IGN_DEPRECATED(3) DPRCT_MAX_D = MAX_D;
365  static const double IGN_DEPRECATED(3) DPRCT_MIN_D = MIN_D;
366  static const double IGN_DEPRECATED(3) DPRCT_LOW_D = LOW_D;
367  static const double IGN_DEPRECATED(3) DPRCT_INF_D = INF_D;
368  static const float IGN_DEPRECATED(3) DPRCT_MAX_F = MAX_F;
369  static const float IGN_DEPRECATED(3) DPRCT_MIN_F = MIN_F;
370  static const float IGN_DEPRECATED(3) DPRCT_LOW_F = LOW_F;
371  static const float IGN_DEPRECATED(3) DPRCT_INF_F = INF_F;
372  static const uint16_t IGN_DEPRECATED(3) DPRCT_MAX_UI16 = MAX_UI16;
373  static const uint16_t IGN_DEPRECATED(3) DPRCT_MIN_UI16 = MIN_UI16;
374  static const uint16_t IGN_DEPRECATED(3) DPRCT_LOW_UI16 = LOW_UI16;
375  static const uint16_t IGN_DEPRECATED(3) DPRCT_INF_UI16 = INF_UI16;
376  static const int16_t IGN_DEPRECATED(3) DPRCT_MAX_I16 = MAX_I16;
377  static const int16_t IGN_DEPRECATED(3) DPRCT_MIN_I16 = MIN_I16;
378  static const int16_t IGN_DEPRECATED(3) DPRCT_LOW_I16 = LOW_I16;
379  static const int16_t IGN_DEPRECATED(3) DPRCT_INF_I16 = INF_I16;
380  static const uint32_t IGN_DEPRECATED(3) DPRCT_MAX_UI32 = MAX_UI32;
381  static const uint32_t IGN_DEPRECATED(3) DPRCT_MIN_UI32 = MIN_UI32;
382  static const uint32_t IGN_DEPRECATED(3) DPRCT_LOW_UI32 = LOW_UI32;
383  static const uint32_t IGN_DEPRECATED(3) DPRCT_INF_UI32 = INF_UI32;
384  static const int32_t IGN_DEPRECATED(3) DPRCT_MAX_I32 = MAX_I32;
385  static const int32_t IGN_DEPRECATED(3) DPRCT_MIN_I32 = MIN_I32;
386  static const int32_t IGN_DEPRECATED(3) DPRCT_LOW_I32 = LOW_I32;
387  static const int32_t IGN_DEPRECATED(3) DPRCT_INF_I32 = INF_I32;
388  static const uint64_t IGN_DEPRECATED(3) DPRCT_MAX_UI64 = MAX_UI64;
389  static const uint64_t IGN_DEPRECATED(3) DPRCT_MIN_UI64 = MIN_UI64;
390  static const uint64_t IGN_DEPRECATED(3) DPRCT_LOW_UI64 = LOW_UI64;
391  static const uint64_t IGN_DEPRECATED(3) DPRCT_INF_UI64 = INF_UI64;
392  static const int64_t IGN_DEPRECATED(3) DPRCT_MAX_I64 = MAX_I64;
393  static const int64_t IGN_DEPRECATED(3) DPRCT_MIN_I64 = MIN_I64;
394  static const int64_t IGN_DEPRECATED(3) DPRCT_LOW_I64 = LOW_I64;
395  static const int64_t IGN_DEPRECATED(3) DPRCT_INF_I64 = INF_I64;
396 
401  template<typename T>
402  inline T clamp(T _v, T _min, T _max)
403  {
404  return std::max(std::min(_v, _max), _min);
405  }
406 
410  inline bool isnan(float _v)
411  {
412  return (std::isnan)(_v);
413  }
414 
418  inline bool isnan(double _v)
419  {
420  return (std::isnan)(_v);
421  }
422 
426  inline float fixnan(float _v)
427  {
428  return isnan(_v) || std::isinf(_v) ? 0.0f : _v;
429  }
430 
434  inline double fixnan(double _v)
435  {
436  return isnan(_v) || std::isinf(_v) ? 0.0 : _v;
437  }
438 
442  inline bool isEven(const int _v)
443  {
444  return !(_v % 2);
445  }
446 
450  inline bool isEven(const unsigned int _v)
451  {
452  return !(_v % 2);
453  }
454 
458  inline bool isOdd(const int _v)
459  {
460  return (_v % 2) != 0;
461  }
462 
466  inline bool isOdd(const unsigned int _v)
467  {
468  return (_v % 2) != 0;
469  }
470 
477  template<typename T>
478  inline int sgn(T _value)
479  {
480  return (T(0) < _value) - (_value < T(0));
481  }
482 
489  template<typename T>
490  inline int signum(T _value)
491  {
492  return sgn(_value);
493  }
494 
498  template<typename T>
499  inline T mean(const std::vector<T> &_values)
500  {
501  T sum = 0;
502  for (unsigned int i = 0; i < _values.size(); ++i)
503  sum += _values[i];
504  return sum / _values.size();
505  }
506 
510  template<typename T>
511  inline T variance(const std::vector<T> &_values)
512  {
513  T avg = mean<T>(_values);
514 
515  T sum = 0;
516  for (unsigned int i = 0; i < _values.size(); ++i)
517  sum += (_values[i] - avg) * (_values[i] - avg);
518  return sum / _values.size();
519  }
520 
524  template<typename T>
525  inline T max(const std::vector<T> &_values)
526  {
528  for (unsigned int i = 0; i < _values.size(); ++i)
529  if (_values[i] > max)
530  max = _values[i];
531  return max;
532  }
533 
537  template<typename T>
538  inline T min(const std::vector<T> &_values)
539  {
541  for (unsigned int i = 0; i < _values.size(); ++i)
542  if (_values[i] < min)
543  min = _values[i];
544  return min;
545  }
546 
551  template<typename T>
552  inline bool equal(const T &_a, const T &_b,
553  const T &_epsilon = T(1e-6))
554  {
555  IGN_FP_VOLATILE T diff = std::abs(_a - _b);
556  return diff <= _epsilon;
557  }
558 
563  template<typename T>
564  inline bool lessOrNearEqual(const T &_a, const T &_b,
565  const T &_epsilon = 1e-6)
566  {
567  return _a < _b + _epsilon;
568  }
569 
574  template<typename T>
575  inline bool greaterOrNearEqual(const T &_a, const T &_b,
576  const T &_epsilon = 1e-6)
577  {
578  return _a > _b - _epsilon;
579  }
580 
585  template<typename T>
586  inline T precision(const T &_a, const unsigned int &_precision)
587  {
588  auto p = std::pow(10, _precision);
589  return static_cast<T>(std::round(_a * p) / p);
590  }
591 
595  template<typename T>
596  inline void sort2(T &_a, T &_b)
597  {
598  using std::swap;
599  if (_b < _a)
600  swap(_a, _b);
601  }
602 
607  template<typename T>
608  inline void sort3(T &_a, T &_b, T &_c)
609  {
610  // _a <= _b
611  sort2(_a, _b);
612  // _a <= _c, _b <= _c
613  sort2(_b, _c);
614  // _a <= _b <= _c
615  sort2(_a, _b);
616  }
617 
621  inline bool isPowerOfTwo(unsigned int _x)
622  {
623  return ((_x != 0) && ((_x & (~_x + 1)) == _x));
624  }
625 
631  inline unsigned int roundUpPowerOfTwo(unsigned int _x)
632  {
633  if (_x == 0)
634  return 1;
635 
636  if (isPowerOfTwo(_x))
637  return _x;
638 
639  while (_x & (_x - 1))
640  _x = _x & (_x - 1);
641 
642  _x = _x << 1;
643 
644  return _x;
645  }
646 
650  inline int parseInt(const std::string &_input)
651  {
652  // Return NAN_I if it is empty
653  if (_input.empty())
654  {
655  return NAN_I;
656  }
657  // Return 0 if it is all spaces
658  else if (_input.find_first_not_of(' ') == std::string::npos)
659  {
660  return 0;
661  }
662 
663  // Otherwise try standard library
664  try
665  {
666  return std::stoi(_input);
667  }
668  // if that fails, return NAN_I
669  catch(...)
670  {
671  return NAN_I;
672  }
673  }
674 
679  inline double parseFloat(const std::string &_input)
680  {
681  // Return NAN_D if it is empty
682  if (_input.empty())
683  {
684  return NAN_D;
685  }
686  // Return 0 if it is all spaces
687  else if (_input.find_first_not_of(' ') == std::string::npos)
688  {
689  return 0;
690  }
691 
692  // Otherwise try standard library
693  try
694  {
695  return std::stod(_input);
696  }
697  // if that fails, return NAN_D
698  catch(...)
699  {
700  return NAN_D;
701  }
702  }
703 
704 
705  // Degrade precision on Windows, which cannot handle 'long double'
706  // values properly. See the implementation of Unpair.
707  // 32 bit ARM processors also define 'long double' to be the same
708  // size as 'double', and must also be degraded
709 #if defined _MSC_VER || defined __arm__
710  using PairInput = uint16_t;
711  using PairOutput = uint32_t;
712 #else
713  using PairInput = uint32_t;
714  using PairOutput = uint64_t;
715 #endif
716 
726  PairOutput IGNITION_MATH_VISIBLE Pair(
727  const PairInput _a, const PairInput _b);
728 
740  std::tuple<PairInput, PairInput> IGNITION_MATH_VISIBLE Unpair(
741  const PairOutput _key);
742  }
743  }
744 }
745 
746 #endif
static const size_t IGN_NINE_SIZE_T
size_t type with a value of 9
Definition: Helpers.hh:250
std::tuple< PairInput, PairInput > Unpair(const PairOutput _key)
The reverse of the Pair function. Accepts a key, produced from the Pair function, and returns a tuple...
T empty(T... args)
static const size_t IGN_SIX_SIZE_T
size_t type with a value of 6
Definition: Helpers.hh:241
static const int NAN_I
Returns the representation of a quiet not a number (NAN)
Definition: Helpers.hh:361
static const int32_t LOW_I32
32bit unsigned integer lowest value. This is equivalent to IGN_INT32_MIN, and is defined here for com...
Definition: Helpers.hh:329
static const float INF_F
float positive infinite value
Definition: Helpers.hh:277
static const double LOW_D
Double low value, equivalent to -MAX_D.
Definition: Helpers.hh:259
T find_first_not_of(T... args)
static const uint64_t MIN_UI64
64bit unsigned integer minimum value
Definition: Helpers.hh:338
static const uint32_t MIN_UI32
32bit unsigned integer minimum value
Definition: Helpers.hh:312
T precision(const T &_a, const unsigned int &_precision)
get value at a specified precision
Definition: Helpers.hh:586
static const static double const static double const static double const static double const static float const static float const static float const static float const static uint16_t const static uint16_t const static uint16_t const static uint16_t const static int16_t const static int16_t const static int16_t const static int16_t const static uint32_t const static uint32_t const static uint32_t const static uint32_t const static int32_t const static int32_t const static int32_t const static int32_t const static uint64_t const static uint64_t const static uint64_t const static uint64_t const static int64_t const static int64_t const static int64_t const int64_t T clamp(T _v, T _min, T _max)
Simple clamping function.
Definition: Helpers.hh:402
static const size_t IGN_EIGHT_SIZE_T
size_t type with a value of 8
Definition: Helpers.hh:247
T mean(const std::vector< T > &_values)
get mean of vector of values
Definition: Helpers.hh:499
static const int32_t INF_I32
32-bit unsigned integer positive infinite value
Definition: Helpers.hh:332
T swap(T... args)
static const float NAN_F
Returns the representation of a quiet not a number (NAN)
Definition: Helpers.hh:280
static const int16_t MAX_I16
16bit unsigned integer maximum value
Definition: Helpers.hh:296
static const uint16_t MAX_UI16
16bit unsigned integer maximum value
Definition: Helpers.hh:283
bool isnan(float _v)
check if a float is NaN
Definition: Helpers.hh:410
T stod(T... args)
static const uint64_t MAX_UI64
64bit unsigned integer maximum value
Definition: Helpers.hh:335
static const uint64_t LOW_UI64
64bit unsigned integer lowest value. This is equivalent to IGN_UINT64_MIN, and is defined here for co...
Definition: Helpers.hh:342
unsigned int roundUpPowerOfTwo(unsigned int _x)
Get the smallest power of two that is greater or equal to a given value.
Definition: Helpers.hh:631
static const uint32_t MAX_UI32
32bit unsigned integer maximum value
Definition: Helpers.hh:309
T max(const std::vector< T > &_values)
get the maximum value of vector of values
Definition: Helpers.hh:525
static const int64_t MAX_I64
64bit unsigned integer maximum value
Definition: Helpers.hh:348
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:552
static const double MIN_D
Double min value. This value will be similar to 2.22507e-308.
Definition: Helpers.hh:256
static const size_t IGN_ONE_SIZE_T
size_t type with a value of 1
Definition: Helpers.hh:226
bool isOdd(const int _v)
Check if parameter is odd.
Definition: Helpers.hh:458
bool greaterOrNearEqual(const T &_a, const T &_b, const T &_epsilon=1e-6)
inequality test, within a tolerance
Definition: Helpers.hh:575
STL class.
T variance(const std::vector< T > &_values)
get variance of vector of values
Definition: Helpers.hh:511
T min(T... args)
static const size_t IGN_FOUR_SIZE_T
size_t type with a value of 4
Definition: Helpers.hh:235
static const uint32_t INF_UI32
32-bit unsigned integer positive infinite value
Definition: Helpers.hh:319
static const size_t IGN_FIVE_SIZE_T
size_t type with a value of 5
Definition: Helpers.hh:238
static const uint64_t INF_UI64
64-bit unsigned integer positive infinite value
Definition: Helpers.hh:345
T lowest(T... args)
static const float LOW_F
Float low value, equivalent to -MAX_F.
Definition: Helpers.hh:274
uint64_t PairOutput
Definition: Helpers.hh:714
#define IGN_FP_VOLATILE
Define IGN_FP_VOLATILE for FP equality comparisons Use volatile parameters when checking floating poi...
Definition: Helpers.hh:192
bool isPowerOfTwo(unsigned int _x)
Is this a power of 2?
Definition: Helpers.hh:621
static const uint16_t INF_UI16
16-bit unsigned integer positive infinite value
Definition: Helpers.hh:293
uint32_t PairInput
Definition: Helpers.hh:713
static const size_t IGN_ZERO_SIZE_T
size_t type with a value of 0
Definition: Helpers.hh:223
static const uint16_t MIN_UI16
16bit unsigned integer minimum value
Definition: Helpers.hh:286
static const uint16_t LOW_UI16
16bit unsigned integer lowest value. This is equivalent to IGN_UINT16_MIN, and is defined here for co...
Definition: Helpers.hh:290
static const int16_t MIN_I16
16bit unsigned integer minimum value
Definition: Helpers.hh:299
T infinity(T... args)
static const int32_t MIN_I32
32bit unsigned integer minimum value
Definition: Helpers.hh:325
T max(T... args)
static const int64_t MIN_I64
64bit unsigned integer minimum value
Definition: Helpers.hh:351
PairOutput Pair(const PairInput _a, const PairInput _b)
A pairing function that maps two values to a unique third value. This is an implement of Szudzik&#39;s fu...
static const float MAX_F
Float maximum value. This value will be similar to 3.40282e+38.
Definition: Helpers.hh:268
int sgn(T _value)
The signum function.
Definition: Helpers.hh:478
T size(T... args)
int signum(T _value)
The signum function.
Definition: Helpers.hh:490
STL class.
bool isEven(const int _v)
Check if parameter is even.
Definition: Helpers.hh:442
T pow(T... args)
static const double NAN_D
Returns the representation of a quiet not a number (NAN)
Definition: Helpers.hh:265
static const int16_t LOW_I16
16bit unsigned integer lowest value. This is equivalent to IGN_INT16_MIN, and is defined here for com...
Definition: Helpers.hh:303
static const int64_t LOW_I64
64bit unsigned integer lowest value. This is equivalent to IGN_INT64_MIN, and is defined here for com...
Definition: Helpers.hh:355
static const double MAX_D
Double maximum value. This value will be similar to 1.79769e+308.
Definition: Helpers.hh:253
static const size_t IGN_TWO_SIZE_T
size_t type with a value of 2
Definition: Helpers.hh:229
static const int64_t INF_I64
64-bit unsigned integer positive infinite value
Definition: Helpers.hh:358
static const float MIN_F
Float minimum value. This value will be similar to 1.17549e-38.
Definition: Helpers.hh:271
T isnan(T... args)
double parseFloat(const std::string &_input)
parse string into float
Definition: Helpers.hh:679
constexpr T IGN_MASSMATRIX3_DEFAULT_TOLERANCE
The default tolerance value used by MassMatrix3::IsValid(), MassMatrix3::IsPositive(), and MassMatrix3::ValidMoments()
Definition: Helpers.hh:36
static const int16_t INF_I16
16-bit unsigned integer positive infinite value
Definition: Helpers.hh:306
T quiet_NaN(T... args)
static const double INF_D
Double positive infinite value.
Definition: Helpers.hh:262
void sort2(T &_a, T &_b)
Sort two numbers, such that _a <= _b.
Definition: Helpers.hh:596
static const uint32_t LOW_UI32
32bit unsigned integer lowest value. This is equivalent to IGN_UINT32_MIN, and is defined here for co...
Definition: Helpers.hh:316
static const size_t IGN_THREE_SIZE_T
size_t type with a value of 3
Definition: Helpers.hh:232
static const size_t IGN_SEVEN_SIZE_T
size_t type with a value of 7
Definition: Helpers.hh:244
T isinf(T... args)
Definition: Angle.hh:39
float fixnan(float _v)
Fix a nan value.
Definition: Helpers.hh:426
T stoi(T... args)
T round(T... args)
int parseInt(const std::string &_input)
parse string into an integer
Definition: Helpers.hh:650
bool lessOrNearEqual(const T &_a, const T &_b, const T &_epsilon=1e-6)
inequality test, within a tolerance
Definition: Helpers.hh:564
T min(const std::vector< T > &_values)
get the minimum value of vector of values
Definition: Helpers.hh:538
void sort3(T &_a, T &_b, T &_c)
Sort three numbers, such that _a <= _b <= _c.
Definition: Helpers.hh:608
static const int32_t MAX_I32
32bit unsigned integer maximum value
Definition: Helpers.hh:322