src
tools
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
16
#if __cplusplus < 201703L
17
21
double
hypot
(
double
x,
double
y,
double
z)
22
{
23
return
sqrt(x*x + y*y + z*z);
24
}
25
26
#endif // C++17
27
34
double
normalizeRadians
(
double
radians)
35
{
36
if
(std::abs(radians) >
PI
)
37
{
38
// For numerical stability we must use this sin/cos/atan2
39
// implementation even though it might consume more cycles.
40
// Note that radians = -pi converts to atan2(0,-1) = +pi!
41
radians = std::atan2 (std::sin(radians), std::cos(radians));
42
// radians now in (-pi,+pi]
43
}
44
if
(radians ==
PI
)
// equality of doubles ... just for the sake of completeness
45
{
46
// Convert half-open interval from (-pi,+pi] to [-pi,+pi)
47
radians = -
PI
;
48
}
49
return
radians;
50
}
hypot
double hypot(double x, double y, double z)
Definition:
MathToolbox.cpp:21
NaN_double
const double NaN_double
Not-a-Number in double precision.
Definition:
MathToolbox.cpp:13
normalizeRadians
double normalizeRadians(double radians)
Definition:
MathToolbox.cpp:34
MathToolbox.hpp
PI
#define PI
Definition:
BasicDatatypes.hpp:34
libsick_ldmrs
Author(s): SICK AG
, Martin Günther
, Jochen Sprickerhof
autogenerated on Wed Oct 26 2022 02:11:57