Rotating a Polygon After Rotating a Background image

36 Views Asked by At

I'm trying to solve a coordinate transformation problem I'm having a hard time figuring out.

For context, I have an image, and on top of it I draw a polygon. (On the figure below you can assume the image is the gray and red shape, and the polygon is the cyan shape).

The image as a whole is rotated, so now the polygon does not match the position relative to the new rotated image.

My question is: how can I transform the points of the polygon so that they match the position relative to the new image coordinate system?

I have tried rotating the polygon 90 degrees relative to its centroid, but that gives me a polygon that has a bit of an offset from the position where it should be.

Here's a figure to describe the idea:

Example figure

Thanks a lot for the help!