我试图用scipy.ConvexHull()
得到一个矩形的边界,但没有成功。在
u=np.linspace(0, 4, 8)
v=np.linspace(5, 10, 8)
u,v=np.meshgrid(u,v)
u=u.flatten()
v=v.flatten()
points2D=np.vstack([u,v]).T
hull = ConvexHull(points2D)
convex_hull_plot_2d(hull)
boundaryList = hull.vertices
print boundaryList
只给出四个角:[ 0 7 63 56]
使用选项qhull_options="QJ Pp"
稍微扰动点,如下所示:
给出更多的点:[62 56 40 8 0 2 6 7 15 23 47 55 63]
,但仍然不是完整的边界集。在
有人能告诉我一个合适的方法吗?在
凸壳态的数学definition
包含一个矩形的最小凸集就是你得到的四个角。在
要获得边界上的所有点,可以使用Delaunay triangulation,然后根据生成的Delaunay网格计算凸包
为了在形成三角剖分后创建外壳,程序使用tri.convex_hull。这将返回构成三角剖分点的凸壳的面顶点。在你的,二维的情况下,这些是线和输出出来作为一组相邻的点组成每一条线。注意,这种方法被认为是低效的,因为它需要形成除凸包外的三角剖分。在
程序的其余部分提取每个点的x和相应的y值,并将它们与生成的三角剖分一起绘制
相关问题 更多 >
编程相关推荐