在python中,对于一组点,With
import matplotlib.tri as tri
triang = tri.Triangulation(x, y)
我怎样才能制作一个面具来消除长边三角形?
在python中,对于一组点,With
import matplotlib.tri as tri
triang = tri.Triangulation(x, y)
我怎样才能制作一个面具来消除长边三角形?
最后我解决了这个问题:
import matplotlib.tri as tri
def long_edges(x, y, triangles, radio=22):
out = []
for points in triangles:
#print points
a,b,c = points
d0 = np.sqrt( (x[a] - x[b]) **2 + (y[a] - y[b])**2 )
d1 = np.sqrt( (x[b] - x[c]) **2 + (y[b] - y[c])**2 )
d2 = np.sqrt( (x[c] - x[a]) **2 + (y[c] - y[a])**2 )
max_edge = max([d0, d1, d2])
#print points, max_edge
if max_edge > radio:
out.append(True)
else:
out.append(False)
return out
triang = tri.Triangulation(x, y)
mask = long_edges(x,y, triang.triangles)
triang.set_mask(mask)
plt.triplot(triang)