Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find maximum area polygon inscribed in larger polygon

I would like to find the rotation and location for a polygon that maximizes how large it can be scaled up within the constraints of fitting within a larger polygon.

polygons

Current idea is to use scipy optimization routines for optimizing position and rotation parameters to maximize the scaling parameter, and shapely to add a constraint that the polygon is contained. This seems like it'll be slow and not particularly elegant.

Other ideas?

like image 885
daedalus12 Avatar asked Jun 28 '13 07:06

daedalus12


2 Answers

This problem sounds like it might be NP-Hard. Given a candidate solution you can't really be certain that it is the best solution. It seems like you'd need to try to use some sort of incremental randomized search.

like image 88
Kenneth Wright Avatar answered Nov 14 '22 08:11

Kenneth Wright


If the internal polygon is maximally scaled, then there are at least 4 pairs "internal vertice - external edge" or "external vertice - internal edge" where the vertice is on the edge.

Let's take all 4s of vertice-edge pairs. For every one we get the system of linear equations for two reference points' coordinates. If it has one solution, we verify that there are no intersections and if OK we remember the coordinates and size of the internal polygon.

This is an exact solution, but it's slow. On the other hand, scipy optimization routines are likely to find a local maximum which is not the global one.

like image 36
Tanriol Avatar answered Nov 14 '22 08:11

Tanriol