00001 #ifndef _DLANGLE_H 00002 #define _DLANGLE_H 00003 00011 class DLAngle 00012 { 00013 friend DLAngle operator+ (const DLAngle & p1, const DLAngle & p2); 00014 friend DLAngle operator- (const DLAngle & p1, const DLAngle & p2); 00015 00016 public: 00017 00021 DLAngle() 00022 : angle(0.0), specialType(DL_ARBITRARY) 00023 { ; } 00024 00029 DLAngle(const DLAngle & orig) { *this = orig; } 00030 00035 const DLAngle & operator=(const DLAngle & right) 00036 { 00037 this->angle = right.angle; 00038 this->specialType = right.specialType; 00039 return *this; 00040 } 00041 00045 virtual ~DLAngle() { ; } 00046 00051 DLAngle(double radians); 00052 00056 enum DLAngleUnits { 00057 DL_DEGREES, 00058 DL_RADIANS, 00059 DL_GRADS 00060 }; 00061 00085 enum DLSpecialAngleType { 00091 DL_ARBITRARY, 00092 00094 DL_ZERO_ANGLE, 00095 00097 DL_45_DEGREE_ANGLE, 00098 00100 DL_RIGHT_ANGLE, 00101 00103 DL_135_DEGREE_ANGLE, 00104 00106 DL_STRAIGHT_ANGLE 00107 }; 00108 00112 enum DLQuadrant { 00118 DL_QUADRANT_UNDEFINED, 00119 00121 DL_QUADRANT_I, 00122 00124 DL_QUADRANT_II, 00125 00127 DL_QUADRANT_III, 00128 00130 DL_QUADRANT_IV 00131 }; 00132 00144 DLAngle(double value, DLAngleUnits units); 00145 00150 DLAngle(double degrees, double minutes, double seconds); 00151 00161 DLAngle(DLSpecialAngleType type); 00162 00166 double dlRadians() const; 00167 00171 double dlDegrees() const; 00172 00176 double dlGrads() const; 00177 00185 bool dlIsSpecial() const; 00186 00190 DLSpecialAngleType dlGetSpecialAngleType() const { return specialType; } 00191 00195 DLQuadrant dlQuadrant() const; 00196 00201 const DLAngle & operator +=(const DLAngle & p2); 00202 00207 const DLAngle & operator -=(const DLAngle & p2); 00208 00212 inline const DLAngle operator-() const 00213 { 00214 return DLAngle(-this->angle); 00215 } 00216 00222 inline const DLAngle operator+() const 00223 { 00224 return *this; 00225 } 00226 00233 inline bool operator==(const DLAngle & p2) const 00234 { 00235 return (this->angle == p2.angle && this->specialType == p2.specialType); 00236 } 00237 00252 inline operator double() const { return angle; } 00253 00257 void dlReduce(); 00258 00259 private: 00260 static inline double degrees2radians(double degrees); 00261 static inline double grads2radians(double grads); 00262 static inline double radians2degrees(double radians); 00263 static inline double radians2grads(double radians); 00264 00267 double angle; 00268 00270 DLSpecialAngleType specialType; 00271 }; 00272 00274 DLAngle operator+ (const DLAngle & p1, const DLAngle & p2); 00275 00277 DLAngle operator- (const DLAngle & p1, const DLAngle & p2); 00278 00279 #endif