I need to get angle (0~359.99°) and distance from Vector2. Is there a common method for that somewhere in Math or XNA namespaces?
I’m not looking for a custom implementation, but an “official” one. It appears they are generally faster than custom ones.
The
Vector2.Lengthmethod returns the length of the vector (i.e. what you’ve called “distance”).To find the angle, use
Math.Atan2(P.Y, P.X).This angle will be measured in radians anti-clockwise relative to the positive X-axis (i.e. standard euclidian coordinates). Multiply the result by
180 / Math.PIto convert it to degrees.