Rotating irregular figure

Hello i’m trying to rotate a type of rectangle that’s an irregular figure, this is a museum extension proposal, the rectangle is suposed to go through the line (image1), then it’s supossed to twist (image2), that’s my problem, i don’t know how to twist it, im doing it in grasshopper so you can see my modest algorithm,
concepto (34.7 KB)
but that’s my problem, anybody got a solution?