The problem is as follows: Given a 3d item and a list of 3d boxes, all rectangular cuboids, find the box with the smallest volume that can contain the given item. Only rotations by multiples of 90 degrees are allowed.
One solution is with the 3d range tree. Suppose a 3d object is defined with 3 dimensions (x, y, z)
where the dimensions are sorted: x <= y <= z
. Then a box (x1,y1,z1)
can contain an item (x2,y2,z2)
if x1 >= x2, y1 >= y2, and z1 >= z2
. Thus we can use a 3d range tree to find all boxes in the range {[x2, infinity], [y2, infinity], [z2, infinity]}
and return the one with the smallest volume. Is there a better or more efficient solution?
NOTE 1: related threads but not the same are 1, 2, 3.
NOTE 2: Looks like this problem can be classified under Constrained Nearest Neighbor search, see this paper.