OSVR-Core
Angles.h
Go to the documentation of this file.
1 
11 // Copyright 2015 Sensics, Inc.
12 //
13 // Licensed under the Apache License, Version 2.0 (the "License");
14 // you may not use this file except in compliance with the License.
15 // You may obtain a copy of the License at
16 //
17 // http://www.apache.org/licenses/LICENSE-2.0
18 //
19 // Unless required by applicable law or agreed to in writing, software
20 // distributed under the License is distributed on an "AS IS" BASIS,
21 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 // See the License for the specific language governing permissions and
23 // limitations under the License.
24 
25 #ifndef INCLUDED_Angles_h_GUID_DDFCCAF8_9ED0_4E85_62F3_173C073B8BB7
26 #define INCLUDED_Angles_h_GUID_DDFCCAF8_9ED0_4E85_62F3_173C073B8BB7
27 
28 // Internal Includes
29 // - none
30 
31 // Library/third-party includes
32 #include <boost/units/quantity.hpp>
33 #include <boost/units/systems/si/plane_angle.hpp>
34 #include <boost/units/systems/angle/degrees.hpp>
35 
36 // Standard includes
37 // - none
38 namespace osvr {
39 namespace util {
40  using boost::units::si::radians;
41  using boost::units::degree::degrees;
42 
45  template <typename System, typename Y = double>
46  using AngleGeneric = boost::units::quantity<
47  boost::units::unit<boost::units::plane_angle_dimension, System>, Y>;
48 
50  template <typename Y>
51  using AngleRadians =
52  boost::units::quantity<boost::units::si::plane_angle, Y>;
53 
55  template <typename Y>
56  using AngleDegrees =
57  boost::units::quantity<boost::units::degree::plane_angle, Y>;
58 
59  typedef AngleRadians<double> AngleRadiansd;
60  typedef AngleDegrees<double> AngleDegreesd;
61 
63  typedef AngleRadiansd Angle;
64 
66  template <typename System, typename Y>
67  inline Y getRadians(AngleGeneric<System, Y> const angle) {
68  const AngleRadians<Y> ret(angle);
69  return ret.value();
70  }
71 
73  template <typename System, typename Y>
74  inline Y getDegrees(AngleGeneric<System, Y> const angle) {
75  const AngleDegrees<Y> ret(angle);
76  return ret.value();
77  }
78 
79 } // namespace util
80 } // namespace osvr
81 #endif // INCLUDED_Angles_h_GUID_DDFCCAF8_9ED0_4E85_62F3_173C073B8BB7
AngleRadiansd Angle
Default angle type.
Definition: Angles.h:63
Definition: RunLoopManager.h:42
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
boost::units::quantity< boost::units::unit< boost::units::plane_angle_dimension, System >, Y > AngleGeneric
Convenience template alias for a plane_angle quantity in an arbitrary system with arbitrary scalar...
Definition: Angles.h:47
Y getDegrees(AngleGeneric< System, Y > const angle)
Get the raw scalar value of your angle in degrees.
Definition: Angles.h:74
Y getRadians(AngleGeneric< System, Y > const angle)
Get the raw scalar value of your angle in radians.
Definition: Angles.h:67
boost::units::quantity< boost::units::si::plane_angle, Y > AngleRadians
Alias for an angle in radians with arbitrary scalar type.
Definition: Angles.h:52
boost::units::quantity< boost::units::degree::plane_angle, Y > AngleDegrees
Alias for an angle in degrees with arbitrary scalar type.
Definition: Angles.h:57