Advertisement
Guest User

Untitled

a guest
Apr 4th, 2016
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. const double PI = 3.141592653589793238463;
  5. class Angle {
  6. private:
  7. int _minutes;
  8. public:
  9. Angle(int minutes) { _minutes = minutes; };
  10. double GetDegrees();
  11. double GetRadians();
  12. double GetSinus();
  13. static Angle& operator+(Angle& a1, Angle& a2);
  14. static Angle& operator-(Angle& a1, Angle& a2);
  15. static bool operator>(Angle& a1, Angle& a2);
  16. static bool operator<(Angle& a1, Angle& a2);
  17. };
  18. double Angle::GetDegrees() {
  19. double degrees = _minutes / 60 % 360; // Приводим к диапазону от -360 до 360.
  20. return degrees < 0 ? 360.0 + degrees : degrees; // Приводим градусы к диапазону 0-360.
  21. }
  22. double Angle::GetRadians() {
  23. return GetDegrees() * PI / 180.0;
  24. }
  25. double Angle::GetSinus() {
  26. return sin(GetRadians());
  27. }
  28.  
  29. Angle& Angle::operator+(Angle& a1, Angle& a2)
  30. {
  31. return Angle(a1._minutes+a2._minutes);
  32. }
  33.  
  34. Angle& Angle::operator-(Angle & a1, Angle & a2)
  35. {
  36. return Angle(a1._minutes - a2._minutes);
  37. }
  38.  
  39. bool Angle::operator>(Angle & a1, Angle & a2)
  40. {
  41. return a1._minutes > a2._minutes;;
  42. }
  43.  
  44. bool Angle::operator<(Angle & a1, Angle & a2)
  45. {
  46. return a1._minutes < a2._minutes;;
  47. }
  48.  
  49.  
  50.  
  51.  
  52. void main() {
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement