Isis 3 Programmer Reference
Angle.h
1 #ifndef Angle_h
2 #define Angle_h
3 
8 /* SPDX-License-Identifier: CC0-1.0 */
9 
10 #include <QtGlobal>
11 #include <QGlobalStatic>
12 
13 class QString;
14 
15 namespace Isis {
16 
45  class Angle {
46 
47  public:
49  enum Units {
63  Radians
64  };
65 
66  Angle();
67  Angle(double angle, Units unit);
68  Angle(const Angle& angle);
69  Angle(QString angle);
70 
71  virtual ~Angle();
72 
73  // Class member operator functions
74  bool isValid() const;
75  static Angle fullRotation();
76 
83  Angle& operator=(const Angle& angle2) {
84  setAngle(angle2.radians(), Radians); return *this;
85  }
86 
87 
88  Angle operator+(const Angle& angle2) const;
89  Angle operator-(const Angle& angle2) const;
90  Angle operator*(double value) const;
91  friend Angle operator *(double mult, Angle angle);
92  Angle operator/(double value) const;
93  double operator/(Angle value) const;
94  bool operator<(const Angle& angle2) const;
95  bool operator>(const Angle& angle2) const;
96 
97 
104  void operator+=(const Angle& angle2) {
105  *this = *this + angle2;
106  };
107 
108 
115  void operator-=(const Angle& angle2) {
116  *this = *this - angle2;
117  };
118 
119 
126  Angle operator*(int value) const {
127  return *this * (double)value;
128  }
129 
130 
137  void operator*=(double value) {
138  *this = *this * value;
139  }
140 
141 
148  Angle operator/(int value) const {
149  return *this / (double)value;
150  }
151 
152 
158  void operator/=(double value) {
159  *this = *this / value;
160  }
161 
162  // Relational operator functions
163 
174  bool operator==(const Angle& angle2) const {
175  return qFuzzyCompare(angle(Radians), angle2.angle(Radians));
176  }
177 
178 
186  bool operator!=(const Angle& angle2) const {
187  return !(*this == angle2);
188  }
189 
190 
197  bool operator<=(const Angle& angle2) const {
198  return *this < angle2 || *this == angle2;
199  }
200 
201 
209  bool operator>=(const Angle& angle2) const {
210  return *this > angle2 || *this == angle2;
211  }
212 
213 
226  double radians() const { return angle(Radians); }
227 
232  double degrees() const { return angle(Degrees); }
233 
240 
247 
248  virtual QString toString(bool includeUnits = true) const;
249  double unitWrapValue(const Units& unit) const;
250  virtual double angle(const Units& unit) const;
251  virtual void setAngle(const double &angle, const Units& unit);
252 
253  private:
258  double m_radians;
259  };
260 }
261 
262 QDebug operator<<(QDebug dbg, const Isis::Angle &angleToPrint);
263 
264 #endif
Isis::Angle::Degrees
@ Degrees
Degrees are generally considered more human readable, 0-360 is one circle, however most math does not...
Definition: Angle.h:56
Isis::Angle::operator*
Angle operator*(double value) const
Multiply this angle by a double and return the resulting angle.
Definition: Angle.cpp:154
Isis::Angle::operator-
Angle operator-(const Angle &angle2) const
Subtract angle value from another and return the resulting angle.
Definition: Angle.cpp:136
Isis::Angle::toString
virtual QString toString(bool includeUnits=true) const
Get the angle in human-readable form.
Definition: Angle.cpp:243
Isis::Angle::operator>
bool operator>(const Angle &angle2) const
Test if the other angle is greater than the current angle.
Definition: Angle.cpp:226
Isis::Angle::operator/=
void operator/=(double value)
Divide this angle by a double and return the resulting angle.
Definition: Angle.h:158
Isis::Angle::m_radians
double m_radians
The angle measure, always stored in radians.
Definition: Angle.h:258
Isis::Angle::operator>=
bool operator>=(const Angle &angle2) const
Test if the other angle is greater than or equal to the current angle.
Definition: Angle.h:209
Isis::Angle::unitWrapValue
double unitWrapValue(const Units &unit) const
Return wrap value in desired units.
Definition: Angle.cpp:266
Isis::Angle::operator+=
void operator+=(const Angle &angle2)
Add angle value to another as double and replace original.
Definition: Angle.h:104
Isis::Angle::operator/
Angle operator/(int value) const
Divide this angle by an integer and return the resulting angle.
Definition: Angle.h:148
Isis::Angle::operator<
bool operator<(const Angle &angle2) const
Test if the other angle is less than the current angle.
Definition: Angle.cpp:208
Isis::Angle::operator*
Angle operator*(int value) const
Multiply this angle by an integer and return the resulting angle.
Definition: Angle.h:126
Isis::Angle::operator==
bool operator==(const Angle &angle2) const
Test if another angle is equal to this angle.
Definition: Angle.h:174
Isis::Angle::Units
Units
The set of usable angle measurement units.
Definition: Angle.h:49
Isis::Angle
Defines an angle and provides unit conversions.
Definition: Angle.h:45
Isis::Angle::setRadians
void setRadians(double radians)
Set the angle in units of Radians.
Definition: Angle.h:239
Isis::Angle::operator-=
void operator-=(const Angle &angle2)
Subtract angle value from another and set this instance to the resulting angle.
Definition: Angle.h:115
Isis::Angle::~Angle
virtual ~Angle()
Destroys the angle object.
Definition: Angle.cpp:83
Isis::Angle::operator/
Angle operator/(double value) const
Divide this angle by a double.
Definition: Angle.cpp:181
Isis::Angle::isValid
bool isValid() const
This indicates whether we have a legitimate angle stored or are in an unset, or invalid,...
Definition: Angle.cpp:95
Isis::Angle::operator*=
void operator*=(double value)
Multiply this angle by a double and set this instance to the resulting angle.
Definition: Angle.h:137
Isis::Angle::Angle
Angle()
Constructs a blank angle object which needs a value to be set in order to do any calculations.
Definition: Angle.cpp:23
Isis::Angle::fullRotation
static Angle fullRotation()
Makes an angle to represent a full rotation (0-360 or 0-2pi).
Definition: Angle.cpp:106
Isis::Angle::operator+
Angle operator+(const Angle &angle2) const
Add angle value to another.
Definition: Angle.cpp:118
Isis::Angle::degrees
double degrees() const
Get the angle in units of Degrees.
Definition: Angle.h:232
Isis::Angle::setAngle
virtual void setAngle(const double &angle, const Units &unit)
Set angle value in desired units.
Definition: Angle.cpp:323
Isis::Angle::operator<=
bool operator<=(const Angle &angle2) const
Test if the other angle is less than or equal to the current angle.
Definition: Angle.h:197
Isis::Angle::operator!=
bool operator!=(const Angle &angle2) const
Test if another angle is not equal to this angle.
Definition: Angle.h:186
Isis::Angle::operator=
Angle & operator=(const Angle &angle2)
Assign angle object equal to another.
Definition: Angle.h:83
Isis::Angle::angle
virtual double angle(const Units &unit) const
Return angle value in desired units.
Definition: Angle.cpp:289
Isis::Angle::setDegrees
void setDegrees(double degrees)
Set the angle in units of Degrees.
Definition: Angle.h:246
Isis::Angle::Radians
@ Radians
Radians are generally used in mathematical equations, 0-2*PI is one circle, however these are more di...
Definition: Angle.h:63
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::Angle::radians
double radians() const
Convert an angle to a double.
Definition: Angle.h:226