How to fit one irregular box inside another.

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.

• B1 already fits inside B2 - do you wish to find the largest scaling factor such that it still fits? Is that what you mean by perfectly? What exactly is your goal when you have N boxes? I think you need to define your problem more precisely. Mar 30, 2017 at 10:23
• Thanks a lot, i wrote more information in the first paragraph. Mar 30, 2017 at 10:35

$$\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$.