Reputation: 70
i have some point on a circle and need to get angle of these points. I use math.atan()
or math.atan2()
functions but the angles are betweeen 0 and 90 or 0 and -90 i know that the math.atan()
function give me the values which are between pi/2 or -pi/2. as i wrote i need angles from 0 to 360.
at this point i need a help. Has anyone any idea about it ? Is there any way to do this?
deger=int(math.degrees(math.atan2(a2,a1)))
liste_tan.append(deger)
liste.append(math.sqrt((a1*a1)+(a2*a2)))
and my outputs like these; ( it has to be 90,91,92...270,271,272...359 degrees instead of -1 -2 -3 ...)
82 82 82 81 81 80 80 80 79 79 78 78 78 77 77 77 76 76 75 75 75 74 74 74 73 73 ....... 7 7 6 6 6 5 5 5 4 4 3 3 3 2 2 1 1 1 0 0 0 0 -1 -1 -1 -2 -2 -3 -3 -3 -4 -4 -5 -5 -5 -6 -6 -6 -7 -7 -8 -8 -8 -9 -9 -10 -10 -10 -11 -11 -12 -12 -12 -13 -13 -14 -14 -14 -15 -15 -15 -16 -16 -17 -17 -17 -18 -18 -19 -19 -20 -20 -20 -........ -74 -75 -75 -75 -76 -76 -77 -77 -77
Upvotes: 0
Views: 2295
Reputation:
atan2
returns angles in the range (-π, π]
. This covers the four quadrants. If you want a value in (0, 2π]
, it suffices to add 2π
to the non-positive angles. For the range [0, 2π)
, add 2π
to the negative only.
atan
can only cover two quadrants.
Note that in many cases, you can very well work with (-π, π]
, adjusting the range is unnecessary
Upvotes: 1