If r is the distance from the origin, and a is the angle (in radians) between the x axis and the point, you can easily calculate the coordinates with a transformation from polar coordinates:
x = r*cos(a) y = r*sin(a)
(this assumes that the origin is placed at (0,0) , otherwise you must add the offset to the final result).
The opposite result is obtained by calculating modulo the vector (since the distance + angle is the vector) and arctangent, which can be calculated using the atan2 function.
r = sqrt(x*2+y*2) a = atan2(y,x)
Jack
source share