When calculating the angle between two vectors, I have traditionally used acos, but this requires the two vectors to be normalised. atan2 can be used to accomplish the same (specifically atan2(b.y_, b.x_) - atan2(a.y_, a.x_)
), does this require normalised vectors?
If atan2 doesn't require normalised vectors, would this be better to use since normalisation can be costly and 'more' error prone since it requires a sqrt operation?
Then I read that atan2 itself can be more costly than acos, but more accurate? And then I also read other interwebs suggesting the opposite :( lots of conflicting information, unsure what the deal is with using acos or atan for calculating the angle between two vectors.
Which is recommeneded? and what are the benefits/issues for each usage?
Any help would be appreciated, thanks!
No, atan2
does not require normalized vectors, and if your vectors are not already normalized you shouldn't pre-normalize them as that may slightly reduce precision. The function works correctly for any inputs other than (0,0).
You should never use acos
for anything.