Strange results by scipy.spatial Delaunay

Hi all, I tried to create a convex hull of a set of points distributed on a cylindrical surface by the following script. The needed input file coor.dat is attached. How can I fix the problem with the distorted mesh (convex.png) ? Nils from scipy.spatial import Delaunay import numpy as np points = np.loadtxt('coor.dat',usecols =(1,2,3)) nid = np.loadtxt('coor.dat',usecols=(0,)) m,n = points.shape print 'Number of points m =', m tri = Delaunay(points) faces = [] for ia, ib, ic in tri.convex_hull: x1 = points[ia] x2 = points[ib] x3 = points[ic] area = 0.5*np.linalg.norm(np.cross(x2-x1,x1-x3)) print 'Area of face', area faces.append(points[[ia, ib, ic]]) import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from mpl_toolkits.mplot3d.art3d import Poly3DCollection fig = plt.figure() ax = fig.gca(projection='3d') items = Poly3DCollection(faces, facecolors=[(0, 0, 0, 0.1)]) ax.add_collection(items) ax.scatter(points[:,0], points[:,1], points[:,2], 'o') ax.legend(loc=0,shadow=True) plt.show()

20.09.2013 15:30, Nils Wagner kirjoitti:
I tried to create a convex hull of a set of points distributed on a cylindrical surface by the following script. The needed input file coor.dat is attached. How can I fix the problem with the distorted mesh (convex.png) ?
The resulting mesh is as reported by Qhull, so you can try tuning Qhull options to make the result better. If you only want convex hulls, you should use scipy.spatial.ConvexHull rather than scipy.spatial.Delaunay, as Delaunay triangulation is both more sensitive to rounding errors and slower than direct convex hulling. -- Pauli Virtanen
participants (2)
-
Nils Wagner
-
Pauli Virtanen