Download

How to get left-handed atan2 rotation?

I have a vector that I have transformed to be relative to a horizon in the XY plane. I want to find the full angle (meaning the quadrant is important) between my vector and the +X axis which represents my horizon. atan2 is perfect for this… almost.

atan2 gives a result in the range (-180 to 180). The problem is the resulting numbers have a right handed rotation e.g. if my vector is (1, 1), atan2 yields 45 degrees, and atan2 with vector (0, 1) yields 90 degrees. In this case I would need the result of vector (1, 1) to be 135 instead of 45. I want a left handed rotation in order to be consistent with all the other rotations that I’m tracking (which are all left handed). How can I achieve this?

Solved by flipping the sign of the x parameter to atan2