My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
Angle.h
Go to the documentation of this file.
1 #ifndef GCP_UTIL_ANGLE_H
2 #define GCP_UTIL_ANGLE_H
3 
11 #include <cmath>
12 #include <string>
13 #include <iostream>
14 
15 #include "gcp/util/common/ConformableQuantity.h"
16 
17 namespace gcp {
18  namespace util {
19 
20  class Angle : public ConformableQuantity {
21  public:
22 
23  class Radians {};
24  class Degrees {};
25  class ArcSec {};
26  class ArcMinutes {};
27  class MilliArcSec {};
28 
32  Angle(bool modulo=false);
33 
37  Angle(std::string degrees, bool modulo=false);
38 
42  Angle(const Radians& units, double radians, bool modulo=false);
43  Angle(const Degrees& units, double degrees, bool modulo=false);
44  Angle(const MilliArcSec& units, double mas, bool modulo=false);
45  Angle(const ArcSec& units, double as, bool modulo=false);
46  Angle(const ArcMinutes& units, double am, bool modulo=false);
47 
48  Angle(Angle& angle);
49  Angle(const Angle& angle);
50  void operator=(Angle& angle);
51  void operator=(const Angle& angle);
52 
56  virtual ~Angle();
57 
61  void setRadians(double radians);
62  void setDegrees(double degrees);
63  void setDegrees(double degrees, double arcmin, double arcsec);
64  void setArcMinutes(double am);
65  void setMas(double mas);
66  void setArcSec(double as);
67  void setDegrees(std::string degrees);
68 
72  virtual void addRadians(double radians);
73  virtual void addDegrees(double degrees);
74  virtual void addDegrees(std::string degrees);
75 
79  inline double radians() {
80  return radians_;
81  }
82 
83  inline double degrees() {
84  return radians_ * degPerRad_;
85  }
86 
87  inline double arcsec() {
88  return radians_ * arcSecPerRad_;
89  }
90 
91  inline double arcmin() {
92  return radians_ * arcMinPerRad_;
93  }
94 
95  inline double mas() {
96  return radians_ * masPerRad_;
97  }
98 
99  std::string strDegrees();
100 
104  friend std::ostream& operator<<(std::ostream& os, Angle& angle);
105 
109  Angle operator+(Angle& angle);
110 
114  Angle operator-(Angle& angle);
115 
119  void operator/=(unsigned uval);
120 
124  Angle operator/(unsigned uval);
125 
129  bool operator>(Angle& angle);
130  bool operator>(const Angle& angle);
131  bool operator>=(Angle& angle);
132  bool operator<(Angle& angle);
133  bool operator<(const Angle& angle);
134  bool operator<=(Angle& angle);
135 
136  //------------------------------------------------------------
137  // Public utility methods
138 
142  static double sexagesimalToDouble(std::string valStr);
143 
147  static std::string doubleToSexagesimal(double val);
148 
149  static const double pi_;
150  static const double twoPi_;
151 
152  static const double degPerRad_;
153  static const double arcSecPerDegree_;
154  static const double masPerDegree_;
155  static const double arcSecPerRad_;
156  static const double arcMinPerRad_;
157  static const double masPerRad_;
158 
159  void initialize();
160 
161  protected:
162 
163  Angle(double radians, bool modulo);
164 
165  double radians_; // The radian representation of this angle
166  bool modulo_; // True if this angle should be manipulated
167  // modulo twoPi_
168 
169  }; // End class Angle
170 
171  } // End namespace util
172 } // End namespace gcp
173 
174 
175 
176 #endif // End #ifndef GCP_UTIL_ANGLE_H
Definition: Angle.h:25
Angle operator-(Angle &angle)
Definition: Angle.cc:331
friend std::ostream & operator<<(std::ostream &os, Angle &angle)
Definition: Angle.h:23
Definition: ConformableQuantity.h:16
void setDegrees(double degrees)
Definition: Angle.cc:106
void setArcSec(double as)
Definition: Angle.cc:146
Definition: Angle.h:27
void operator/=(unsigned uval)
Definition: Angle.cc:339
virtual ~Angle()
Definition: Angle.cc:72
Angle operator/(unsigned uval)
Definition: Angle.cc:344
Definition: Angle.h:26
Angle operator+(Angle &angle)
Definition: Angle.cc:320
bool operator>(Angle &angle)
Definition: Angle.cc:354
void setRadians(double radians)
Definition: Angle.cc:97
void setArcMinutes(double am)
Definition: Angle.cc:138
Definition: Angle.h:20
virtual void addRadians(double radians)
Definition: Angle.cc:162
void setMas(double mas)
Definition: Angle.cc:154
std::string strDegrees()
Definition: Angle.cc:193
Angle(bool modulo=false)
Definition: Angle.cc:24
static double sexagesimalToDouble(std::string valStr)
Definition: Angle.cc:211
virtual void addDegrees(double degrees)
Definition: Angle.cc:177
static std::string doubleToSexagesimal(double val)
Definition: Angle.cc:266
double radians()
Definition: Angle.h:79
Definition: Angle.h:24