我有一个点列表,它是描述多边形的闭合路径,如何获得必须位于多边形区域内的点? 我不知道凹多边形的情况,但是当情况变为凸多边形时,所有点的平均值都位于多边形内部。
答案 0 :(得分:3)
保证结束,因为每个严格封闭的多边形至少有一个三角形,它完全是多边形的一部分。
对于步骤2.搜索SO,已多次回答。
答案 1 :(得分:3)
https://mathoverflow.net/questions/56655/get-a-point-inside-a-polygon
链接到:
部分地说:
Given a simple polygon, find some point inside it. Here is a method based on the proof that
there exists an internal diagonal, in [O'Rourke, 13-14]. The idea is that the midpoint of
a diagonal is interior to the polygon.
1. Identify a convex vertex v; let its adjacent vertices be a and b.
2. For each other vertex q do:
2a. If q is inside avb, compute distance to v (orthogonal to ab).
2b. Save point q if distance is a new min.
3. If no point is inside, return midpoint of ab, or centroid of avb.
4. Else if some point inside, qv is internal: return its midpoint.