For each do point:
alpha = arctan2(x, y) len = sqrt(x^2 + y^2) newX = len * cos(alpha + rotation) newy = len * sin(alpha + rotation)
The original [x, y] and new [newX, newY] coordinates are relative to the center of your rotation. If your original [x, y] is absolute, you need to calculate the relative first:
x = xAbs - xCenter y = yAbs - yCenter
Make sure your arctan2 function provides a PI / 2 or -PI / 2 result if x = 0. The primitive arctan functions do not allow x = 0.
source share