tags:

views:

995

answers:

4

I am using UIAcceleration for rotation. I have opposite side, adjacent side, but I want to calculate tan-1(y/x) inverse tan.

+4  A: 

The standard C math.h functions are available:

#include <math.h>

...
float theta = atan2f(y, x);
...
Louis Gerbarg
Note that in most atan2 functions, Y is the first parameter, not X
Sean
You are correct, fixed.
Louis Gerbarg
+3  A: 

atan2(y, x) is the same thing as atan(y/x), but it can deal properly with the case where x = 0 (i.e. a vertical line going up or down) without having do deal with positive vs. negative infinity.

David Maymudes
Note that in most atan2 functions, Y is the first parameter, not X
Sean
thanks, fixed it!
David Maymudes
+8  A: 
Jason S
Yes. Basically atan2 gets you into the correct quadrant.
Nosredna
Note that in most atan2 functions, Y is the first parameter, not X
Sean
Yay, edited. Now you get upvoted. :)
Sean
i got lazy and followed the other 2 answ w/o looking it up. thanks for the prod. :-)
Jason S
A: 

Thx for answer.. it was helpful .. SOLVED

Miky