Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The key to solving this problem is first making an observation: the center of the largest circle that will fit inside an arbitrary polygon is the point that is:</p> <ol> <li>Inside the polygon; and</li> <li>Furthest from any point on the edges of the polygon.</li> </ol> <p>Why? Because every point on the edge of a circle is equidistant from that center. By definition, the largest circle will have the largest radius and will touch the polygon on at least two points so if you find the point inside furthest from the polygon you've found the center of the circle.</p> <p>This problem appears in geography and is solved iteratively to any arbitrary precision. Its called the Poles of Inaccessibility problem. See <a href="http://web.archive.org/web/20140629230429/http://cuba.ija.csic.es/~danielgc/papers/Garcia-Castellanos,%20Lombardo,%202007,%20SGJ.pdf" rel="nofollow noreferrer">Poles of Inaccessibility: A Calculation Algorithm for the Remotest Places on Earth</a>.</p> <p>The basic algorithm works like this:</p> <ol> <li>Define R as a rectilinear region from (x<sub>min</sub>,y<sub>min</sub>) to (x<sub>max</sub>,y<sub>max</sub>);</li> <li>Divide R into an arbitrary number of points. The paper uses 21 as a heuristic (meaning divide the height and width by 20);</li> <li>Clip any points that are outside the polygon;</li> <li>For the remainder find the point that is furthest from any point on the edge;</li> <li>From that point define a new R with smaller intervals and bounds and repeat from step 2 to get to any arbitrary precision answer. The paper reduces R by a factor of the square root of 2.</li> </ol> <p>One note, How to test if a point is inside the polygon or not: The simplest solution to this part of the problem is to cast a ray to the right of the point. If it crosses an odd number of edges, it's within the polygon. If it's an even number, it's outside.</p> <p>Also, as far as testing the distance to any edge there are two cases you need to consider:</p> <ol> <li>The point is perpendicular to a point on that edge (within the bounds of the two vertices); or</li> <li>It isn't.</li> </ol> <p>(2) is easy. The distance to the edge is the minimum of the distances to the two vertices. For (1), the closest point on that edge will be the point that intersects the edge at a 90 degree angle starting from the point you're testing. See <a href="http://geomalgorithms.com/a02-_lines.html" rel="nofollow noreferrer">Distance of a Point to a Ray or Segment</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload