libgdx/libgdx — pull request #2143 by Gtoknu (2014-07-21 08:34:22+00:00)
Title: Added angle calculation methods to Vector2

Added two methods to the Vector2 class, allowing to calculate angle between two vectors, and not only between the x-axis.

I'm not using the standard acos solution, math explained here: http://geomalgorithms.com/vector_products.html

Since the dot product is the cosine of the angle between two vectors, and the 2d cross product (perp dot) is the sine of the same angle, plugging both on a `atan2(crs, dot)` call can give the angle on the full circle (-180~+180, instead of `acos(dot)` solution, which gives only 0~180) and also avoid the two sqrts involved in normalising the vectors.

Here's another explanation on the matter: http://johnblackburne.blogspot.com.br/2012/01/angle-between-two-vectors.html