Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Algorithm for fitting 2D polygons in an area?

Is there a standard for this? Algorithm name?

Say: I have 10 polygons of different sizes. I have an area of specific size.

I want to know how to fill the most polygons in that area, and how they are fitted.

Note: Polygons may be rotated depending on the restriction set.

like image 769
Atlas Avatar asked Dec 01 '09 08:12

Atlas


3 Answers

One possible name is a Packing Problem. It is related to the Knapsack Problem. These problems tend to be NP-hard, and many require heuristics. If you can constrain the allowed forms of polygons and of the area, there may exist a more efficient algorithm for your special case.

like image 186
Yuval F Avatar answered Oct 23 '22 07:10

Yuval F


You can have a look at "Dancing Links" in Wikipedia for Donald Knuth's solution to the exact cover problem - which includes tiling - your question can be looked at as a tiling problem

like image 41
Steve De Caux Avatar answered Oct 23 '22 07:10

Steve De Caux


IF (that's a big if) all your polygons were rectangles, and the area into which they are to fit is also a rectangle, then this would be called bin-packing, Google will overwhelm you with information about this. If they're not then I guess that you are looking for a variant of bin-packing, and I guess some more that you are into an NP problem for which 'try and test' is about the best algorithm around.

like image 26
High Performance Mark Avatar answered Oct 23 '22 06:10

High Performance Mark