Consulting

Results 1 to 6 of 6

Thread: fitting shapes in a frame

  1. #1
    VBAX Newbie
    Joined
    Oct 2010
    Posts
    3
    Location

    fitting shapes in a frame

    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!

  2. #2
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,064
    Location
    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.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  3. #3
    VBAX Expert
    Joined
    Feb 2005
    Posts
    929
    Location
    Quote Originally Posted by PGO
    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:
    1. 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.
    2. 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?
    "It's not just the due date that's important, it's also the do date" [MWE]

    When your problem has been resolved, mark the thread SOLVED by clicking on the Thread Tools dropdown menu at the top of the thread.

  4. #4
    VBAX Newbie
    Joined
    Oct 2010
    Posts
    3
    Location
    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...

    Quote Originally Posted by MWE
    There are two ways to think about the "objects in a box" problem:
    1. 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.
    2. 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?

  5. #5
    VBAX Expert
    Joined
    Feb 2005
    Posts
    929
    Location
    Quote Originally Posted by PGO
    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:
    1. you have N "small" rectangles, of various sizes
    2. some may be the same size (length and width) as others
    3. you have a single larger rectangle, lets call it M
    4. you wish to know the N rectangles will fit in M

    A clarifying question:
    1. 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.
    2. 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.
    "It's not just the due date that's important, it's also the do date" [MWE]

    When your problem has been resolved, mark the thread SOLVED by clicking on the Thread Tools dropdown menu at the top of the thread.

  6. #6
    VBAX Newbie
    Joined
    Oct 2010
    Posts
    3
    Location
    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

    Quote Originally Posted by MWE
    Actually, most VBA tasks are math problems, some easy, some difficult. Let me restate your need:
    1. you have N "small" rectangles, of various sizes
    2. some may be the same size (length and width) as others
    3. you have a single larger rectangle, lets call it M
    4. you wish to know the N rectangles will fit in M
    A clarifying question:
    1. 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.
    2. 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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •