代码之家  ›  专栏  ›  技术社区  ›  sazr

Delaunay的重复点有可能吗?

  •  1
  • sazr  · 技术社区  · 7 年前

    我在用 scipy.spatial.Delaunay

    我注意到现在它不允许/坚持这一点-见下面的例子。是否有允许此操作的设置?

    我希望创建一个看起来像“台阶”的网格,即如下所示:

    enter image description here

    为了实现这个网格,将有重复的x,y点-2个重复点 (0.5,0) 也在 (0.5,1) .

    points = np.array([[0,0], [0,1], [1,1], [1,0], [0.5,0], [0.5,0], [0.5,1], [0.5,1]])
    z = np.array([0,0,1,1,0,1,0,1])
    
    tri = Delaunay(points)
    
    fig = plt.figure()
    ax = fig.add_subplot(1, 1, 1, projection='3d')
    ax.plot_trisurf(points[:,0], points[:,1], z, triangles=tri.simplices, cmap=plt.cm.Spectral)
    plt.show()
    

    enter image description here

    如果我使用不同的/不重复的点,我可以让它工作:

    points = np.array([[0,0], [0,1], [1,1], [1,0], [0.5,0], [0.51,0], [0.5,1], [0.51,1]])
    
    0 回复  |  直到 7 年前