#include <cmath>#include <algorithm>#include <limits>#include <string>#include <iostream>#include <vector>#include <tuple>#include <cstdint>Go to the source code of this file.
Namespaces | |
| ignition | |
| ignition::math | |
| Math classes and function useful in robot applications. | |
Macros | |
| #define | IGN_BOX_VOLUME(_x, _y, _z) (_x *_y * _z) |
| Compute box volume. More... | |
| #define | IGN_BOX_VOLUME_V(_v) (_v.X() *_v.Y() * _v.Z()) |
| Compute box volume from a vector. More... | |
| #define | IGN_CYLINDER_VOLUME(_r, _l) (_l * IGN_PI * std::pow(_r, 2)) |
| Compute cylinder volume. More... | |
| #define | IGN_DBL_INF std::numeric_limits<double>::infinity() |
| Double positive infinite value. More... | |
| #define | IGN_DBL_LOW std::numeric_limits<double>::lowest() |
| Double low value, equivalent to -IGN_DBL_MAX. More... | |
| #define | IGN_DBL_MAX std::numeric_limits<double>::max() |
| Double maximum value. This value will be similar to 1.79769e+308. More... | |
| #define | IGN_DBL_MIN std::numeric_limits<double>::min() |
| Double min value. This value will be similar to 2.22507e-308. More... | |
| #define | IGN_FLT_INF std::numeric_limits<float>::infinity() |
| Float positive infinite value. More... | |
| #define | IGN_FLT_LOW std::numeric_limits<float>::lowest() |
| Float lowest value, equivalent to -IGN_FLT_MAX. More... | |
| #define | IGN_FLT_MAX std::numeric_limits<float>::max() |
| Float maximum value. This value will be similar to 3.40282e+38. More... | |
| #define | IGN_FLT_MIN std::numeric_limits<float>::min() |
| Float minimum value. This value will be similar to 1.17549e-38. More... | |
| #define | IGN_FP_VOLATILE |
| Define IGN_FP_VOLATILE for FP equality comparisons Use volatile parameters when checking floating point equality on the 387 math coprocessor to work around bugs from the 387 extra precision. More... | |
| #define | IGN_INT16_INF std::numeric_limits<int16_t>::infinity() |
| 16-bit integer positive infinite value More... | |
| #define | IGN_INT16_LOW std::numeric_limits<int16_t>::lowest() |
| 16bit integer lowest value. More... | |
| #define | IGN_INT16_MAX std::numeric_limits<int16_t>::max() |
| 16bit integer maximum value More... | |
| #define | IGN_INT16_MIN std::numeric_limits<int16_t>::min() |
| 16bit integer minimum value More... | |
| #define | IGN_INT32_INF std::numeric_limits<int32_t>::infinity() |
| 32-bit integer positive infinite value More... | |
| #define | IGN_INT32_LOW std::numeric_limits<int32_t>::lowest() |
| 32bit integer minimum value. More... | |
| #define | IGN_INT32_MAX std::numeric_limits<int32_t>::max() |
| 32bit integer maximum value More... | |
| #define | IGN_INT32_MIN std::numeric_limits<int32_t>::min() |
| 32bit integer minimum value More... | |
| #define | IGN_INT64_INF std::numeric_limits<int64_t>::infinity() |
| 64-bit integer positive infinite value More... | |
| #define | IGN_INT64_LOW std::numeric_limits<int64_t>::lowest() |
| 64bit integer lowest value. More... | |
| #define | IGN_INT64_MAX std::numeric_limits<int64_t>::max() |
| 64bit integer maximum value More... | |
| #define | IGN_INT64_MIN std::numeric_limits<int64_t>::min() |
| 64bit integer minimum value More... | |
| #define | IGN_PI 3.14159265358979323846 |
| Define IGN_PI, IGN_PI_2, and IGN_PI_4. More... | |
| #define | IGN_PI_2 1.57079632679489661923 |
| #define | IGN_PI_4 0.78539816339744830962 |
| #define | IGN_SPHERE_VOLUME(_radius) (4.0*IGN_PI*std::pow(_radius, 3)/3.0) |
| Compute sphere volume. More... | |
| #define | IGN_SQRT2 1.41421356237309504880 |
| #define | IGN_UINT16_INF std::numeric_limits<uint16_t>::infinity() |
| 16-bit unsigned integer positive infinite value More... | |
| #define | IGN_UINT16_LOW std::numeric_limits<uint16_t>::lowest() |
| 16bit unsigned integer lowest value. More... | |
| #define | IGN_UINT16_MAX std::numeric_limits<uint16_t>::max() |
| 16bit unsigned integer maximum value More... | |
| #define | IGN_UINT16_MIN std::numeric_limits<uint16_t>::min() |
| 16bit unsigned integer minimum value More... | |
| #define | IGN_UINT32_INF std::numeric_limits<uint32_t>::infinity() |
| 32-bit unsigned integer positive infinite value More... | |
| #define | IGN_UINT32_LOW std::numeric_limits<uint32_t>::lowest() |
| 32bit unsigned integer lowest value. More... | |
| #define | IGN_UINT32_MAX std::numeric_limits<uint32_t>::max() |
| 32bit unsigned integer maximum value More... | |
| #define | IGN_UINT32_MIN std::numeric_limits<uint32_t>::min() |
| 32bit unsigned integer minimum value More... | |
| #define | IGN_UINT64_INF std::numeric_limits<uint64_t>::infinity() |
| 64-bit unsigned integer positive infinite value More... | |
| #define | IGN_UINT64_LOW std::numeric_limits<uint64_t>::lowest() |
| 64bit unsigned integer lowest value. More... | |
| #define | IGN_UINT64_MAX std::numeric_limits<uint64_t>::max() |
| 64bit unsigned integer maximum value More... | |
| #define | IGN_UINT64_MIN std::numeric_limits<uint64_t>::min() |
| 64bit unsigned integer minimum value More... | |
| #define | IGNITION_HIDDEN |
| Use to represent "symbol hidden" if supported. More... | |
| #define | IGNITION_VISIBLE |
| Use to represent "symbol visible" if supported. More... | |
Typedefs | |
| using | ignition::math::PairInput = uint32_t |
| using | ignition::math::PairOutput = uint64_t |
Functions | |
| template<typename T > | |
| T | ignition::math::clamp (T _v, T _min, T _max) |
| Simple clamping function. More... | |
| template<typename T > | |
| bool | ignition::math::equal (const T &_a, const T &_b, const T &_epsilon=1e-6) |
| check if two values are equal, within a tolerance More... | |
| float | ignition::math::fixnan (float _v) |
| Fix a nan value. More... | |
| double | ignition::math::fixnan (double _v) |
| Fix a nan value. More... | |
| bool | ignition::math::isEven (const int _v) |
| Check if parameter is even. More... | |
| bool | ignition::math::isEven (const unsigned int _v) |
| Check if parameter is even. More... | |
| bool | ignition::math::isnan (float _v) |
| check if a float is NaN More... | |
| bool | ignition::math::isnan (double _v) |
| check if a double is NaN More... | |
| bool | ignition::math::isOdd (const int _v) |
| Check if parameter is odd. More... | |
| bool | ignition::math::isOdd (const unsigned int _v) |
| Check if parameter is odd. More... | |
| bool | ignition::math::isPowerOfTwo (unsigned int _x) |
| Is this a power of 2? More... | |
| template<typename T > | |
| T | ignition::math::max (const std::vector< T > &_values) |
| get the maximum value of vector of values More... | |
| template<typename T > | |
| T | ignition::math::mean (const std::vector< T > &_values) |
| get mean of vector of values More... | |
| template<typename T > | |
| T | ignition::math::min (const std::vector< T > &_values) |
| get the minimum value of vector of values More... | |
| PairOutput | ignition::math::Pair (const PairInput _a, const PairInput _b) |
| A pairing function that maps two values to a unique third value. More... | |
| double | ignition::math::parseFloat (const std::string &_input) |
| parse string into float More... | |
| int | ignition::math::parseInt (const std::string &_input) |
| parse string into an integer More... | |
| template<typename T > | |
| T | ignition::math::precision (const T &_a, const unsigned int &_precision) |
| get value at a specified precision More... | |
| unsigned int | ignition::math::roundUpPowerOfTwo (unsigned int _x) |
| Get the smallest power of two that is greater or equal to a given value. More... | |
| template<typename T > | |
| void | ignition::math::sort2 (T &_a, T &_b) |
| Sort two numbers, such that _a <= _b. More... | |
| template<typename T > | |
| void | ignition::math::sort3 (T &_a, T &_b, T &_c) |
| Sort three numbers, such that _a <= _b <= _c. More... | |
| std::tuple< PairInput, PairInput > | ignition::math::Unpair (const PairOutput _key) |
| The reverse of the Pair function. More... | |
| template<typename T > | |
| T | ignition::math::variance (const std::vector< T > &_values) |
| get variance of vector of values More... | |
Variables | |
| static const double | ignition::math::NAN_D = std::numeric_limits<double>::quiet_NaN() |
| Returns the representation of a quiet not a number (NAN) More... | |
| static const float | ignition::math::NAN_F = std::numeric_limits<float>::quiet_NaN() |
| Returns the representation of a quiet not a number (NAN) More... | |
| static const int | ignition::math::NAN_I = std::numeric_limits<int>::quiet_NaN() |
| Returns the representation of a quiet not a number (NAN) More... | |
| #define IGN_BOX_VOLUME | ( | _x, | |
| _y, | |||
| _z | |||
| ) | (_x *_y * _z) |
Compute box volume.
| [in] | _x | X length |
| [in] | _y | Y length |
| [in] | _z | Z length |
| #define IGN_BOX_VOLUME_V | ( | _v | ) | (_v.X() *_v.Y() * _v.Z()) |
Compute box volume from a vector.
| [in] | _v | Vector3d that contains the box's dimensions. |
| #define IGN_CYLINDER_VOLUME | ( | _r, | |
| _l | |||
| ) | (_l * IGN_PI * std::pow(_r, 2)) |
Compute cylinder volume.
| [in] | _r | Cylinder base radius |
| [in] | _l | Cylinder length |
| #define IGN_DBL_INF std::numeric_limits<double>::infinity() |
Double positive infinite value.
| #define IGN_DBL_LOW std::numeric_limits<double>::lowest() |
Double low value, equivalent to -IGN_DBL_MAX.
| #define IGN_DBL_MAX std::numeric_limits<double>::max() |
Double maximum value. This value will be similar to 1.79769e+308.
| #define IGN_DBL_MIN std::numeric_limits<double>::min() |
Double min value. This value will be similar to 2.22507e-308.
Referenced by ignition::math::Quaternion< double >::Integrate().
| #define IGN_FLT_INF std::numeric_limits<float>::infinity() |
Float positive infinite value.
| #define IGN_FLT_LOW std::numeric_limits<float>::lowest() |
Float lowest value, equivalent to -IGN_FLT_MAX.
| #define IGN_FLT_MAX std::numeric_limits<float>::max() |
Float maximum value. This value will be similar to 3.40282e+38.
| #define IGN_FLT_MIN std::numeric_limits<float>::min() |
Float minimum value. This value will be similar to 1.17549e-38.
| #define IGN_FP_VOLATILE |
Define IGN_FP_VOLATILE for FP equality comparisons Use volatile parameters when checking floating point equality on the 387 math coprocessor to work around bugs from the 387 extra precision.
Referenced by ignition::math::equal().
| #define IGN_INT16_INF std::numeric_limits<int16_t>::infinity() |
16-bit integer positive infinite value
| #define IGN_INT16_LOW std::numeric_limits<int16_t>::lowest() |
16bit integer lowest value.
This is equivalent to IGN_INT16_MIN, and is defined here for completeness.
| #define IGN_INT16_MAX std::numeric_limits<int16_t>::max() |
16bit integer maximum value
| #define IGN_INT16_MIN std::numeric_limits<int16_t>::min() |
16bit integer minimum value
| #define IGN_INT32_INF std::numeric_limits<int32_t>::infinity() |
32-bit integer positive infinite value
| #define IGN_INT32_LOW std::numeric_limits<int32_t>::lowest() |
32bit integer minimum value.
This is equivalent to IGN_INT32_MIN, and is defined here for completeness.
| #define IGN_INT32_MAX std::numeric_limits<int32_t>::max() |
32bit integer maximum value
| #define IGN_INT32_MIN std::numeric_limits<int32_t>::min() |
32bit integer minimum value
| #define IGN_INT64_INF std::numeric_limits<int64_t>::infinity() |
64-bit integer positive infinite value
| #define IGN_INT64_LOW std::numeric_limits<int64_t>::lowest() |
64bit integer lowest value.
This is equivalent to IGN_INT64_MIN, and is defined here for completeness.
| #define IGN_INT64_MAX std::numeric_limits<int64_t>::max() |
64bit integer maximum value
| #define IGN_INT64_MIN std::numeric_limits<int64_t>::min() |
64bit integer minimum value
| #define IGN_PI 3.14159265358979323846 |
Define IGN_PI, IGN_PI_2, and IGN_PI_4.
This was put here for Windows support.
Referenced by ignition::math::Quaternion< double >::Euler(), ignition::math::Matrix4< double >::EulerRotation(), ignition::math::OnePole< math::Quaterniond >::Fc(), ignition::math::BiQuad< math::Vector3d >::Fc(), and ignition::math::MassMatrix3< T >::PrincipalMoments().
| #define IGN_PI_2 1.57079632679489661923 |
Referenced by ignition::math::MassMatrix3< T >::PrincipalAxesOffset().
| #define IGN_PI_4 0.78539816339744830962 |
| #define IGN_SPHERE_VOLUME | ( | _radius | ) | (4.0*IGN_PI*std::pow(_radius, 3)/3.0) |
Compute sphere volume.
| [in] | _radius | Sphere radius |
| #define IGN_SQRT2 1.41421356237309504880 |
| #define IGN_UINT16_INF std::numeric_limits<uint16_t>::infinity() |
16-bit unsigned integer positive infinite value
| #define IGN_UINT16_LOW std::numeric_limits<uint16_t>::lowest() |
16bit unsigned integer lowest value.
This is equivalent to IGN_UINT16_MIN, and is defined here for completeness.
| #define IGN_UINT16_MAX std::numeric_limits<uint16_t>::max() |
16bit unsigned integer maximum value
| #define IGN_UINT16_MIN std::numeric_limits<uint16_t>::min() |
16bit unsigned integer minimum value
| #define IGN_UINT32_INF std::numeric_limits<uint32_t>::infinity() |
32-bit unsigned integer positive infinite value
| #define IGN_UINT32_LOW std::numeric_limits<uint32_t>::lowest() |
32bit unsigned integer lowest value.
This is equivalent to IGN_UINT32_MIN, and is defined here for completeness.
| #define IGN_UINT32_MAX std::numeric_limits<uint32_t>::max() |
32bit unsigned integer maximum value
| #define IGN_UINT32_MIN std::numeric_limits<uint32_t>::min() |
32bit unsigned integer minimum value
| #define IGN_UINT64_INF std::numeric_limits<uint64_t>::infinity() |
64-bit unsigned integer positive infinite value
| #define IGN_UINT64_LOW std::numeric_limits<uint64_t>::lowest() |
64bit unsigned integer lowest value.
This is equivalent to IGN_UINT64_MIN, and is defined here for completeness.
| #define IGN_UINT64_MAX std::numeric_limits<uint64_t>::max() |
64bit unsigned integer maximum value
| #define IGN_UINT64_MIN std::numeric_limits<uint64_t>::min() |
64bit unsigned integer minimum value
| #define IGNITION_HIDDEN |
Use to represent "symbol hidden" if supported.
| #define IGNITION_VISIBLE |
Use to represent "symbol visible" if supported.