[SciPy-User] Strange results by scipy.spatial Delaunay
Nils Wagner
nils106 at googlemail.com
Fri Sep 20 08:30:35 EDT 2013
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()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20130920/b67ccead/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: coor.dat.gz
Type: application/x-gzip
Size: 1841 bytes
Desc: not available
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20130920/b67ccead/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: convex.png.gz
Type: application/x-gzip
Size: 280018 bytes
Desc: not available
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20130920/b67ccead/attachment-0001.bin>
More information about the SciPy-User
mailing list