Suppose we have 2 rectangles in Cartesian coordinate system with (0,0) at the top left corner of the screen. Both of rectangles (a and b) at the same place. The first one has its origin point in top-left corner(A) and the second one in bottom-right point(B). Now I rotate them at 80 degrees CWW.

As we see b1 now has different position then a1. But in my case I need b1 will be at the same place as a1. So what a formula to recalculate position of a rectangle based on its origin point and angle? Thanks in advance!