Calculate largest rectangle in a rotated rectangle

后端 未结 8 2289
你的背包
你的背包 2020-11-28 03:20

I\'m trying to find the best way to calculate the biggest (in area) rectangle which can be contained inside a rotated rectangle.

Some pictures should help (I hope) i

8条回答
  •  甜味超标
    2020-11-28 04:02

    Edit: My Mathematica answer below is wrong - I was solving a slightly different problem than what I think you are really asking.

    To solve the problem you are really asking, I would use the following algorithm(s):

    On the Maximum Empty Rectangle Problem

    Using this algorithm, denote a finite amount of points that form the boundary of the rotated rectangle (perhaps a 100 or so, and make sure to include the corners) - these would be the set S decribed in the paper.

    .

    .

    .

    .

    .

    For posterity's sake I have left my original post below:

    The inside rectangle with the largest area will always be the rectangle where the lower mid corner of the rectangle (the corner near the alpha on your diagram) is equal to half of the width of the outer rectangle.

    I kind of cheated and used Mathematica to solve the algebra for me:

    enter image description here

    From this you can see that the maximum area of the inner rectangle is equal to 1/4 width^2 * cosecant of the angle times the secant of the angle.

    Now I need to figure out what is the x value of the bottom corner for this optimal condition. Using the Solve function in mathematica on my area formula, I get the following:

    enter image description here

    Which shows that the x coordinate of the bottom corner equals half of the width.

    Now just to make sure, I'll going to test our answer empirically. With the results below you can see that indeed the highest area of all of my tests (definately not exhaustive but you get the point) is when the bottom corner's x value = half of the outer rectangle's width. enter image description here

提交回复
热议问题