CMS 3D CMS Logo

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 long double piRadians(M_PIl); // M_PIl is long double version of pi
9  constexpr long double degPerRad = 180. / piRadians; // Degrees per radian
10 
11  namespace operators {
12 
13  // Angle
14  constexpr long double operator"" _pi(long double x) { return x * piRadians; }
15  constexpr long double operator"" _pi(unsigned long long int x) { return x * piRadians; }
16  constexpr long double operator"" _deg(long double deg) { return deg / degPerRad; }
17  constexpr long double operator"" _deg(unsigned long long int deg) { return deg / degPerRad; }
18  constexpr long 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 long double convertDegToRad(NumType degrees) // Degrees -> radians
28  {
29  return (degrees / degPerRad);
30  }
31  } // namespace operators
32 } // namespace angle_units
33 
34 #endif
degrees
double degrees(double radiants)
def degrees
Definition: EcalEleCalibLooper.cc:359
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
angle_units::operators::convertDegToRad
constexpr long double convertDegToRad(NumType degrees)
Definition: angle_units.h:27
angle_units::degPerRad
constexpr long double degPerRad
Definition: angle_units.h:9
angle_units::piRadians
constexpr long double piRadians(M_PIl)
angle_units
Definition: angle_units.h:6