How to fit one irregular box inside another.

260 Views Asked by At

I have a box $B_1$ with sides of $2$, $2.5$ and $3$ units, and box $B_2$ with sides of $1140$, $890$, and $1120$ units.

$B_1$ is the bounding box of a rabbit mesh, an elephant mesh, etc, inside $B_2$ is a voxelized 3D fractal isosurface. I wish to multiply the voxelized rabbit with the fractal with maximum resolution, without chopping a part of the rabbit.

How can I find the correct ratio to multiply $B_1$ so that it fits perfectly (with matching maximum) inside of box $B_2$ while keeping the same ratio of either?

I have $N$ randomly sized bounding boxes which have different ratios every time. I wish to generalize the formula.

1

There are 1 best solutions below

0
On BEST ANSWER

Assuming you cannot rotate your boxes, you want to find

$$\min\left(\frac{1140}{2},\frac{890}{2.5},\frac{1120}{3}\right)$$

Here it is $356$, from the middle term. so if you multiply the sides of $B_2$ by $356$, you get an enlarged $712 \times 890 \times 1068$ box, which just fits in $B_1$.

If you can rotate your boxes, then sort the two sets of dimensions first and find $$\min\left(\frac{890}{2},\frac{1120}{2.5},\frac{1140}{3}\right)$$ to give $380$ from the right-hand term, and multiplying the sides of $B_2$ by $380$ gives you an enlarged $760 \times 950 \times 1140$ box, which with rotation just fits in $B_1$.