我正在阅读有关Delaunay (scipy)的内容并遇到了代码:
import numpy as np
points = np.array([[0, 0], [0, 1.1], [1, 0], [1, 1]])
from scipy.spatial import Delaunay
tri = Delaunay(points)
import matplotlib.pyplot as plt
plt.triplot(points[:,0], points[:,1], tri.simplices.copy())
plt.plot(points[:,0], points[:,1], 'o')
plt.show()
据我了解,单纯形是将三角形推广到更高维度。
我不明白下面代码的含义,并希望帮助理解它:
# Point indices and coordinates for the two triangles forming the triangulation:
tri.simplices
array([[3, 2, 0],
[3, 1, 0]], dtype=int32)
points[tri.simplices]
array([[[ 1. , 1. ],
[ 1. , 0. ],
[ 0. , 0. ]],
[[ 1. , 1. ],
[ 0. , 1.1],
[ 0. , 0. ]]])
Triangle 0 is the only neighbor of triangle 1, and it’s opposite to vertex 1 of triangle 1:
tri.neighbors[1]
# array([-1, 0, -1], dtype=int32)
points[tri.simplices[1,1]]
array([ 0. , 1.1])
谢谢!