I have some points in 3D, at each point is associated a number.
I would like to extrapolate a surface from these points and should be colored according to the number associated at each point, this is a perfect example: http://docs.enthought.com/mayavi/mayavi/auto/example_surface_from_irregular_data.html
In my case these points can be over a plane with an hole or over a cylinder, for example:
from mayavi import mlab
import numpy as np
import random
R = 20
r = 15
points = list()
for i in np.linspace(0, 2*np.pi, 20):
points.append([ R*np.cos(i), R*np.sin(i), 0.0, random.random() ])
points.append([ r*np.cos(i), r*np.sin(i), 0.0, random.random() ])
points = np.array(points)
x = points[:,0]
y = points[:,1]
z = points[:,2]
c = points[:,3]
mlab.figure(fgcolor=(0, 0, 0), bgcolor=(1, 1, 1))
pts = mlab.points3d(x, y, z, c, scale_mode='none', scale_factor=0.2)
mesh = mlab.pipeline.delaunay2d(pts)
surf = mlab.pipeline.surface(mesh, colormap='jet')
mlab.points3d(x,y,z,c, scale_mode='none', scale_factor=2)
mlab.savefig('1.png')
#%% Cylinder
points = list()
for j in np.linspace(0, 50, 10):
for i in np.linspace(0, 2*np.pi, 20):
points.append([ R*np.cos(i), R*np.sin(i), j, random.random() ])
points = np.array(points)
x = points[:,0]
y = points[:,1]
z = points[:,2]
c = points[:,3]
mlab.figure(fgcolor=(0, 0, 0), bgcolor=(1, 1, 1))
pts = mlab.points3d(x, y, z, c, scale_mode='none', scale_factor=0.2)
mesh = mlab.pipeline.delaunay3d(pts)
surf = mlab.pipeline.surface(mesh, colormap='jet')
mlab.points3d(x,y,z,c, scale_mode='none', scale_factor=2)
mlab.savefig('2.png')
The following image shows the results:
results
As you can see:
- the "plane" figure doesn't have an hole
- the "cylinder" is not completely closed along the lateral face and the top and bottom face are closed
So in my opinion these problems can be solved setting a maximum distance from point to point to be considered part of the mesh, but I am not able to find any option for delaunay2d or delaunay3d.
Do you know any alternative?
Thanks