user1256183
user1256183

Reputation: 11

Check to see if box fits in another box

Given LxWxH of a box A, and LxWxH of a box B, how can I do a simple check to see if A fits in B (with 90 degrees rotations if necessary)? I'm trying to avoid checking all the possible permutations. Thanks.

Upvotes: 1

Views: 2873

Answers (1)

Dr.Tower
Dr.Tower

Reputation: 995

I would check to see if

minimum dimension of A < minimum dimension of B &&
median dimension of A < median dimension of B  &&
maximum dimension of A < maximum dimension of B 

If those 3 conditions are met, A fits in B.

Upvotes: 10

Related Questions