Packing Rectangles into a Polygon Using JavaScript

I need to assemble n rectangles (n <10) of different sizes into a simple polygon. I know of two possible solutions:

  • Insert rectangles into a rectangle. Then the problem becomes finding the rectangle in the polygon, which is large enough. It should not be the largest rectangle, but it should be large enough to be a good approximation to the polygon to pack these small rectangles. Is there any algorithm that could do this?

  • Using a constraint solver. The only JavaScript constraint resolver I know is Cassowary . However, it is linear, and it seems to me that the point constraint inside a simple polygon is not a linear constraint.

Any ideas?

+4
source share

All Articles