According to the above image; There is one big rectangle(borders) and there are the small ones. All the width and lengths are variable and may change. Question is; how can i calculate how many from each small rectangle i can fit inside the big rectanglewithout overlapping and with the most efficient way? EDIT: Most efficient way means leaving the smallest unused empty space inside big rectangle AND using the biggest tiles possible. Any help is appreciated.
If it's me, and I'm doing what I'm pretty sure you're doing, I use the Sprite Packer to do all the work for me This is a non-trivial problem, and there's no magic bullet. AFAIK most solutions consist of placing the biggest one in a corner, then placing the next biggest nestled in a corner near it in different positions until it fits, and so on down the line.
I dont know what sprite packer is, but i am sure it is slightly different than what i require. My problem is very smiliar to Cutting stock problem as the data(rectangles) and canvas are all variables and canvas should not be enlarged like you would pack textures (i.e. lightmapping). Further more, data might be 3D in some cases. Too bad i dont understand the formula there
Here's one algorithm that you could dive into: http://www.codeproject.com/Articles/210979/Fast-optimizing-rectangle-packing-algorithm-for-bu