【问题标题】:Create a triangular mesh using Delaunay methods使用 Delaunay 方法创建三角形网格
【发布时间】:2015-09-26 05:59:32
【问题描述】:

我正在尝试使用 python 创建一个三角形网格。 由于我知道边界点,我认为 delaunay 方法更合适。 我尝试使用 scipy。代码很简单

from scipy.spatial import Delaunay
pixelpoints = np.transpose(np.nonzero(binaryImage))
tri = Delaunay(pixelpoints)
import matplotlib.pyplot as plt
plt.triplot(pixelpoints[:,0], pixelpoints[:,1], tri.simplices.copy())
plt.plot(pixelpoints[:,0], pixelpoints[:,1], 'o')
plt.show()

但我不想要这个。我想在图像边界内网格化。另外,我不想在孔内网格化。 我可以控制覆盖表面的三角形数量吗? 有没有其他方法可以做到这一点?

谢谢。

【问题讨论】:

    标签: python numpy scipy triangulation delaunay


    【解决方案1】:

    您可以使用Polygon.IsPointInside(tCentroid) 轻松删除其他三角形,其中tCentroid 是三角形的质心。 IsPointInside() 可以由此推导出:http://geomalgorithms.com/a03-_inclusion.html

    【讨论】:

      【解决方案2】:

      Triangle 程序支持这两种需求:将三角形细化到规定的大小,并删除多边形外部或孔中的三角形。似乎有一个python interface 漂浮在周围:API 描述了如何指定孔和最大三角形区域。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-10-20
        • 2016-04-29
        • 1970-01-01
        • 2016-02-08
        • 2014-01-21
        • 2015-07-09
        • 2020-06-02
        • 1970-01-01
        相关资源
        最近更新 更多