I was reading about Delaunay (scipy) and came across the code:
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()
As far as I understand, a simplex is the generalization of a triangle to higher dimensions.
I don't understand the meaning of the code below and would like help understanding it:
# 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])
Thanks!