Skip to main content

Rotation about a pivot point

Short answer

Rotation about pivot (xr,yr) is M=T(xr,yr)*R(-theta)*T(-xr,-yr) with R(-theta)=[[cos theta, sin theta,0],[-sin theta, cos theta,0],[0,0,1]]. Thus x'=xr+(x-xr)cos theta+(y-yr)sin theta, y'=yr-(x-xr)sin theta+(y-yr)cos theta; for counter-clockwise replace theta by -theta.

Derive the 2D transformation matrix for rotating an object by angle θ about a pivot point (xr, yr) (composite matrix for rotation about an arbitrary point, clockwise).

To rotate an object about a pivot point (xr, yr), the pivot is first moved to the origin, the object is rotated about the origin, and then the pivot is moved back. This is a composite transformation of three basic transformations.

Basic matrices (homogeneous, column vectors)

For clockwise rotation by θ, the angle is −θ in the standard (counter-clockwise positive) convention:

Rotation about origin, clockwise θ:
   R(−θ) = |  cosθ  sinθ  0 |
           | −sinθ  cosθ  0 |
           |   0     0    1 |
Translation T(tx, ty) = | 1 0 tx |
                        | 0 1 ty |
                        | 0 0  1 |

Steps

  1. Translate the pivot to the origin: T(−xr, −yr)
  2. Rotate about the origin: R(−θ)
  3. Translate back: T(xr, yr)
M = T(xr, yr) · R(−θ) · T(−xr, −yr)

    | 1 0 xr |   |  cosθ  sinθ 0 |   | 1 0 −xr |
  = | 0 1 yr | · | −sinθ  cosθ 0 | · | 0 1 −yr |
    | 0 0  1 |   |   0     0   1 |   | 0 0   1  |

Multiplying the last two matrices first:

 |  cosθ  sinθ  −xr·cosθ − yr·sinθ |
 | −sinθ  cosθ   xr·sinθ − yr·cosθ |
 |   0     0              1        |

Then adding the translation by (xr, yr):

        |  cosθ   sinθ   xr(1 − cosθ) − yr·sinθ |
   M =  | −sinθ   cosθ   yr(1 − cosθ) + xr·sinθ |
        |   0      0               1            |

So a point P(x, y) goes to x' = xr + (x − xr)cosθ + (y − yr)sinθ y' = yr − (x − xr)sinθ + (y − yr)cosθ

Check: for (x, y) = (xr, yr): x' = xr, y' = yr, so the pivot does not move. For counter-clockwise rotation, replace θ by −θ (the sign of the sinθ terms changes).

✓ Answer checked by Claude Opus 5.5 (high effort)

All Computer Graphics chapter 3 questions →