Detect if one rect can be put into another rect

后端 未结 4 1634
春和景丽
春和景丽 2021-02-13 06:39

This problem is different from testing if one rect is in another rect.

Known information is the sides length of two rects.

How to calculate if one rect can be pu

4条回答
  •  滥情空心
    2021-02-13 07:35

    You can weed out the two simple cases fairly easily:

    1. If the larger dimension of the second is smaller than the larger dimension of the first, and if the same is true for the smaller dimensions, then the second fits inside.
    2. If the larger dimension of the second is greater than the hypotenuse of the first, then the second will not fit in the first.

    The hard part is working out whether it can fit in at an angle such as in your sketch. I don't know of a simple formula -- it probably requires a plug-and-chug solution.

    Might be a good question for the Mathematics Stack Exchange site.

    Added: I'm not 100% sure if this, but I think that if the hypotenuse of the second is smaller than the hypotenuse of the first then it will fit.

    Oops: Nope -- I'll take that back. But if the hypotenuse of the second is larger than the hypotenuse of the first it won't fit.

提交回复
热议问题