Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- const double PI = 3.141592653589793238463;
- class Angle {
- private:
- int _minutes;
- public:
- Angle(int minutes) { _minutes = minutes; };
- double GetDegrees();
- double GetRadians();
- double GetSinus();
- static Angle& operator+(Angle& a1, Angle& a2);
- static Angle& operator-(Angle& a1, Angle& a2);
- static bool operator>(Angle& a1, Angle& a2);
- static bool operator<(Angle& a1, Angle& a2);
- };
- double Angle::GetDegrees() {
- double degrees = _minutes / 60 % 360; // Приводим к диапазону от -360 до 360.
- return degrees < 0 ? 360.0 + degrees : degrees; // Приводим градусы к диапазону 0-360.
- }
- double Angle::GetRadians() {
- return GetDegrees() * PI / 180.0;
- }
- double Angle::GetSinus() {
- return sin(GetRadians());
- }
- Angle& Angle::operator+(Angle& a1, Angle& a2)
- {
- return Angle(a1._minutes+a2._minutes);
- }
- Angle& Angle::operator-(Angle & a1, Angle & a2)
- {
- return Angle(a1._minutes - a2._minutes);
- }
- bool Angle::operator>(Angle & a1, Angle & a2)
- {
- return a1._minutes > a2._minutes;;
- }
- bool Angle::operator<(Angle & a1, Angle & a2)
- {
- return a1._minutes < a2._minutes;;
- }
- void main() {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement