Angle of line linking two points

 Let center.x and center.y be the center of the Cartesian plan. Let x1 and y1 be the coordinate of the point. The angle between (center.x, center.y) and (x1, y1) is:

(atan((y1-center.y)/(x1-center.x))+pi*(as.numeric((x1-center.x)<0))) %% (2*pi)

The 0 is at right of the center, pi is at left, pi/2 at the top and 3 pi/2 at the bottom.


Commentaires