Presumably the boxes are aligned with the axes and you have a definition that $W$ is the width in $x, H$ in $Y$, and $L$ in $z$. Call the centers $(x_1, y_1, z_1)$ and $(x_2, y_2, z_2)$. Then box $1$ is inside box $2$ if $x_1-W_1/2 \gt x_2-W_2/2, x_1+W_1/2 \lt x_2+W_2/2$ and so on.