Isis 3.0 Programmer Reference
Back | Home
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 
58  class Angle {
59 
60  public:
62  enum Units {
77  };
78 
79  Angle();
80  Angle(double angle, Units unit);
81  Angle(const Angle& angle);
82  Angle(QString angle);
83 
84  virtual ~Angle();
85 
86  // Class member operator functions
87  bool isValid() const;
88  static Angle fullRotation();
89 
96  Angle& operator=(const Angle& angle2) {
97  setAngle(angle2.radians(), Radians); return *this;
98  }
99 
100 
101  Angle operator+(const Angle& angle2) const;
102  Angle operator-(const Angle& angle2) const;
103  Angle operator*(double value) const;
104  friend Angle operator *(double mult, Angle angle);
105  Angle operator/(double value) const;
106  double operator/(Angle value) const;
107  bool operator<(const Angle& angle2) const;
108  bool operator>(const Angle& angle2) const;
109 
110 
117  void operator+=(const Angle& angle2) {
118  *this = *this + angle2;
119  };
120 
121 
128  void operator-=(const Angle& angle2) {
129  *this = *this - angle2;
130  };
131 
132 
139  Angle operator*(int value) const {
140  return *this * (double)value;
141  }
142 
143 
150  void operator*=(double value) {
151  *this = *this * value;
152  }
153 
154 
161  Angle operator/(int value) const {
162  return *this / (double)value;
163  }
164 
165 
171  void operator/=(double value) {
172  *this = *this / value;
173  }
174 
175  // Relational operator functions
176 
187  bool operator==(const Angle& angle2) const {
188  return qFuzzyCompare(angle(Radians), angle2.angle(Radians));
189  }
190 
191 
199  bool operator!=(const Angle& angle2) const {
200  return !(*this == angle2);
201  }
202 
203 
210  bool operator<=(const Angle& angle2) const {
211  return *this < angle2 || *this == angle2;
212  }
213 
214 
222  bool operator>=(const Angle& angle2) const {
223  return *this > angle2 || *this == angle2;
224  }
225 
226 
239  double radians() const { return angle(Radians); }
240 
245  double degrees() const { return angle(Degrees); }
246 
252  void setRadians(double radians) { setAngle(radians, Radians); }
253 
259  void setDegrees(double degrees) { setAngle(degrees, Degrees); }
260 
261  virtual QString toString(bool includeUnits = true) const;
262 
263  protected:
264  double unitWrapValue(const Units& unit) const;
265  virtual double angle(const Units& unit) const;
266  virtual void setAngle(const double &angle, const Units& unit);
267 
268  private:
273  double m_radians;
274  };
275 }
276 
277 QDebug operator<<(QDebug dbg, const Isis::Angle &angleToPrint);
278 
279 #endif
bool operator==(const Angle &angle2) const
Test if another angle is equal to this angle.
Definition: Angle.h:187
Angle operator*(int value) const
Multiply this angle by an integer and return the resulting angle.
Definition: Angle.h:139
Units
The set of usable angle measurement units.
Definition: Angle.h:62
Angle operator-(const Angle &angle2) const
Subtract angle value from another and return the resulting angle.
Definition: Angle.cpp:151
double degrees() const
Get the angle in units of Degrees.
Definition: Angle.h:245
void operator+=(const Angle &angle2)
Add angle value to another as double and replace original.
Definition: Angle.h:117
void setRadians(double radians)
Set the angle in units of Radians.
Definition: Angle.h:252
double radians() const
Convert an angle to a double.
Definition: Angle.h:239
void operator-=(const Angle &angle2)
Subtract angle value from another and set this instance to the resulting angle.
Definition: Angle.h:128
virtual void setAngle(const double &angle, const Units &unit)
Set angle value in desired units.
Definition: Angle.cpp:336
void setDegrees(double degrees)
Set the angle in units of Degrees.
Definition: Angle.h:259
Angle operator/(int value) const
Divide this angle by an integer and return the resulting angle.
Definition: Angle.h:161
void operator/=(double value)
Divide this angle by a double and return the resulting angle.
Definition: Angle.h:171
Angle & operator=(const Angle &angle2)
Assign angle object equal to another.
Definition: Angle.h:96
QDebug operator<<(QDebug dbg, const Isis::Angle &angleToPrint)
Display an Angle for a debugging statement.
Definition: Angle.cpp:379
Angle operator/(double value) const
Divide this angle by a double.
Definition: Angle.cpp:196
Degrees are generally considered more human readable, 0-360 is one circle, however most math does not...
Definition: Angle.h:69
virtual QString toString(bool includeUnits=true) const
Get the angle in human-readable form.
Definition: Angle.cpp:256
Angle()
Constructs a blank angle object which needs a value to be set in order to do any calculations.
Definition: Angle.cpp:38
Angle operator*(double value) const
Multiply this angle by a double and return the resulting angle.
Definition: Angle.cpp:169
bool operator>=(const Angle &angle2) const
Test if the other angle is greater than or equal to the current angle.
Definition: Angle.h:222
Angle operator+(const Angle &angle2) const
Add angle value to another.
Definition: Angle.cpp:133
bool isValid() const
This indicates whether we have a legitimate angle stored or are in an unset, or invalid, state.
Definition: Angle.cpp:110
static Angle fullRotation()
Makes an angle to represent a full rotation (0-360 or 0-2pi).
Definition: Angle.cpp:121
double unitWrapValue(const Units &unit) const
Return wrap value in desired units.
Definition: Angle.cpp:279
Defines an angle and provides unit conversions.
Definition: Angle.h:58
bool operator<(const Angle &angle2) const
Test if the other angle is less than the current angle.
Definition: Angle.cpp:223
virtual ~Angle()
Destroys the angle object.
Definition: Angle.cpp:98
bool operator>(const Angle &angle2) const
Test if the other angle is greater than the current angle.
Definition: Angle.cpp:240
Radians are generally used in mathematical equations, 0-2*PI is one circle, however these are more di...
Definition: Angle.h:76
virtual double angle(const Units &unit) const
Return angle value in desired units.
Definition: Angle.cpp:302
bool operator!=(const Angle &angle2) const
Test if another angle is not equal to this angle.
Definition: Angle.h:199
double m_radians
The angle measure, always stored in radians.
Definition: Angle.h:273
bool operator<=(const Angle &angle2) const
Test if the other angle is less than or equal to the current angle.
Definition: Angle.h:210
void operator*=(double value)
Multiply this angle by a double and set this instance to the resulting angle.
Definition: Angle.h:150

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:14:12