Reputation: 2332
I have a set of points, from which I calculate a Delaunay triangulation using the scipy.spatial.Delaunay function. Something along the following for example:
import numpy as np
from scipy.spatial import Delaunay
tri = Delaunay(np.random.rand(10,2))
What I want to do after this is calculated is remove a simplex. Is there an easy way to do this? I notice the Delaunay object has a method for add_point
but nothing for remove_point
or remove_simplex
.
The way I see it, I have two options. I know the list of points myself so I simply remove the necessary points and re-calculate the Delaunay triangulation. I hope to avoid this as it can become inefficient if I have to re-calculate a lot for a lot of points. The other option I can see is to directly edit the object parameters myself, but this seems like a potentially dangerous method. Does anyone have any suggestions of a better method?
Upvotes: 4
Views: 2569
Reputation: 6166
The Delaunay result is a numpy object.You can choose the simplex you need.
import numpy as np
from scipy.spatial import Delaunay
import matplotlib.pyplot as plt
points = np.random.rand(30,2)
tri = Delaunay(points).simplices.copy()
plt.triplot(points[:,0], points[:,1], tri, linewidth=0.5)
plt.show()
tri_another = tri[0:10,:]
print(len(tri))
print(len(tri_another))
plt.triplot(points[:,0], points[:,1], tri_another, linewidth=0.5)
plt.show()
Upvotes: 2