MathToolbox.hpp
Go to the documentation of this file.
```00001 //
00002 // MathToolbox.hpp
00003 //
00004 //
00005 // Math functions and definitions.
00006 //
00008
00009 #if !defined(MATHTOOLBOX_HPP)
00010 #define MATHTOOLBOX_HPP
00011
00012 #include <math.h>
00013 #include <cmath>        // for abs()
00014 #include "../BasicDatatypes.hpp"
00015
00016
00017 extern double hypot(double x, double y, double z);
00018
00020 extern const double NaN_double;
00021
00023
00028 inline bool fuzzyCompare (double a, double b)
00029 {
00030         return std::abs(a - b) < 1E-11;
00031 }
00032
00033 //
00034 // Square
00035 //
00036 inline double sqr(double val)
00037 {
00038         return val * val;
00039 }
00040
00042
00047 inline bool fuzzyCompare(float a, float b)
00048 {
00049         return std::abs(a - b) < 1E-6f;
00050 }
00051
00052
00053 // Normalizes an angle in radians to the interval [-pi,+pi)
00055
00057
00062 template<typename floatT>
00063 inline bool isNaN (floatT x)
00064 {
00065         return (x != x);
00066 }
00067
00069
00073 template<typename IntT>
00074 inline IntT round_to_int (float floatValue)
00075 {
00076
00077         //      assert (std::numeric_limits<float>::round_style == std::round_toward_zero);
00078         //      static_cast<IntT>() rounds toward zero
00079         return IntT (floatValue + (floatValue >= 0.0f ? + 0.5f : -0.5f));
00080 }
00081
00083
00087 template<typename IntT>
00088 inline IntT round_to_int (double floatValue)
00089 {
00090
00091         //      assert (std::numeric_limits<double>::round_style == std::round_toward_zero);
00092         //      static_cast<IntT>() rounds toward zero
00093         return IntT (floatValue + (floatValue >= 0.0 ? + 0.5 : -0.5));
00094 }
00095
00096
00097 #endif // MATHTOOLBOX
```

libsick_ldmrs
Author(s): SICK AG , Martin Günther , Jochen Sprickerhof
autogenerated on Wed Jun 14 2017 04:04:50