= Solution
Translate the <vertex centroid> to the origin, rotate, and translate back:
``
rotatePoly :: Polygon -> Double -> Polygon
rotatePoly ps theta =
(translate c . map turn . translate (-cx,-cy)) ps
where
c@(cx,cy) = centroid ps
turn (x,y) = (cos theta*x + sin theta*y,
-sin theta*x + cos theta*y)
``
This follows the supplied <rotation matrix>, so \b[positive $\theta$ rotates clockwise] in the usual Cartesian axes. The opposite signs give the conventional counterclockwise matrix. Since the <vertex centroid> of the centered vertices is zero and a <linear map> commutes with their average, the final centroid remains `c`.
Back to article page