英文:
Finding out if a circle can "escape" a set of points
问题
我试图创建一个程序,用于标记圆是否可以用于以后的计算。要求使用圆的条件是:
- 点(图中的金点)不能在圆的周围。
- 圆必须能够“逃离”周围的点,例如,它不能处于封闭空间中。
第一个要求很容易解决,但我对第二个要求有些困惑。
我在Python 3.x中编写代码,并使用DT = scipy.spatial.delaunay(golden_spots)
和marked_circles = DT.find_simplex(circle_centers)
作为标记圆的初始方法,如下图所示(为了方便查看,绘制了凸包),但它还标记了每个图中的两个圆(左图中的所有红圆和右图中最左和最右的红圆),它们能够“逃离”,但在德劳内三角剖分内。问题在于,我仍然希望标记右图中的内部红圆,而不标记外部两个。
就我可用的数据而言,我有所有点和圆心的x/y坐标以及它们的半径(在给定图中所有圆的半径相同)。此外,圆圈在x轴和y轴上的间距不均匀。
图例说明:
- 灰色圆:未标记
- 蓝色圆:由于德劳内而标记
- 绿色圆:由于接近点而标记
- 红色圆:由于德劳内而标记,但不靠近点
问题:有没有办法不标记最外层的圆,同时仍然标记最内层的圆(右图)?提前感谢。
注意:这两个图仅为示例,但从理论上讲,可能会在图的各个位置有各自的金点,不一定在中间形成一个连续的“堆叠”。
英文:
Simplified explanation: I am trying to create a program that marks whether or not circles can be used for a later calculation. Requirements for a circle to be used:
- A dot (golden points in the plots) must not be within a circle's circumference
- The circle must be able to "escape" the surrounding dots, e.g. it must not be in an enclosed space.
The first requirement is easy to solve but i am struggling a bit with the second one.
I am coding in python3.x and have used DT = scipy.spatial.delaunay(golden_spots)
and marked_circles = DT.find_simplex(circle_centers)
as an initial way to mark circles as can be seen in the picture below (convex hull is plotted to ease visibility), however it also marks two circles in each plot (all red circles in left plot and the left- and right-most red circles in right plot) that would be able to "escape" but are within the delaunay triangulation. The problem here is that i still want the inner red circle in the right plot to be marked, without the outer two.
In terms of what data i have available, then i have the x/y coordinates of all points and circle centers and their radius (all circles have the same radius in a given plot).
Furthermore, the circles are not evenly spaced along the x- and y-axes.
Figure explanation:
- Grey circles: Unmarked
- Blue circles: Marked due to delaunay
- Green circles: Marked due to proximity to point
- Red circles: Marked due to delaunay but not in proximity of a point
Question: Is there a way to not mark the outermost circles while the innermost (right plot) is still marked. Thanks in advance.
Note: These two plots are just examples, but in theory there could be individual golden spots in various places on the plot, not necessarily in one contiguous "pile" in the middle.
答案1
得分: 1
潜在的解决方案可能如下所示:
-
消除所有包含金点(蓝/绿色)的圆。
-
在所有距离小于
d
的金点之间绘制线,其中d
是圆的直径。 -
对于每个剩余的圆,确定该点是否位于由四周的边界包围的区域内。实现这个可能有几种方法:从空间的Delaunay三角剖分创建图,其中每个三角形空间由3个金点连接在一起,如果它们相邻但不在边上(即共享点之间的距离大于
d
),则它们彼此连接。从所有外部Delaunay三角形到汇点/端点创建边。然后,如果存在从圆的起始Delaunay三角形到汇点的路径,圆应该被涂成绿色。 -
另一种方法:通过从凸包开始,然后迭代地“缩小”凸包,使凸包中包含没有通过边连接的两个连续点的地方(即,如果凸包包含两点距离大于
d
,则添加额外的点到凹凸包,直到所有点距离小于d
)。最终的凹凸包将包含所有红色圆的中心,并且不会包含任何灰色圆的中心。
英文:
One potential solution could look like this:
-
Eliminate all circles that contain a gold point (blue/green I think)
-
Draw lines between all gold points less than
d
apart, whered
is the diameter of the circles. -
For each remaining circle, determine whether that point lies within an area enclosed by edges on all sides. A few possible ways to do this might be: Create a graph from the delaunay triangulation of the space, where each triangular space between 3 gold points is connected to another if they are adjacent along a non-edge (i.e. the distance between the shared points is greater than
d
). Make an edge from all exterior delaunay triangles to the sink / endpoint. Then, the circle should be colored green iff there exists a path from the circle's starting delaunay triangle to the sink. -
An alternative method: create a concave hull by starting with the convex hull, then iteratively "shrinking" the hull everywhere the hull contains two consecutive points not connected by an edge (i.e. if the hull contains two points greater than
d
apart, add additional points to the concave hull until all points are less thand
apart.) The final concave hull will contain the centers of all red circles, and will not contain the centers of any grey circles.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论