2

This is just a theoretical question. I think it's very probably that someone is already faced this problem before, and should be plenty of known algorithms to solve it. More than a concrete answer to my problem, I would be grateful if someone could give me some general idea where to start investigating.

The problem is very simple. I need to implement a function which has to receive 6 parameters. These parameters represent the dimension (width, length and height) of 2 objects: a box and figure. The problem is simple to explain, the function has to return true if the figure could be packed inside that box.

It may seem simple but it's not. It's not enough to compare if width_box >= width_figure. You can rotate the figure, incline it a few degrees in some direction... Also if the box is too big, the figure could "fly" inside the box.

I thought to compare them using their areas but it's not a good solution. See this example, despite of area_box=area_figure, you can't put that figure on that box.

Box: {Width:1, Lenght:1, Height: 10}
Figure: {Width:2, Lenght:5: Height:1}

As i said before, i don't pretend to answer me with a sample code. I think it has to be a common problem in assembly lines. Do you know any library, module, function or algorithm to solve my problem?

Sklivvz
  • 30,601
  • 24
  • 116
  • 172
Rumpelstinsk
  • 3,107
  • 3
  • 30
  • 57
  • So you would like to know if `Figure` fits into `Box` even if it is rotated across 360 degrees? – npinti Mar 10 '15 at 16:32
  • 2
    http://stackoverflow.com/questions/14296974/how-to-find-if-a-3d-object-fits-in-another-3d-object-the-container, http://stackoverflow.com/questions/140406/how-can-i-programmatically-determine-how-to-fit-smaller-boxes-into-a-larger-pack, http://en.wikipedia.org/wiki/Packing_problems – CodeCaster Mar 10 '15 at 16:32
  • @npinti If it is rotated 360 degrees, it comes to the orignal position. But yes, that's the idea. – Rumpelstinsk Mar 11 '15 at 10:55
  • @CodeCaster Thanks for the links, i will review them, and ask agan if i need, additional help :d – Rumpelstinsk Mar 11 '15 at 10:55
  • @Rumpel: What I meant was that you rotate it any value within the range [0, 360]. – npinti Mar 11 '15 at 11:07
  • I added an answer which naively sorted the length, width, and height of each object and simply compared them, i.e. if all dimensions of the container was larger than the dimensions of the contained, returned true. @SebastianNegraszus pointed out that you are allowed to *rotate* an object in 3D space, i.e. `Cuboid(1.1, 0.1, 0.1)` fits into a `Cuboid(1, 1, 1)`. I've deleted it (the answer) for now while I ponder how to solve this problem. – Wai Ha Lee Mar 11 '15 at 13:05

0 Answers0