4

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?

zephyr
  • 2,182
  • 3
  • 29
  • 51
  • What are you using the `Delaunay` object for? – ali_m Feb 09 '16 at 20:22
  • @ali_m For generating polygonal meshes (potentially in high dimensions). I create a baseline mesh using Delaunay triangulation, but I then need to adjust the mesh by doing things like moving vertices around or removing simplexes. – zephyr Feb 09 '16 at 20:59
  • 1
    I guess my question is which methods of the `Delaunay` instance still need to work correctly after you've removed simplices? – ali_m Feb 09 '16 at 21:02
  • Not 100% sure yet, but at the very least, I need the information stored in it. However I expect I'll eventually need information like the paraboloid scale and shift or the convex hull. – zephyr Feb 10 '16 at 15:56

1 Answers1

3

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()

enter image description here enter image description here

giser_yugang
  • 6,058
  • 4
  • 21
  • 44