scipy.spatial.tsearch

scipy.spatial.tsearch(tri, xi)

找出包含给定点的简图。此函数的作用与 Delaunay.find_simplex

0.9 新版功能.

示例

>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> from scipy.spatial import Delaunay, delaunay_plot_2d, tsearch
>>> rng = np.random.default_rng()

一组随机点的Delaunay三角剖分:

>>> pts = rng.random((20, 2))
>>> tri = Delaunay(pts)
>>> _ = delaunay_plot_2d(tri)

查找包含一组给定点的简化:

>>> loc = rng.uniform(0.2, 0.8, (5, 2))
>>> s = tsearch(tri, loc)
>>> plt.triplot(pts[:, 0], pts[:, 1], tri.simplices[s], 'b-', mask=s==-1)
>>> plt.scatter(loc[:, 0], loc[:, 1], c='r', marker='x')
>>> plt.show()
../../_images/scipy-spatial-tsearch-1.png