Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Need algorithm

Need algorithm

Scheduled Pinned Locked Moved Visual Basic
helpalgorithmsquestion
9 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    xx77abs
    wrote on last edited by
    #1

    Hello ! Is there any kind of algorithm that will calculate how many rectangles can if in one big rectangle ? I have following problem: have big rectangle, and then many smaller rectangles. I need to fit as much rectangles as it is possible in the big one. Can anyone help ? Btw, I was trying to make something myselft, but I only came out with recursive solution, and I think that it will be too slow (especially when you have maaaaany rectangles). Thanks :)

    0 J T 3 Replies Last reply
    0
    • X xx77abs

      Hello ! Is there any kind of algorithm that will calculate how many rectangles can if in one big rectangle ? I have following problem: have big rectangle, and then many smaller rectangles. I need to fit as much rectangles as it is possible in the big one. Can anyone help ? Btw, I was trying to make something myselft, but I only came out with recursive solution, and I think that it will be too slow (especially when you have maaaaany rectangles). Thanks :)

      0 Offline
      0 Offline
      0x3c0
      wrote on last edited by
      #2

      You might get a better answer in the Algorithms forum. But I would personally iterate from 0 to srcRect.Width, and iterate inside that from 0 to srcRect.Height. If the two iteration variables aren't equal, then add it to the list. That'll account for different sizes. You could loop again, through each item in the list to take different positions and the same size into account. The problem I can think of is that this would be extremely slow.

      OSDev

      X 1 Reply Last reply
      0
      • X xx77abs

        Hello ! Is there any kind of algorithm that will calculate how many rectangles can if in one big rectangle ? I have following problem: have big rectangle, and then many smaller rectangles. I need to fit as much rectangles as it is possible in the big one. Can anyone help ? Btw, I was trying to make something myselft, but I only came out with recursive solution, and I think that it will be too slow (especially when you have maaaaany rectangles). Thanks :)

        J Offline
        J Offline
        Johan Hakkesteegt
        wrote on last edited by
        #3

        I can't offer you a ready made solution but I figured out a little function that may at least help you out: Round a number to a multiple of another number[^] It would only give you a one-dimensional solution, but someone posted a reply to my article, saying that they used it in a grid calculation.

        My advice is free, and you may get what you paid for.

        X 1 Reply Last reply
        0
        • X xx77abs

          Hello ! Is there any kind of algorithm that will calculate how many rectangles can if in one big rectangle ? I have following problem: have big rectangle, and then many smaller rectangles. I need to fit as much rectangles as it is possible in the big one. Can anyone help ? Btw, I was trying to make something myselft, but I only came out with recursive solution, and I think that it will be too slow (especially when you have maaaaany rectangles). Thanks :)

          T Offline
          T Offline
          tosch
          wrote on last edited by
          #4

          we had to write a cut optimisation software once. I can't give you any detailed code but i can remember that you have to sort your small rectangles by size and the try to fit in the biggest piece first. You may find something useful if you google for 'cut optimisation'.

          Tosch

          X 1 Reply Last reply
          0
          • 0 0x3c0

            You might get a better answer in the Algorithms forum. But I would personally iterate from 0 to srcRect.Width, and iterate inside that from 0 to srcRect.Height. If the two iteration variables aren't equal, then add it to the list. That'll account for different sizes. You could loop again, through each item in the list to take different positions and the same size into account. The problem I can think of is that this would be extremely slow.

            OSDev

            X Offline
            X Offline
            xx77abs
            wrote on last edited by
            #5

            hehe, that's kind of what I've thought of ;) Thanks anyway

            1 Reply Last reply
            0
            • J Johan Hakkesteegt

              I can't offer you a ready made solution but I figured out a little function that may at least help you out: Round a number to a multiple of another number[^] It would only give you a one-dimensional solution, but someone posted a reply to my article, saying that they used it in a grid calculation.

              My advice is free, and you may get what you paid for.

              X Offline
              X Offline
              xx77abs
              wrote on last edited by
              #6

              Thanks for reply, I'll look into that :)

              1 Reply Last reply
              0
              • T tosch

                we had to write a cut optimisation software once. I can't give you any detailed code but i can remember that you have to sort your small rectangles by size and the try to fit in the biggest piece first. You may find something useful if you google for 'cut optimisation'.

                Tosch

                X Offline
                X Offline
                xx77abs
                wrote on last edited by
                #7

                Yea, that's what I'm writing ... Cut optimization software :) Thanks for suggestion for google search, I'll try it :)

                T 1 Reply Last reply
                0
                • X xx77abs

                  Yea, that's what I'm writing ... Cut optimization software :) Thanks for suggestion for google search, I'll try it :)

                  T Offline
                  T Offline
                  tosch
                  wrote on last edited by
                  #8

                  just found a link in my bookmarks that may help you: http://answers.google.com/answers/main?cmd=threadview&id=141254

                  Tosch

                  X 1 Reply Last reply
                  0
                  • T tosch

                    just found a link in my bookmarks that may help you: http://answers.google.com/answers/main?cmd=threadview&id=141254

                    Tosch

                    X Offline
                    X Offline
                    xx77abs
                    wrote on last edited by
                    #9

                    Thanks, I'll read it :)

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups