0
$\begingroup$

given 2 boxes (in 3-space) determine if one of the boxes resides within the other, or if a third box must be constructed that holds them both?

given that a box is defined by its center($x,y,z$), and its dimensions($W, H, D$).

consider that

  • the boxes are immovable,
  • can not have their properties altered,
  • and all tests must be done with fundamental logic.
  • 0
    What is the question?2012-04-12
  • 0
    @GerryMyerson edited.2012-04-12

1 Answers 1

1

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.

  • 0
    are these conjoined tests (both must be true), or are they separate. I can somewhat see that the tests would need to be reversed in order to determine if box2 resides in box box1, but what would be the characteristics of box3 if it is needed2012-04-12
  • 0
    @gardian06: There are two tests in each dimension for box 1 inside box 2. I gave the two in $x$. You need all six to pass for box 1 to be in 2. Then there are six more to see if 2 is in 1, which you should be able to figure out by symmetry. If you are going to build a single box, it needs to have the minimum $x$ coordinate equal to the minimum $x$ of either box and so on-again the same logic I used.2012-04-12