Is there a simple algorithm for calculating the maximum inscribed circle into a convex polygon?

前端 未结 4 751
无人共我
无人共我 2020-12-14 20:28

I found some solutions, but they\'re too messy.

4条回答
  •  别那么骄傲
    2020-12-14 21:10

    Perhaps these "too messy" solutions are what you actually looking for, and there are no simplier ones?

    I can suggest a simple, but potentially imprecise solution, which uses numerical analysis. Assume you have a resilient ball, and you inflate it, starting from radius zero. If its center is not in the center you're looking for, then it will move, because the walls would "push" it in the proper direction, until it reaches the point, from where he can't move anywhere else. I guess, for a convex polygon, the ball will eventually move to the point where it has maximum radius.

    You can write a program that emulates the process of circle inflation. Start with an arbitrary point, and "inflate" the circle until it reaches a wall. If you keep inflating it, it will move in one of the directions that don't make it any closer to the walls it already encounters. You can determine the possible ways where it could move by drawing the lines that are parallel to the walls through the center you're currently at.

    In this example, the ball would move in one of the directions marked with green:


    (source: coldattic.info)

    Then, move your ball slightly in one of these directions (a good choice might be moving along the bisection of the angle), and repeat the step. If the new radius would be less than the one you have, retreat and decrease the pace you move it. When you'll have to make your pace less than a value of, say, 1 inch, then you've found the centre with precision of 1 in. (If you're going to draw it on a screen, precision of 0.5 pixel would be good enough, I guess).

    If an imprecise solution is enough for you, this is simple enough, I guess.

提交回复
热议问题