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 put into another rect?
This is a great question! If and only if one of these conditions is satisfied does a smaller rectangle with sides p
and q
(p >= q
) fit completely into a larger rectangle with sides a
and b
(a >= b
):
or
See this for reference.
So if we had variables a
, b
, p
, q
, we could check if such a rectangle arrangement would be possible by evaluating:
(p <= a && q <= b) || (p > a &&
b >= (2*p*q*a + (p*p-q*q)*sqrt(p*p+q*q-a*a)) / (p*p+q*q))
EDIT: Thanks to @amulware for posting this alternate version in his comment:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With