Need algorithm
-
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 :)
-
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 :)
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.
-
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 :)
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.
-
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 :)
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
-
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.
-
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.
-
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
-
Yea, that's what I'm writing ... Cut optimization software :) Thanks for suggestion for google search, I'll try it :)
just found a link in my bookmarks that may help you: http://answers.google.com/answers/main?cmd=threadview&id=141254
Tosch
-
just found a link in my bookmarks that may help you: http://answers.google.com/answers/main?cmd=threadview&id=141254
Tosch