SHARE
TWEET

Untitled

a guest Jul 19th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top