Skip to content

2D Coordinate Rotation

Published On:
Nov 13, 2014
Last Updated:
Nov 13, 2014

A 2D coordinate (x1,y1)(x_1, y_1) can be easily rotated by θ\theta around another point (xc,yc)(x_c, y_c) to give the new rotated point (x2,y2)(x_2, y_2) with the equation:

x2=(x1xc)cos(θ)(y1yc)sin(θ)+xcx_2 = (x_1 - x_c) cos(\theta) - (y_1 - y_c) sin(\theta) + x_c y2=(x1xc)sin(θ)+(y1yc)cos(θ)+ycy_2 = (x_1 - x_c) sin(\theta) + (y_1 - y_c) cos(\theta) + y_c

The angle θ\theta is positive for a counter-clockwise rotation. You may notice that the coordinate is translated as if (xc,yc)(x_c, y_c) was the origin, the rotation transformation is applied, and then it is translated back into position.