Search code examples
python-3.xmathrectangles

Python | Rotate Rectangle and get new boundariy dimensions


So we got the rectangle A and we rotate it around its corner by x degree. Now I want to know how to calculate the boundaries of the new rectangle. What I mean with boundaries (blue rect): enter image description here

known values are inner rectangle width/height/center/corners Thanks in advance!


Solution

  • Bounding rectange has dimensions:

    New_Height = Old_Width * Abs(Sin(Fi)) + Old_Height * Abs(Cos(Fi))
    New_Width = Old_Width * Abs(Cos(Fi)) + Old_Height * Abs(Sin(Fi))