I don't think mine is very complicated. I test to see which quadrant the point lies, then see if it's greater than the 45 degree line of said quadrant and return the appropriate angle. But for the second angle I make sure that if they are in the same quadrant, you get the second angle of the quadrant so that the same angle is not returned for both. You're welcome. This is a place of learning, so asking why one coded it a certain way is fine. I hope my explanation make sense to you (though it looks like you figured it out before I posted this message).