rapid
A ROS robotics library.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
deg_rad.h
Go to the documentation of this file.
1 #ifndef _RAPID_UTILS_DEG_RAD_H_
2 #define _RAPID_UTILS_DEG_RAD_H_
3 
4 // Types for degrees and radians.
5 //
6 // Most algorithms use radians, but simply taking in arguments as doubles can be
7 // confusing. Using these types, an algorithm can explicitly document that it
8 // takes in degrees or radians:
9 //
10 // head.PanTilt(rapid::Radians(0.707), rapid::Radians(0.5));
11 //
12 // We also allow users to implicitly convert degrees to radians. For example, if
13 // PanTilt takes in radians, users can nonetheless pass in degrees and have the
14 // conversion taken care of for them:
15 //
16 // head.PanTilt(rapid::Degrees(45), rapid::Degrees(30));
17 
18 namespace rapid {
23 class Degrees {
24  public:
28  explicit Degrees(double degrees);
29 
31  double value() const;
32 
33  private:
34  double degrees_;
35 };
36 
43 class Radians {
44  public:
48  explicit Radians(double radians);
49 
61  Radians(const Degrees& degrees);
62 
64  double value() const;
65 
66  private:
67  double radians_;
68 };
69 
70 } // namespace rapid
71 
72 #endif // _RAPID_UTILS_DEG_RAD_H_
Type for angles measured in radians.
Definition: deg_rad.h:43
double value() const
Type for angles measured in degrees.
Definition: deg_rad.h:23
double value() const
Radians(double radians)
Constructor.
Degrees(double degrees)
Constructor.