Ignition Math

API Reference

6.4.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 <chrono>
21 #include <cmath>
22 #include <algorithm>
23 #include <limits>
24 #include <string>
25 #include <iostream>
26 #include <vector>
27 #include <tuple>
28 #include <utility>
29 #include <cstdint>
30 
31 #include <ignition/math/config.hh>
32 #include "ignition/math/Export.hh"
33 
36 template <typename T>
38 
41 #define IGN_DBL_MAX ignition::math::DPRCT_MAX_D
42 
45 #define IGN_DBL_MIN ignition::math::DPRCT_MIN_D
46 
49 #define IGN_DBL_LOW ignition::math::DPRCT_LOW_D
50 
53 #define IGN_DBL_INF ignition::math::DPRCT_INF_D
54 
57 #define IGN_FLT_MAX ignition::math::DPRCT_MAX_F
58 
61 #define IGN_FLT_MIN ignition::math::DPRCT_MIN_F
62 
65 #define IGN_FLT_LOW ignition::math::DPRCT_LOW_F
66 
69 #define IGN_FLT_INF ignition::math::DPRCT_INF_F
70 
73 #define IGN_UINT16_MAX ignition::math::DPRCT_MAX_UI16
74 
77 #define IGN_UINT16_MIN ignition::math::DPRCT_MIN_UI16
78 
82 #define IGN_UINT16_LOW ignition::math::DPRCT_LOW_UI16
83 
86 #define IGN_UINT16_INF ignition::math::DPRCT_INF_UI16
87 
90 #define IGN_INT16_MAX ignition::math::DPRCT_MAX_I16
91 
94 #define IGN_INT16_MIN ignition::math::DPRCT_MIN_I16
95 
99 #define IGN_INT16_LOW ignition::math::DPRCT_LOW_I16
100 
103 #define IGN_INT16_INF ignition::math::DPRCT_INF_I16
104 
107 #define IGN_UINT32_MAX ignition::math::DPRCT_MAX_UI32
108 
111 #define IGN_UINT32_MIN ignition::math::DPRCT_MIN_UI32
112 
116 #define IGN_UINT32_LOW ignition::math::DPRCT_LOW_UI32
117 
120 #define IGN_UINT32_INF ignition::math::DPRCT_INF_UI32
121 
124 #define IGN_INT32_MAX ignition::math::DPRCT_MAX_I32
125 
128 #define IGN_INT32_MIN ignition::math::DPRCT_MIN_I32
129 
133 #define IGN_INT32_LOW ignition::math::DPRCT_LOW_I32
134 
137 #define IGN_INT32_INF ignition::math::DPRCT_INF_I32
138 
141 #define IGN_UINT64_MAX ignition::math::DPRCT_MAX_UI64
142 
145 #define IGN_UINT64_MIN ignition::math::DPRCT_MIN_UI64
146 
150 #define IGN_UINT64_LOW ignition::math::DPRCT_LOW_UI64
151 
154 #define IGN_UINT64_INF ignition::math::DPRCT_INF_UI64
155 
158 #define IGN_INT64_MAX ignition::math::DPRCT_MAX_I64
159 
162 #define IGN_INT64_MIN ignition::math::DPRCT_MIN_I64
163 
167 #define IGN_INT64_LOW ignition::math::DPRCT_LOW_I64
168 
171 #define IGN_INT64_INF ignition::math::DPRCT_INF_I64
172 
175 #ifdef M_PI
176 #define IGN_PI M_PI
177 #define IGN_PI_2 M_PI_2
178 #define IGN_PI_4 M_PI_4
179 #define IGN_SQRT2 M_SQRT2
180 #else
181 #define IGN_PI 3.14159265358979323846
182 #define IGN_PI_2 1.57079632679489661923
183 #define IGN_PI_4 0.78539816339744830962
184 #define IGN_SQRT2 1.41421356237309504880
185 #endif
186 
190 #if defined __FLT_EVAL_METHOD__ && __FLT_EVAL_METHOD__ == 2
191 #define IGN_FP_VOLATILE volatile
192 #else
193 #define IGN_FP_VOLATILE
194 #endif
195 
198 #define IGN_SPHERE_VOLUME(_radius) (4.0*IGN_PI*std::pow(_radius, 3)/3.0)
199 
203 #define IGN_CYLINDER_VOLUME(_r, _l) (_l * IGN_PI * std::pow(_r, 2))
204 
209 #define IGN_BOX_VOLUME(_x, _y, _z) (_x *_y * _z)
210 
213 #define IGN_BOX_VOLUME_V(_v) (_v.X() *_v.Y() * _v.Z())
214 
215 namespace ignition
216 {
218  namespace math
219  {
220  // Inline bracket to help doxygen filtering.
221  inline namespace IGNITION_MATH_VERSION_NAMESPACE {
222  //
224  static const size_t IGN_ZERO_SIZE_T = 0u;
225 
227  static const size_t IGN_ONE_SIZE_T = 1u;
228 
230  static const size_t IGN_TWO_SIZE_T = 2u;
231 
233  static const size_t IGN_THREE_SIZE_T = 3u;
234 
236  static const size_t IGN_FOUR_SIZE_T = 4u;
237 
239  static const size_t IGN_FIVE_SIZE_T = 5u;
240 
242  static const size_t IGN_SIX_SIZE_T = 6u;
243 
245  static const size_t IGN_SEVEN_SIZE_T = 7u;
246 
248  static const size_t IGN_EIGHT_SIZE_T = 8u;
249 
251  static const size_t IGN_NINE_SIZE_T = 9u;
252 
254  static const double MAX_D = std::numeric_limits<double>::max();
255 
257  static const double MIN_D = std::numeric_limits<double>::min();
258 
261 
264 
267 
269  static const float MAX_F = std::numeric_limits<float>::max();
270 
272  static const float MIN_F = std::numeric_limits<float>::min();
273 
276 
279 
282 
284  static const uint16_t MAX_UI16 = std::numeric_limits<uint16_t>::max();
285 
287  static const uint16_t MIN_UI16 = std::numeric_limits<uint16_t>::min();
288 
292 
295 
297  static const int16_t MAX_I16 = std::numeric_limits<int16_t>::max();
298 
300  static const int16_t MIN_I16 = std::numeric_limits<int16_t>::min();
301 
305 
308 
310  static const uint32_t MAX_UI32 = std::numeric_limits<uint32_t>::max();
311 
313  static const uint32_t MIN_UI32 = std::numeric_limits<uint32_t>::min();
314 
318 
321 
323  static const int32_t MAX_I32 = std::numeric_limits<int32_t>::max();
324 
326  static const int32_t MIN_I32 = std::numeric_limits<int32_t>::min();
327 
331 
334 
336  static const uint64_t MAX_UI64 = std::numeric_limits<uint64_t>::max();
337 
339  static const uint64_t MIN_UI64 = std::numeric_limits<uint64_t>::min();
340 
344 
347 
349  static const int64_t MAX_I64 = std::numeric_limits<int64_t>::max();
350 
352  static const int64_t MIN_I64 = std::numeric_limits<int64_t>::min();
353 
357 
360 
363 
364  // variables created to deprecate macros in this file
365  static const double IGN_DEPRECATED(3) DPRCT_MAX_D = MAX_D;
366  static const double IGN_DEPRECATED(3) DPRCT_MIN_D = MIN_D;
367  static const double IGN_DEPRECATED(3) DPRCT_LOW_D = LOW_D;
368  static const double IGN_DEPRECATED(3) DPRCT_INF_D = INF_D;
369  static const float IGN_DEPRECATED(3) DPRCT_MAX_F = MAX_F;
370  static const float IGN_DEPRECATED(3) DPRCT_MIN_F = MIN_F;
371  static const float IGN_DEPRECATED(3) DPRCT_LOW_F = LOW_F;
372  static const float IGN_DEPRECATED(3) DPRCT_INF_F = INF_F;
373  static const uint16_t IGN_DEPRECATED(3) DPRCT_MAX_UI16 = MAX_UI16;
374  static const uint16_t IGN_DEPRECATED(3) DPRCT_MIN_UI16 = MIN_UI16;
375  static const uint16_t IGN_DEPRECATED(3) DPRCT_LOW_UI16 = LOW_UI16;
376  static const uint16_t IGN_DEPRECATED(3) DPRCT_INF_UI16 = INF_UI16;
377  static const int16_t IGN_DEPRECATED(3) DPRCT_MAX_I16 = MAX_I16;
378  static const int16_t IGN_DEPRECATED(3) DPRCT_MIN_I16 = MIN_I16;
379  static const int16_t IGN_DEPRECATED(3) DPRCT_LOW_I16 = LOW_I16;
380  static const int16_t IGN_DEPRECATED(3) DPRCT_INF_I16 = INF_I16;
381  static const uint32_t IGN_DEPRECATED(3) DPRCT_MAX_UI32 = MAX_UI32;
382  static const uint32_t IGN_DEPRECATED(3) DPRCT_MIN_UI32 = MIN_UI32;
383  static const uint32_t IGN_DEPRECATED(3) DPRCT_LOW_UI32 = LOW_UI32;
384  static const uint32_t IGN_DEPRECATED(3) DPRCT_INF_UI32 = INF_UI32;
385  static const int32_t IGN_DEPRECATED(3) DPRCT_MAX_I32 = MAX_I32;
386  static const int32_t IGN_DEPRECATED(3) DPRCT_MIN_I32 = MIN_I32;
387  static const int32_t IGN_DEPRECATED(3) DPRCT_LOW_I32 = LOW_I32;
388  static const int32_t IGN_DEPRECATED(3) DPRCT_INF_I32 = INF_I32;
389  static const uint64_t IGN_DEPRECATED(3) DPRCT_MAX_UI64 = MAX_UI64;
390  static const uint64_t IGN_DEPRECATED(3) DPRCT_MIN_UI64 = MIN_UI64;
391  static const uint64_t IGN_DEPRECATED(3) DPRCT_LOW_UI64 = LOW_UI64;
392  static const uint64_t IGN_DEPRECATED(3) DPRCT_INF_UI64 = INF_UI64;
393  static const int64_t IGN_DEPRECATED(3) DPRCT_MAX_I64 = MAX_I64;
394  static const int64_t IGN_DEPRECATED(3) DPRCT_MIN_I64 = MIN_I64;
395  static const int64_t IGN_DEPRECATED(3) DPRCT_LOW_I64 = LOW_I64;
396  static const int64_t IGN_DEPRECATED(3) DPRCT_INF_I64 = INF_I64;
397 
402  template<typename T>
403  inline T clamp(T _v, T _min, T _max)
404  {
405  return std::max(std::min(_v, _max), _min);
406  }
407 
411  inline bool isnan(float _v)
412  {
413  return (std::isnan)(_v);
414  }
415 
419  inline bool isnan(double _v)
420  {
421  return (std::isnan)(_v);
422  }
423 
427  inline float fixnan(float _v)
428  {
429  return isnan(_v) || std::isinf(_v) ? 0.0f : _v;
430  }
431 
435  inline double fixnan(double _v)
436  {
437  return isnan(_v) || std::isinf(_v) ? 0.0 : _v;
438  }
439 
443  inline bool isEven(const int _v)
444  {
445  return !(_v % 2);
446  }
447 
451  inline bool isEven(const unsigned int _v)
452  {
453  return !(_v % 2);
454  }
455 
459  inline bool isOdd(const int _v)
460  {
461  return (_v % 2) != 0;
462  }
463 
467  inline bool isOdd(const unsigned int _v)
468  {
469  return (_v % 2) != 0;
470  }
471 
478  template<typename T>
479  inline int sgn(T _value)
480  {
481  return (T(0) < _value) - (_value < T(0));
482  }
483 
490  template<typename T>
491  inline int signum(T _value)
492  {
493  return sgn(_value);
494  }
495 
499  template<typename T>
500  inline T mean(const std::vector<T> &_values)
501  {
502  T sum = 0;
503  for (unsigned int i = 0; i < _values.size(); ++i)
504  sum += _values[i];
505  return sum / _values.size();
506  }
507 
511  template<typename T>
512  inline T variance(const std::vector<T> &_values)
513  {
514  T avg = mean<T>(_values);
515 
516  T sum = 0;
517  for (unsigned int i = 0; i < _values.size(); ++i)
518  sum += (_values[i] - avg) * (_values[i] - avg);
519  return sum / _values.size();
520  }
521 
525  template<typename T>
526  inline T max(const std::vector<T> &_values)
527  {
529  for (unsigned int i = 0; i < _values.size(); ++i)
530  if (_values[i] > max)
531  max = _values[i];
532  return max;
533  }
534 
538  template<typename T>
539  inline T min(const std::vector<T> &_values)
540  {
542  for (unsigned int i = 0; i < _values.size(); ++i)
543  if (_values[i] < min)
544  min = _values[i];
545  return min;
546  }
547 
552  template<typename T>
553  inline bool equal(const T &_a, const T &_b,
554  const T &_epsilon = T(1e-6))
555  {
556  IGN_FP_VOLATILE T diff = std::abs(_a - _b);
557  return diff <= _epsilon;
558  }
559 
564  template<typename T>
565  inline bool lessOrNearEqual(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 bool greaterOrNearEqual(const T &_a, const T &_b,
577  const T &_epsilon = 1e-6)
578  {
579  return _a > _b - _epsilon;
580  }
581 
586  template<typename T>
587  inline T precision(const T &_a, const unsigned int &_precision)
588  {
589  auto p = std::pow(10, _precision);
590  return static_cast<T>(std::round(_a * p) / p);
591  }
592 
596  template<typename T>
597  inline void sort2(T &_a, T &_b)
598  {
599  using std::swap;
600  if (_b < _a)
601  swap(_a, _b);
602  }
603 
608  template<typename T>
609  inline void sort3(T &_a, T &_b, T &_c)
610  {
611  // _a <= _b
612  sort2(_a, _b);
613  // _a <= _c, _b <= _c
614  sort2(_b, _c);
615  // _a <= _b <= _c
616  sort2(_a, _b);
617  }
618 
622  inline bool isPowerOfTwo(unsigned int _x)
623  {
624  return ((_x != 0) && ((_x & (~_x + 1)) == _x));
625  }
626 
632  inline unsigned int roundUpPowerOfTwo(unsigned int _x)
633  {
634  if (_x == 0)
635  return 1;
636 
637  if (isPowerOfTwo(_x))
638  return _x;
639 
640  while (_x & (_x - 1))
641  _x = _x & (_x - 1);
642 
643  _x = _x << 1;
644 
645  return _x;
646  }
647 
658  inline int roundUpMultiple(int _num, int _multiple)
659  {
660  if (_multiple == 0)
661  return _num;
662 
663  int remainder = std::abs(_num) % _multiple;
664  if (remainder == 0)
665  return _num;
666 
667  if (_num < 0)
668  return -(std::abs(_num) - remainder);
669  else
670  return _num + _multiple - remainder;
671  }
672 
676  inline int parseInt(const std::string &_input)
677  {
678  // Return NAN_I if it is empty
679  if (_input.empty())
680  {
681  return NAN_I;
682  }
683  // Return 0 if it is all spaces
684  else if (_input.find_first_not_of(' ') == std::string::npos)
685  {
686  return 0;
687  }
688 
689  // Otherwise try standard library
690  try
691  {
692  return std::stoi(_input);
693  }
694  // if that fails, return NAN_I
695  catch(...)
696  {
697  return NAN_I;
698  }
699  }
700 
705  inline double parseFloat(const std::string &_input)
706  {
707  // Return NAN_D if it is empty
708  if (_input.empty())
709  {
710  return NAN_D;
711  }
712  // Return 0 if it is all spaces
713  else if (_input.find_first_not_of(' ') == std::string::npos)
714  {
715  return 0;
716  }
717 
718  // Otherwise try standard library
719  try
720  {
721  return std::stod(_input);
722  }
723  // if that fails, return NAN_D
724  catch(...)
725  {
726  return NAN_D;
727  }
728  }
729 
736  const std::chrono::steady_clock::duration &_dur)
737  {
740  return {s.count(), ns.count()};
741  }
742 
743  // Degrade precision on Windows, which cannot handle 'long double'
744  // values properly. See the implementation of Unpair.
745  // 32 bit ARM processors also define 'long double' to be the same
746  // size as 'double', and must also be degraded
747 #if defined _MSC_VER || defined __arm__
748  using PairInput = uint16_t;
749  using PairOutput = uint32_t;
750 #else
751  using PairInput = uint32_t;
752  using PairOutput = uint64_t;
753 #endif
754 
764  PairOutput IGNITION_MATH_VISIBLE Pair(
765  const PairInput _a, const PairInput _b);
766 
778  std::tuple<PairInput, PairInput> IGNITION_MATH_VISIBLE Unpair(
779  const PairOutput _key);
780  }
781  }
782 }
783 
784 #endif
static const size_t IGN_NINE_SIZE_T
size_t type with a value of 9
Definition: Helpers.hh:251
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:242
static const int NAN_I
Returns the representation of a quiet not a number (NAN)
Definition: Helpers.hh:362
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:330
static const float INF_F
float positive infinite value
Definition: Helpers.hh:278
static const double LOW_D
Double low value, equivalent to -MAX_D.
Definition: Helpers.hh:260
T find_first_not_of(T... args)
static const uint64_t MIN_UI64
64bit unsigned integer minimum value
Definition: Helpers.hh:339
static const uint32_t MIN_UI32
32bit unsigned integer minimum value
Definition: Helpers.hh:313
T precision(const T &_a, const unsigned int &_precision)
get value at a specified precision
Definition: Helpers.hh:587
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:403
static const size_t IGN_EIGHT_SIZE_T
size_t type with a value of 8
Definition: Helpers.hh:248
T mean(const std::vector< T > &_values)
get mean of vector of values
Definition: Helpers.hh:500
static const int32_t INF_I32
32-bit unsigned integer positive infinite value
Definition: Helpers.hh:333
T swap(T... args)
static const float NAN_F
Returns the representation of a quiet not a number (NAN)
Definition: Helpers.hh:281
static const int16_t MAX_I16
16bit unsigned integer maximum value
Definition: Helpers.hh:297
static const uint16_t MAX_UI16
16bit unsigned integer maximum value
Definition: Helpers.hh:284
bool isnan(float _v)
check if a float is NaN
Definition: Helpers.hh:411
T stod(T... args)
static const uint64_t MAX_UI64
64bit unsigned integer maximum value
Definition: Helpers.hh:336
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:343
unsigned int roundUpPowerOfTwo(unsigned int _x)
Get the smallest power of two that is greater or equal to a given value.
Definition: Helpers.hh:632
static const uint32_t MAX_UI32
32bit unsigned integer maximum value
Definition: Helpers.hh:310
T max(const std::vector< T > &_values)
get the maximum value of vector of values
Definition: Helpers.hh:526
T duration_cast(T... args)
static const int64_t MAX_I64
64bit unsigned integer maximum value
Definition: Helpers.hh:349
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:553
static const double MIN_D
Double min value. This value will be similar to 2.22507e-308.
Definition: Helpers.hh:257
static const size_t IGN_ONE_SIZE_T
size_t type with a value of 1
Definition: Helpers.hh:227
bool isOdd(const int _v)
Check if parameter is odd.
Definition: Helpers.hh:459
bool greaterOrNearEqual(const T &_a, const T &_b, const T &_epsilon=1e-6)
inequality test, within a tolerance
Definition: Helpers.hh:576
STL class.
T variance(const std::vector< T > &_values)
get variance of vector of values
Definition: Helpers.hh:512
T min(T... args)
static const size_t IGN_FOUR_SIZE_T
size_t type with a value of 4
Definition: Helpers.hh:236
std::pair< int64_t, int64_t > durationToSecNsec(const std::chrono::steady_clock::duration &_dur)
Convert a std::chrono::steady_clock::duration to a seconds and nanoseconds pair.
Definition: Helpers.hh:735
static const uint32_t INF_UI32
32-bit unsigned integer positive infinite value
Definition: Helpers.hh:320
static const size_t IGN_FIVE_SIZE_T
size_t type with a value of 5
Definition: Helpers.hh:239
static const uint64_t INF_UI64
64-bit unsigned integer positive infinite value
Definition: Helpers.hh:346
T lowest(T... args)
static const float LOW_F
Float low value, equivalent to -MAX_F.
Definition: Helpers.hh:275
uint64_t PairOutput
Definition: Helpers.hh:752
#define IGN_FP_VOLATILE
Define IGN_FP_VOLATILE for FP equality comparisons Use volatile parameters when checking floating poi...
Definition: Helpers.hh:193
bool isPowerOfTwo(unsigned int _x)
Is this a power of 2?
Definition: Helpers.hh:622
static const uint16_t INF_UI16
16-bit unsigned integer positive infinite value
Definition: Helpers.hh:294
uint32_t PairInput
Definition: Helpers.hh:751
static const size_t IGN_ZERO_SIZE_T
size_t type with a value of 0
Definition: Helpers.hh:224
static const uint16_t MIN_UI16
16bit unsigned integer minimum value
Definition: Helpers.hh:287
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:291
static const int16_t MIN_I16
16bit unsigned integer minimum value
Definition: Helpers.hh:300
T infinity(T... args)
static const int32_t MIN_I32
32bit unsigned integer minimum value
Definition: Helpers.hh:326
T max(T... args)
static const int64_t MIN_I64
64bit unsigned integer minimum value
Definition: Helpers.hh:352
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:269
int sgn(T _value)
The signum function.
Definition: Helpers.hh:479
T size(T... args)
int signum(T _value)
The signum function.
Definition: Helpers.hh:491
STL class.
bool isEven(const int _v)
Check if parameter is even.
Definition: Helpers.hh:443
T pow(T... args)
static const double NAN_D
Returns the representation of a quiet not a number (NAN)
Definition: Helpers.hh:266
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:304
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:356
static const double MAX_D
Double maximum value. This value will be similar to 1.79769e+308.
Definition: Helpers.hh:254
static const size_t IGN_TWO_SIZE_T
size_t type with a value of 2
Definition: Helpers.hh:230
static const int64_t INF_I64
64-bit unsigned integer positive infinite value
Definition: Helpers.hh:359
static const float MIN_F
Float minimum value. This value will be similar to 1.17549e-38.
Definition: Helpers.hh:272
T isnan(T... args)
double parseFloat(const std::string &_input)
parse string into float
Definition: Helpers.hh:705
constexpr T IGN_MASSMATRIX3_DEFAULT_TOLERANCE
The default tolerance value used by MassMatrix3::IsValid(), MassMatrix3::IsPositive(), and MassMatrix3::ValidMoments()
Definition: Helpers.hh:37
static const int16_t INF_I16
16-bit unsigned integer positive infinite value
Definition: Helpers.hh:307
T quiet_NaN(T... args)
static const double INF_D
Double positive infinite value.
Definition: Helpers.hh:263
void sort2(T &_a, T &_b)
Sort two numbers, such that _a <= _b.
Definition: Helpers.hh:597
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:317
static const size_t IGN_THREE_SIZE_T
size_t type with a value of 3
Definition: Helpers.hh:233
static const size_t IGN_SEVEN_SIZE_T
size_t type with a value of 7
Definition: Helpers.hh:245
T isinf(T... args)
Definition: Angle.hh:42
float fixnan(float _v)
Fix a nan value.
Definition: Helpers.hh:427
T stoi(T... args)
T round(T... args)
int parseInt(const std::string &_input)
parse string into an integer
Definition: Helpers.hh:676
bool lessOrNearEqual(const T &_a, const T &_b, const T &_epsilon=1e-6)
inequality test, within a tolerance
Definition: Helpers.hh:565
T min(const std::vector< T > &_values)
get the minimum value of vector of values
Definition: Helpers.hh:539
int roundUpMultiple(int _num, int _multiple)
Round a number up to the nearest multiple. For example, if the input number is 12 and the multiple is...
Definition: Helpers.hh:658
void sort3(T &_a, T &_b, T &_c)
Sort three numbers, such that _a <= _b <= _c.
Definition: Helpers.hh:609
static const int32_t MAX_I32
32bit unsigned integer maximum value
Definition: Helpers.hh:323