impressive_i

Angles

Apr 18th, 2021
974
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. #define PI 3.1415926535
  7.  
  8. int getAngle(double x, double y){
  9.    double fi = atan2( y , x);
  10.    if (fi > 0){
  11.        return (int) (fi * (180.0 / PI));
  12.    } else {
  13.        return 360 + (int) (fi * (180.0 / PI));
  14.    }
  15. }
  16.  
  17. int main() {
  18.     double x = -1;
  19.     double y = -1;
  20.     cout << getAngle(x, y) << endl;
  21.     return 0;
  22. }
  23.  
  24.  
Advertisement
Add Comment
Please, Sign In to add comment