Isis 3 Programmer Reference
Angle.h
Go to the documentation of this file.
1 #ifndef Angle_h
2 #define Angle_h
3 
4 #include <QtGlobal>
5 
28 #include <QGlobalStatic>
29 
30 class QString;
31 
32 namespace Isis {
33 
62  class Angle {
63 
64  public:
66  enum Units {
81  };
82 
83  Angle();
84  Angle(double angle, Units unit);
85  Angle(const Angle& angle);
86  Angle(QString angle);
87 
88  virtual ~Angle();
89 
90  // Class member operator functions
91  bool isValid() const;
92  static Angle fullRotation();
93 
100  Angle& operator=(const Angle& angle2) {
101  setAngle(angle2.radians(), Radians); return *this;
102  }
103 
104 
105  Angle operator+(const Angle& angle2) const;
106  Angle operator-(const Angle& angle2) const;
107  Angle operator*(double value) const;
108  friend Angle operator *(double mult, Angle angle);
109  Angle operator/(double value) const;
110  double operator/(Angle value) const;
111  bool operator<(const Angle& angle2) const;
112  bool operator>(const Angle& angle2) const;
113 
114 
121  void operator+=(const Angle& angle2) {
122  *this = *this + angle2;
123  };
124 
125 
132  void operator-=(const Angle& angle2) {
133  *this = *this - angle2;
134  };
135 
136 
143  Angle operator*(int value) const {
144  return *this * (double)value;
145  }
146 
147 
154  void operator*=(double value) {
155  *this = *this * value;
156  }
157 
158 
165  Angle operator/(int value) const {
166  return *this / (double)value;
167  }
168 
169 
175  void operator/=(double value) {
176  *this = *this / value;
177  }
178 
179  // Relational operator functions
180 
191  bool operator==(const Angle& angle2) const {
192  return qFuzzyCompare(angle(Radians), angle2.angle(Radians));
193  }
194 
195 
203  bool operator!=(const Angle& angle2) const {
204  return !(*this == angle2);
205  }
206 
207 
214  bool operator<=(const Angle& angle2) const {
215  return *this < angle2 || *this == angle2;
216  }
217 
218 
226  bool operator>=(const Angle& angle2) const {
227  return *this > angle2 || *this == angle2;
228  }
229 
230 
243  double radians() const { return angle(Radians); }
244 
249  double degrees() const { return angle(Degrees); }
250 
257 
264 
265  virtual QString toString(bool includeUnits = true) const;
266  double unitWrapValue(const Units& unit) const;
267  virtual double angle(const Units& unit) const;
268  virtual void setAngle(const double &angle, const Units& unit);
269 
270  private:
275  double m_radians;
276  };
277 }
278 
279 QDebug operator<<(QDebug dbg, const Isis::Angle &angleToPrint);
280 
281 #endif
Angle operator*(double value) const
Multiply this angle by a double and return the resulting angle.
Definition: Angle.cpp:169
Units
The set of usable angle measurement units.
Definition: Angle.h:66
void operator+=(const Angle &angle2)
Add angle value to another as double and replace original.
Definition: Angle.h:121
void setRadians(double radians)
Set the angle in units of Radians.
Definition: Angle.h:256
bool operator==(const Angle &angle2) const
Test if another angle is equal to this angle.
Definition: Angle.h:191
Angle operator-(const Angle &angle2) const
Subtract angle value from another and return the resulting angle.
Definition: Angle.cpp:151
void operator-=(const Angle &angle2)
Subtract angle value from another and set this instance to the resulting angle.
Definition: Angle.h:132
double radians() const
Convert an angle to a double.
Definition: Angle.h:243
virtual void setAngle(const double &angle, const Units &unit)
Set angle value in desired units.
Definition: Angle.cpp:338
void setDegrees(double degrees)
Set the angle in units of Degrees.
Definition: Angle.h:263
bool operator<=(const Angle &angle2) const
Test if the other angle is less than or equal to the current angle.
Definition: Angle.h:214
void operator/=(double value)
Divide this angle by a double and return the resulting angle.
Definition: Angle.h:175
double degrees() const
Get the angle in units of Degrees.
Definition: Angle.h:249
Angle operator+(const Angle &angle2) const
Add angle value to another.
Definition: Angle.cpp:133
Angle & operator=(const Angle &angle2)
Assign angle object equal to another.
Definition: Angle.h:100
Angle operator/(int value) const
Divide this angle by an integer and return the resulting angle.
Definition: Angle.h:165
Degrees are generally considered more human readable, 0-360 is one circle, however most math does not...
Definition: Angle.h:73
bool operator!=(const Angle &angle2) const
Test if another angle is not equal to this angle.
Definition: Angle.h:203
Angle()
Constructs a blank angle object which needs a value to be set in order to do any calculations.
Definition: Angle.cpp:38
virtual QString toString(bool includeUnits=true) const
Get the angle in human-readable form.
Definition: Angle.cpp:258
double unitWrapValue(const Units &unit) const
Return wrap value in desired units.
Definition: Angle.cpp:281
static Angle fullRotation()
Makes an angle to represent a full rotation (0-360 or 0-2pi).
Definition: Angle.cpp:121
Defines an angle and provides unit conversions.
Definition: Angle.h:62
bool operator<(const Angle &angle2) const
Test if the other angle is less than the current angle.
Definition: Angle.cpp:223
QDebug operator<<(QDebug dbg, const Isis::Angle &angleToPrint)
Display an Angle for a debugging statement.
Definition: Angle.cpp:383
Angle operator/(double value) const
Divide this angle by a double.
Definition: Angle.cpp:196
virtual ~Angle()
Destroys the angle object.
Definition: Angle.cpp:98
virtual double angle(const Units &unit) const
Return angle value in desired units.
Definition: Angle.cpp:304
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
bool isValid() const
This indicates whether we have a legitimate angle stored or are in an unset, or invalid, state.
Definition: Angle.cpp:110
Radians are generally used in mathematical equations, 0-2*PI is one circle, however these are more di...
Definition: Angle.h:80
Angle operator*(int value) const
Multiply this angle by an integer and return the resulting angle.
Definition: Angle.h:143
double m_radians
The angle measure, always stored in radians.
Definition: Angle.h:275
bool operator>=(const Angle &angle2) const
Test if the other angle is greater than or equal to the current angle.
Definition: Angle.h:226
void operator*=(double value)
Multiply this angle by a double and set this instance to the resulting angle.
Definition: Angle.h:154
bool operator>(const Angle &angle2) const
Test if the other angle is greater than the current angle.
Definition: Angle.cpp:241