USGS

Isis 3.0 Developer's Reference (API)

Home

Angle.h

Go to the documentation of this file.
00001 #ifndef Angle_h
00002 #define Angle_h
00003 
00025 namespace Isis {
00035   class Angle {
00036 
00037   public:
00039     enum Units {
00046       Degrees,
00053       Radians
00054     };
00055 
00056     Angle();
00057     Angle(double angle, Units unit);
00058     Angle(const Angle& angle);
00059 
00060     virtual ~Angle();
00061 
00062 
00063     // Class member operator functions 
00064     bool Valid() const;
00065 
00072     Angle& operator=(const Angle& angle2) { 
00073       SetAngle(angle2.GetRadians(), Radians); return *this;
00074     }
00075 
00076 
00077     Angle operator+(const Angle& angle2) const;
00078     Angle operator-(const Angle& angle2) const;
00079     Angle operator*(double value) const;
00080     friend Angle operator *(double mult, Angle angle);
00081     Angle operator/(double value) const;
00082     double operator/(Angle value) const;
00083     bool operator<(const Angle& angle2) const;
00084     bool operator>(const Angle& angle2) const;
00085 
00086 
00093     void operator+=(const Angle&  angle2) {
00094       *this = *this + angle2;
00095     };
00096 
00097 
00104     void operator-=(const Angle& angle2) {
00105       *this = *this - angle2;
00106     };
00107 
00108 
00115     Angle operator*(int value) const {
00116       return *this * (double)value;
00117     }
00118 
00119 
00126     void operator*=(double value) {
00127       *this = *this * value;
00128     }
00129 
00130 
00137     Angle operator/(int value) const {
00138       return *this / (double)value;
00139     }
00140 
00141 
00147     void operator/=(double value) {
00148       *this = *this / value;
00149     }
00150 
00151     // Relational operator functions
00152 
00163     bool operator==(const Angle& angle2) const {
00164       return (GetAngle(Radians) == angle2.GetAngle(Radians));
00165     }
00166 
00167 
00175     bool operator!=(const Angle& angle2) const {
00176       return !(*this == angle2);
00177     }
00178 
00179 
00186     bool operator<=(const Angle& angle2) const {
00187       return *this < angle2 || *this == angle2;
00188     }
00189 
00190 
00198     bool operator>=(const Angle& angle2) const {
00199       return *this > angle2 || *this == angle2;
00200     }
00201 
00202 
00214     double GetRadians() const { return GetAngle(Radians); }
00215 
00219     double GetDegrees() const { return GetAngle(Degrees); }
00220 
00226     void SetRadians(double radians) { SetAngle(radians, Radians); }
00227 
00233     void SetDegrees(double degrees) { SetAngle(degrees, Degrees); }
00234 
00235   protected:
00236     double UnitWrapValue(const Units& unit) const;
00237     virtual double GetAngle(const Units& unit) const;
00238     virtual void SetAngle(const double &angle, const Units& unit);
00239 
00240   private:
00245     double p_radians;
00246   };
00247 }
00248 
00249 #endif