I will explain in SIMPLE TERMS this way.
Refer to this image for the following explanation:

Task: Choose a function that will track the correct angle across a range -180 < θ < 180
Trial 1:
sin()
is positive in the first and second quadrants, sin(30) = sin(150) = 0.5
. It won't be easy to track quadrant change with sin()
.
Therefore, asin2()
is not feasible.
Trial 2:
cos()
is positive in the first and fourth quadrants, cos(60) = sin(300) = 0.5
. Also, it won't be easy to track quadrant change with cos()
.
Therefore, acos2()
is again not feasible.
Trial 3:
tan()
is positive in the first and third quadrants, and in an interesting order.
It is positive in the 1st quadrant, negative in the 2nd, positive in the 3rd, negative in the 4th, and positive in the wrapped-around-1st quadrant.
such that tan(45) = 1
, tan(135) = -1
, tan(225) = 1
, tan(315) = -1
, and tan(360+45) = 1
. Hurray! we can track quadrant change.
Notice that the unambiguous range is -180 < θ < 180
. Also, note in my 45-degree-increment example above, if the sequence is 1,-1,..
the angle goes counter-clockwise, and if the sequence is -1,1,..
it goes clockwise. This idea should resolve directionality.
Therefore, atan2()
BECOMES OUR CHOICE.