Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #define M_RAD 57.2957
  2. float getAngleByCoordinates(float x, float y)//zwraca kat miedzy osia y+ zgodnie z ruchem wskazowek zegara do punku (x,y)
  3. {
  4. if (x == 0)
  5. {
  6. if (y > 0) return 0.f;
  7. else return 180.f;
  8. }
  9. if (y == 0)
  10. {
  11. if (x > 0) return 90.f;
  12. else return 270.f;
  13. }
  14. if (x > 0 && y > 0) return 90.f - atan(fabs(y / x)) * M_RAD;
  15. if (x > 0 && y < 0) return 90.f + atan(fabs(y / x)) * M_RAD;
  16. if (x < 0 && y < 0) return 270.f - atan(fabs(y / x)) * M_RAD;
  17. if (x < 0 && y > 0) return 270.f + atan(fabs(y / x)) * M_RAD;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement