I’m sure everyone of you got livid with the return value of the
atan2 functions. Here is a fix.
This is Java code, but easy to adapt for other languages. And since you are here, a little hint: Multiply the result with
180 / Math.PI to receive the angle in degrees.