Skip to main content

2D Coordinate Rotation

Geoffrey Hunter
mbedded.ninja Author
warning
This page is in notes format, and may not be of the same quality as other pages on this site.

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.