I need to calculate the angle between two vectors. The vectors may be pointing in any direction, and have been normalized. I want the angle to be measured clockwise from vectorA to vectorB in some cases, and anticlockwise from vectorA to vectorB in other cases (in other words, I don't just want to know the smallest angle).
Here's what I have
if (clockwise) angle = Math.atan2(vectorA.y, vectorA.x) - Math.atan2(vectorB.y, vectorB.x);
else angle = -1*(Math.atan2(vectorA.y, -vectorA.x) - Math.atan2(vectorB.y, -vectorB.x));
I guess this will never work for reflex angles? So how do I calculate an angle on the range 0->2pi?