The atan2 Function
Introduce the atan2 function which helps us overcome ambiguities in inverse tangent functions and its advantages.
Recall the arctangent fuction:
In fact, the atan function can not distinguish between any pair of points opposite from each other on the unit circle. This is ambiguous!
Also the atan function is undefined in two poles:
We can use atan2 function to solve this proplem:
The atan2 function will return angles in the entire range of 0 to 2 pi.
Ref: The atan2 Function