[Math] Calculating how many pieces fit into a given area

algebra-precalculus

Is there any program which calculates how many pieces of an item with different sizes you can put in one area?

For example, I have a sheet of glass with size $3210 \times 2210$mm. Now I have different sizes to cut:

  • $1800 \times 1200=5$pcs,
  • $600 \times 800=14$pcs,
  • $400 \times 500=15$pcs,
  • $900 \times 500=10$pcs.

I want to maximize the use of sheet so to as to avoid big wastage. Can you help me find any program or any formula?

Best Answer

Along the lines of this discussion, I've arrived at the following packing:

enter image description here

I've added the following lines of Javascript to function doRender() in RectanglePacker:

(notice that I scaled down all dimensions by a factor of 10)

params.canvasWidth = 321;
params.canvasHeight = 221;
var b = []
var i = 0;
var bi = 0;
b[i++] = { w: 180, h: 120, n: 5 };
b[i++] = { w: 60, h: 80, n: 14 };
b[i++] = { w: 40, h: 50, n: 15 };
b[i++] = { w: 90, h: 50, n: 10 };

for (var j=0; j<b.length; j++) {
    for (var n=0; n<b[j].n; n++) {
        blocks[bi++] = { w: b[j].w, h: b[j].h };
    }
}
Related Question