MathToolbox.cpp
Go to the documentation of this file.
1 //
2 // MathToolbox.cpp
3 //
4 //
5 // Math functions.
6 //
8 
9 #include "MathToolbox.hpp"
10 #include <limits>
11 
12 
13 const double NaN_double = std::numeric_limits<double>::quiet_NaN();
14 //const float NaN = std::numeric_limits<float>::quiet_NaN();
15 
19 double hypot(double x, double y, double z)
20 {
21  return sqrt(x*x + y*y + z*z);
22 }
23 
24 
31 double normalizeRadians (double radians)
32 {
33  if (std::abs(radians) > PI)
34  {
35  // For numerical stability we must use this sin/cos/atan2
36  // implementation even though it might consume more cycles.
37  // Note that radians = -pi converts to atan2(0,-1) = +pi!
38  radians = std::atan2 (std::sin(radians), std::cos(radians));
39  // radians now in (-pi,+pi]
40  }
41  if (radians == PI) // equality of doubles ... just for the sake of completeness
42  {
43  // Convert half-open interval from (-pi,+pi] to [-pi,+pi)
44  radians = -PI;
45  }
46  return radians;
47 }
const double NaN_double
Not-a-Number in double precision.
Definition: MathToolbox.cpp:13
double hypot(double x, double y, double z)
Definition: MathToolbox.cpp:19
double normalizeRadians(double radians)
Definition: MathToolbox.cpp:31
#define PI


libsick_ldmrs
Author(s): SICK AG , Martin Günther , Jochen Sprickerhof
autogenerated on Sat Jun 8 2019 17:57:33