PDA

View Full Version : fitting shapes in a frame



PGO
10-08-2010, 12:42 AM
Dear all,

This is my first time on a forum and have never posted a thread before, so first of all sorry if I break any rule with my question...

I've got following problem:
I have a big rectangular (say with lenght a and width b), and in this rectangular I want see if a combination of 10 other rectangulars with variable dimensions fit (using a VBA-frame or excel to enter the dimensions).

Because the rectangulars can be turned in any position as long as they fit the big one, it's very hard to draw and create formulas.

Has anyone have perhaps an idea how to start writing the code for this?

Thanks and with kind regards!

Aussiebear
10-08-2010, 04:27 AM
Welcome to VBAX PGO. Can't say I've ever heard of anyone ever asking this type of question before. Please be patient, someone may come along with an idea for you.

MWE
10-08-2010, 07:39 AM
Dear all,

This is my first time on a forum and have never posted a thread before, so first of all sorry if I break any rule with my question...

I've got following problem:
I have a big rectangular (say with lenght a and width b), and in this rectangular I want see if a combination of 10 other rectangulars with variable dimensions fit (using a VBA-frame or excel to enter the dimensions).

Because the rectangulars can be turned in any position as long as they fit the big one, it's very hard to draw and create formulas.

Has anyone have perhaps an idea how to start writing the code for this?

Thanks and with kind regards!There are two ways to think about the "objects in a box" problem:
you have N objects (you know the shape and orientation of each object) and you wish to find a box (or other regular object) that will enclose the original N.
you have a box and wish to know if the N objects can be placed in such a way that they fit in the box.#1 is much easier to solve than #2. #2 is a very difficult problem in 3 space for quirky objects; hard but much easier in 2 space. Your particular problem appears to be #2 simplified to 2D rectangles; and is easier yet. Sounds a lot like "the box packing problem".

So, are you interested in how you solve the problem or in a solution?

PGO
10-10-2010, 05:42 AM
Hi MWE,

Indeed, I'm interested in the #2!
I would like to fill in the dimensions f.e. on an Excel-sheet, and then there should appear a box with "fit" or "doesn't fit".

I think it's a rather complex math problem in stead of a VBA-problem...
Sorry...


There are two ways to think about the "objects in a box" problem:

you have N objects (you know the shape and orientation of each object) and you wish to find a box (or other regular object) that will enclose the original N.
you have a box and wish to know if the N objects can be placed in such a way that they fit in the box.#1 is much easier to solve than #2. #2 is a very difficult problem in 3 space for quirky objects; hard but much easier in 2 space. Your particular problem appears to be #2 simplified to 2D rectangles; and is easier yet. Sounds a lot like "the box packing problem".

So, are you interested in how you solve the problem or in a solution?

MWE
10-10-2010, 07:37 AM
Hi MWE,

Indeed, I'm interested in the #2!
I would like to fill in the dimensions f.e. on an Excel-sheet, and then there should appear a box with "fit" or "doesn't fit".

I think it's a rather complex math problem in stead of a VBA-problem...
Sorry...Actually, most VBA tasks are math problems, some easy, some difficult. Let me restate your need:

you have N "small" rectangles, of various sizes
some may be the same size (length and width) as others
you have a single larger rectangle, lets call it M
you wish to know the N rectangles will fit in M
A clarifying question:

I assume that there are only two "correct" orientations for the N rectangles, i.e., if one orientation is at 0 degrees, the only other acceptable orientation is with an orientation rotate 90 degrees. This is the most reasonable orientation set for minimizing the size of M.
Is there any value in specific smaller rectangles being in some area of M? If this is a box packing problem and M is a truck, then there is probably a preferred "unpacking" orientation.

PGO
10-10-2010, 12:06 PM
Hi,
Thanks for your reply!
Yes, indeed correct about the orientations.
For your second question... there is no preferred unpacking orientation. I just want to know if the "cases" fit the "truck".

Kind regards


Actually, most VBA tasks are math problems, some easy, some difficult. Let me restate your need:

you have N "small" rectangles, of various sizes
some may be the same size (length and width) as others
you have a single larger rectangle, lets call it M
you wish to know the N rectangles will fit in MA clarifying question:

I assume that there are only two "correct" orientations for the N rectangles, i.e., if one orientation is at 0 degrees, the only other acceptable orientation is with an orientation rotate 90 degrees. This is the most reasonable orientation set for minimizing the size of M.
Is there any value in specific smaller rectangles being in some area of M? If this is a box packing problem and M is a truck, then there is probably a preferred "unpacking" orientation.