[Math] Rotate a point around a rectangle

rotations

This is kind of a strange problem so I'll do my best to describe it.

If you have a rectangle, the example I've been testing with is 13×8, and you have a point that is around the outside of the rectangle like the image below. The top left of the rect is at (0, 0).
rect1

How would you rotate the point around the rectangle 180 degrees so it now looks like this:
rect2

And in the opposite case how would you rotate to get it from the bottom right back to the top left? The data I have available is the current door location (the red dot), the size of the building (the black box), the location of the building (top left of the black box), and that the point will always be on the edge of a rectangle one size larger in both dimensions than the base rect. So the point in the example will always land on the edge of a 14×9 rectangle that is at (-1, -1).

Basically what this is being used for is to determine where the player needs to be to enter the door on a building, so when the building rotates 180 degrees the door location needs to move accordingly.

Best Answer

If I understand you correctly, you are rotating the point $(x,y)$ by 180 degrees around the centre of the rectangle. If that centre is at $(a,b)$, the rotation takes $(x,y)$ to $(2a-x, 2b-y)$.