DataFormats
Math
interface
angle_units.h
Go to the documentation of this file.
1
#ifndef DataFormats_Math_Angle_Units_h
2
#define DataFormats_Math_Angle_Units_h
3
4
#include <cmath>
5
6
namespace
angle_units
{
7
8
constexpr
double
piRadians
(
M_PI
);
9
constexpr
double
degPerRad
= 180. /
piRadians
;
// Degrees per radian
10
11
namespace
operators {
12
13
// Angle
14
constexpr
double
operator
""
_pi(
long
double
x) {
return
double(x) *
M_PI
; }
15
constexpr
double
operator
""
_pi(
unsigned
long
long
int
x) {
return
double(x) *
M_PI
; }
16
constexpr
double
operator
""
_deg(
long
double
deg) {
return
deg /
degPerRad
; }
17
constexpr
double
operator
""
_deg(
unsigned
long
long
int
deg) {
return
deg /
degPerRad
; }
18
constexpr
double
operator
""
_rad(
long
double
rad) {
return
rad * 1.; }
19
20
template
<
class
NumType>
21
inline
constexpr NumType
convertRadToDeg
(NumType radians)
// Radians -> degrees
22
{
23
return
(radians *
degPerRad
);
24
}
25
26
template
<
class
NumType>
27
inline
constexpr
double
convertDegToRad
(NumType
degrees
)
// Degrees -> radians
28
{
29
return
(
degrees
/
degPerRad
);
30
}
31
32
template
<
class
NumType>
33
typename
std::enable_if<!std::numeric_limits<NumType>::is_integer,
bool
>
::type
almostEqual
(NumType x,
34
NumType y,
35
int
ulp) {
36
return
std::fabs(x - y) <=
std::numeric_limits<NumType>::epsilon
() * std::fabs(x + y) * ulp ||
37
std::fabs(x - y) <
std::numeric_limits<NumType>::min
();
38
}
39
40
}
// namespace operators
41
}
// namespace angle_units
42
43
#endif
angle_units::operators::convertDegToRad
constexpr double convertDegToRad(NumType degrees)
Definition:
angle_units.h:27
degrees
double degrees(double radiants)
def degrees
Definition:
EcalEleCalibLooper.cc:359
min
T min(T a, T b)
Definition:
MathUtil.h:58
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition:
angle_units.h:21
angle_units::operators::almostEqual
std::enable_if<!std::numeric_limits< NumType >::is_integer, bool >::type almostEqual(NumType x, NumType y, int ulp)
Definition:
angle_units.h:33
geometryDiff.epsilon
int epsilon
Definition:
geometryDiff.py:26
type
type
Definition:
SiPixelVCal_PayloadInspector.cc:39
angle_units
Definition:
angle_units.h:6
M_PI
#define M_PI
Definition:
BXVectorInputProducer.cc:49
angle_units::piRadians
constexpr double piRadians(M_PI)
angle_units::degPerRad
constexpr double degPerRad
Definition:
angle_units.h:9
Generated for CMSSW Reference Manual by
1.8.16