Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define M_RAD 57.2957
- float getAngleByCoordinates(float x, float y)//zwraca kat miedzy osia y+ zgodnie z ruchem wskazowek zegara do punku (x,y)
- {
- if (x == 0)
- {
- if (y > 0) return 0.f;
- else return 180.f;
- }
- if (y == 0)
- {
- if (x > 0) return 90.f;
- else return 270.f;
- }
- if (x > 0 && y > 0) return 90.f - atan(fabs(y / x)) * M_RAD;
- if (x > 0 && y < 0) return 90.f + atan(fabs(y / x)) * M_RAD;
- if (x < 0 && y < 0) return 270.f - atan(fabs(y / x)) * M_RAD;
- if (x < 0 && y > 0) return 270.f + atan(fabs(y / x)) * M_RAD;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement