Click to See Complete Forum and Search --> : Random shape fitting code ?
pjohno
November 25th, 2005, 08:47 AM
Part of the app I am currently building needs to tile a rectangular space with a random pattern of rectangular and square shapes.
The rectangular and square shapes are of known size, as is the overall size of the enclosing rectangle.
Has anybody come across this before and if so, can you point me to a solution / sample code ?
Currently coding using C++ Builder, but code of any language that shows an algorithm would be ok.
Thanks,
Paul
ovidiucucu
November 27th, 2005, 12:16 PM
Except that you are using C++ Builder you give not any additional info. How kind of application you want to create? Want you use Windows GDI functions ore something else? Is something like in attached image that you need?
pjohno
November 27th, 2005, 02:55 PM
Hi, I kept the details to a minimum to keep the post short. Maybe too short...
The application is a part of a layout program for designing accoustic tiling. All C++ and uses both Borland Graphics and Windows Graphics to do the actual drawing. The drawing itself isnt the problem. The problem is in calculating the sizes and selections of the square and rectangular tiles, required to fill the outside rectangular area.
As mentions, the rectangles and squares used to fit the overall rectangle are taken randomly from a list of rectangles and squares of known sizes. The idea is to achieve a tiled outside rectangle where all the randomly chosen shapes fil the entire rectangular area, edge to edge with each other.
So, the outside enclosing rectangle is of known dimensions, as are the dimensions of the smaller squares and rectangles in the shapes list.
What I need is help with the coding algorithm to select an array of smaller shapes to fit the larger shape with little wasted space.
Paul
ovidiucucu
November 29th, 2005, 05:02 AM
[ Redirected thread ]
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.