I have a pointlist=[p1,p2,p3...] where p1 = [x1,y1],p2=[x2,y2] ...
I want to use scipy.spatial.Delaunay to do trianglation on these point clouds and then plot it
How can i do this ?
The documentation for the Delaunay is really scarce
so far i have this code
from subprocess import Popen, PIPE
import os
os.environ['point_num'] = "2000"
cmd = 'rbox $point_num D2 | tail -n $point_num'
sub_process = Popen(cmd, shell=True,stdout=PIPE,stderr=PIPE)
output = sub_process.communicate()
points = [line.split() for line in output[0].split('\n') if line]
x = [p[0] for p in points if p]
y = [p[1] for p in points if p]
import matplotlib.pyplot as plt
plt.plot(x,y,'bo')
from scipy.spatial import Delaunay
dl = Delaunay(points)
convex = dl.convex_hull
from numpy.core.numeric import reshape,shape
convex = reshape(convex,(shape(convex)[0]*shape(convex)[1],1))
convex_x = [x[i] for i in convex]
convex_y = [y[i] for i in convex]
plt.plot(convex_x,convex_y,'r')
plt.show()
Thanks
EDIT: plot also the convex hull
Note that using
scipy.spatial.Delaunay
just for computing the complex hull is probably overkill, because computing just the hull can in principle done faster than computing the triangulation. Unfortunately, there's no interface in Scipy yet for computing hulls directly with Qhull.