let me start by stating that I'm terrible in math.
I'm trying to reposition and rotate a rectangular rectangular. However, I need to rotate the right-angled nick from a point that is not 0,0, but depending on how much its coordinates are shifted. I am sure that this does not make much sense, so I made a few sketches to explain what I need.

the image above shows 3 stages of a red rectangle moving from 0% to 100%. The X and Y coordinates of the red rectangle (at the top left of the red rectangle) move only as a percentage of the height of the blue rectangle.

red rectangle can rotate. focusing only on the middle example (“Distance -50%”) from above, where the red rectangle is moved at -50 the height of the blue rectangle, its new angular in the image above is now -45 º. he was rotated with 0, 0 points.

Now my problem is that I want its pivot point to reflect its position.
the red and blue rectangles are the same size but have the opposite width and height. Since the coordinates of the red rectangle 0.0 are now -50% of the height of the blue rectangle, and since they have the opposite width and height, I want the pivot point to be 50% of the width of the red rectangle (or 50% blue). the height of the rectangle, which is the same).
, angular 50% , , , , , X Y angular , .