TITLE: How to check if a box fits in a box?
QUESTION [28 upvotes]: How could I calculate if a rectangular cuboid fits in an other rectangular cuboid, it may rotate or be placed in any way inside the bigger one.
For example would, (650,220,55) fit in (590,290,160), they are all mm.

REPLY [8 votes]: This could also be solved by quantifier elimination, and perhaps someone with more knowledge of quantifier elimination can see how to do it feasibly.
A box of side lengths $(a,b,c)$ fits inside a box of side lengths $(x,y,z)$ iff there are vectors $(\mathbf{t},\mathbf u,\mathbf{v})$ for the sides satisfying:
\begin{gather*}
\begin{aligned}
\mathbf{t}\cdot\mathbf{t}=a^2,&& &
\mathbf{u}\cdot\mathbf{u}=b^2,&&
\mathbf{v}\cdot\mathbf{v}=c^2, \\
\mathbf{t}\cdot\mathbf{u}=0,&&&
\mathbf{u}\cdot\mathbf{v}=0,&&
\mathbf{v}\cdot\mathbf{t}=0,
\end{aligned} \\
\pm\mathbf{t} \pm \mathbf{u} \pm \mathbf{v} \le (x,y,z)
\end{gather*}
where the last line represents three coordinate inequalities for each choice of signs. In other words, we are checking a statement of the form $\exists t_i t_j t_k u_i u_j u_k v_i v_j v_k\ \phi$, where $\phi$ is the conjunction of 6 equalities and 24 inequalities in those 9 bound variables and in $a$, $b$, $c$, $x$, $y$, $z$.
Quantifier elimination should then provide some list of polynomial inequalities in $a$, $b$, $c$, $x$, $y$, $z$ which together are equivalent to the small box fitting inside the large box.
Update: This works in the 2-d case, with interesting results. Assuming that $0<a<b$ and $0<x<y$, the $a\times b$ rectangle can fit inside the $x\times y$ rectangle iff either:
$$a \le x$$
$$b \le y$$
or:
$$a \le x$$
$$\phantom{(ax+by)^2+}(b^2-a^2)^2 \le (ax-by)^2+(ay-bx)^2$$