Reputation: 387
I have a X, Y, Z file that, when plotted as a 3D scatter, creates the following:
I'd like to create a 3D shape by connecting the outter dots of these two "round distributions", or simply fit a 3D shape (e.g. a cylinder) in a way that, later, I could calculate the volume of this 3D shape. Any ideas?
The data:
0.200 0.080 3.311
0.200 0.080 3.325
0.200 0.080 3.340
0.200 0.080 3.354
0.200 0.080 3.369
0.200 0.080 3.384
0.200 0.080 3.398
0.200 0.080 3.413
0.200 0.080 3.428
0.200 0.085 3.281
0.200 0.085 3.296
0.200 0.085 3.311
0.200 0.085 3.325
0.200 0.085 3.340
0.200 0.085 3.354
0.200 0.085 3.369
0.200 0.085 3.384
0.200 0.085 3.398
0.200 0.085 3.413
0.200 0.085 3.428
0.200 0.085 3.442
0.200 0.085 3.457
0.200 0.090 3.267
0.200 0.090 3.281
0.200 0.090 3.296
0.200 0.090 3.311
0.200 0.090 3.325
0.200 0.090 3.340
0.200 0.090 3.354
0.200 0.090 3.369
0.200 0.090 3.384
0.200 0.090 3.398
0.200 0.090 3.413
0.200 0.090 3.428
0.200 0.090 3.442
0.200 0.090 3.457
0.200 0.090 3.472
0.200 0.090 3.486
0.200 0.095 3.281
0.200 0.095 3.296
0.200 0.095 3.311
0.200 0.095 3.325
0.200 0.095 3.340
0.200 0.095 3.354
0.200 0.095 3.369
0.200 0.095 3.384
0.200 0.095 3.398
0.200 0.095 3.413
0.200 0.095 3.428
0.200 0.095 3.442
0.200 0.095 3.457
0.200 0.095 3.472
0.200 0.095 3.486
0.200 0.095 3.501
0.200 0.095 3.516
0.200 0.100 3.281
0.200 0.100 3.296
0.200 0.100 3.311
0.200 0.100 3.325
0.200 0.100 3.340
0.200 0.100 3.354
0.200 0.100 3.369
0.200 0.100 3.384
0.200 0.100 3.398
0.200 0.100 3.413
0.200 0.100 3.428
0.200 0.100 3.442
0.200 0.100 3.457
0.200 0.100 3.472
0.200 0.100 3.486
0.200 0.100 3.501
0.200 0.100 3.516
0.200 0.100 3.530
0.200 0.105 3.311
0.200 0.105 3.325
0.200 0.105 3.340
0.200 0.105 3.354
0.200 0.105 3.369
0.200 0.105 3.384
0.200 0.105 3.398
0.200 0.105 3.413
0.200 0.105 3.428
0.200 0.105 3.442
0.200 0.105 3.457
0.200 0.105 3.472
0.200 0.105 3.486
0.200 0.105 3.501
0.200 0.105 3.516
0.200 0.105 3.530
0.200 0.110 3.325
0.200 0.110 3.340
0.200 0.110 3.354
0.200 0.110 3.369
0.200 0.110 3.384
0.200 0.110 3.398
0.200 0.110 3.413
0.200 0.110 3.428
0.200 0.110 3.442
0.200 0.110 3.457
0.200 0.110 3.472
0.200 0.110 3.486
0.200 0.110 3.501
0.200 0.110 3.516
0.200 0.115 3.369
0.200 0.115 3.384
0.200 0.115 3.398
0.200 0.115 3.413
0.200 0.115 3.428
0.200 0.115 3.442
0.200 0.115 3.457
0.200 0.115 3.472
0.200 0.115 3.486
0.200 0.120 3.428
0.200 0.120 3.442
0.200 0.120 3.457
0.200 0.120 3.472
0.200 0.120 3.486
0.350 0.080 3.428
0.350 0.085 3.296
0.350 0.085 3.311
0.350 0.085 3.325
0.350 0.085 3.340
0.350 0.085 3.354
0.350 0.085 3.369
0.350 0.085 3.384
0.350 0.085 3.398
0.350 0.085 3.413
0.350 0.085 3.428
0.350 0.085 3.442
0.350 0.085 3.457
0.350 0.085 3.472
0.350 0.085 3.486
0.350 0.085 3.501
0.350 0.090 3.267
0.350 0.090 3.281
0.350 0.090 3.296
0.350 0.090 3.311
0.350 0.090 3.325
0.350 0.090 3.340
0.350 0.090 3.354
0.350 0.090 3.369
0.350 0.090 3.384
0.350 0.090 3.398
0.350 0.090 3.413
0.350 0.090 3.428
0.350 0.090 3.442
0.350 0.090 3.457
0.350 0.090 3.472
0.350 0.090 3.486
0.350 0.090 3.501
0.350 0.090 3.516
0.350 0.090 3.530
0.350 0.095 3.267
0.350 0.095 3.281
0.350 0.095 3.296
0.350 0.095 3.311
0.350 0.095 3.325
0.350 0.095 3.340
0.350 0.095 3.354
0.350 0.095 3.369
0.350 0.095 3.384
0.350 0.095 3.398
0.350 0.095 3.413
0.350 0.095 3.428
0.350 0.095 3.442
0.350 0.095 3.457
0.350 0.095 3.472
0.350 0.095 3.486
0.350 0.095 3.501
0.350 0.095 3.516
0.350 0.095 3.530
0.350 0.095 3.545
0.350 0.095 3.560
0.350 0.100 3.267
0.350 0.100 3.281
0.350 0.100 3.296
0.350 0.100 3.311
0.350 0.100 3.325
0.350 0.100 3.340
0.350 0.100 3.354
0.350 0.100 3.369
0.350 0.100 3.384
0.350 0.100 3.398
0.350 0.100 3.413
0.350 0.100 3.428
0.350 0.100 3.442
0.350 0.100 3.457
0.350 0.100 3.472
0.350 0.100 3.486
0.350 0.100 3.501
0.350 0.100 3.516
0.350 0.100 3.530
0.350 0.100 3.545
0.350 0.100 3.560
0.350 0.100 3.574
0.350 0.100 3.589
0.350 0.105 3.267
0.350 0.105 3.281
0.350 0.105 3.296
0.350 0.105 3.311
0.350 0.105 3.325
0.350 0.105 3.340
0.350 0.105 3.354
0.350 0.105 3.369
0.350 0.105 3.384
0.350 0.105 3.398
0.350 0.105 3.413
0.350 0.105 3.428
0.350 0.105 3.442
0.350 0.105 3.457
0.350 0.105 3.472
0.350 0.105 3.486
0.350 0.105 3.501
0.350 0.105 3.516
0.350 0.105 3.530
0.350 0.105 3.545
0.350 0.105 3.560
0.350 0.105 3.574
0.350 0.105 3.589
0.350 0.110 3.237
0.350 0.110 3.252
0.350 0.110 3.267
0.350 0.110 3.281
0.350 0.110 3.296
0.350 0.110 3.311
0.350 0.110 3.325
0.350 0.110 3.340
0.350 0.110 3.354
0.350 0.110 3.369
0.350 0.110 3.384
0.350 0.110 3.398
0.350 0.110 3.413
0.350 0.110 3.428
0.350 0.110 3.442
0.350 0.110 3.457
0.350 0.110 3.472
0.350 0.110 3.486
0.350 0.110 3.501
0.350 0.110 3.516
0.350 0.110 3.530
0.350 0.110 3.545
0.350 0.110 3.560
0.350 0.110 3.574
0.350 0.110 3.589
0.350 0.115 3.237
0.350 0.115 3.252
0.350 0.115 3.267
0.350 0.115 3.281
0.350 0.115 3.296
0.350 0.115 3.311
0.350 0.115 3.325
0.350 0.115 3.340
0.350 0.115 3.354
0.350 0.115 3.369
0.350 0.115 3.384
0.350 0.115 3.398
0.350 0.115 3.413
0.350 0.115 3.428
0.350 0.115 3.442
0.350 0.115 3.457
0.350 0.115 3.472
0.350 0.115 3.486
0.350 0.115 3.501
0.350 0.115 3.516
0.350 0.115 3.530
0.350 0.115 3.545
0.350 0.115 3.560
0.350 0.115 3.574
0.350 0.115 3.589
0.350 0.120 3.267
0.350 0.120 3.281
0.350 0.120 3.296
0.350 0.120 3.311
0.350 0.120 3.325
0.350 0.120 3.340
0.350 0.120 3.354
0.350 0.120 3.369
0.350 0.120 3.384
0.350 0.120 3.398
0.350 0.120 3.413
0.350 0.120 3.428
0.350 0.120 3.442
0.350 0.120 3.457
0.350 0.120 3.472
0.350 0.120 3.486
0.350 0.120 3.501
0.350 0.120 3.516
0.350 0.120 3.530
0.350 0.120 3.545
0.350 0.120 3.560
0.350 0.120 3.574
0.350 0.120 3.589
0.350 0.125 3.311
0.350 0.125 3.325
0.350 0.125 3.340
0.350 0.125 3.354
0.350 0.125 3.369
0.350 0.125 3.384
0.350 0.125 3.398
0.350 0.125 3.413
0.350 0.125 3.428
0.350 0.125 3.442
0.350 0.125 3.457
0.350 0.125 3.472
0.350 0.125 3.486
0.350 0.125 3.501
0.350 0.125 3.516
0.350 0.125 3.530
0.350 0.125 3.545
0.350 0.125 3.560
0.350 0.125 3.574
0.350 0.130 3.369
0.350 0.130 3.384
0.350 0.130 3.398
0.350 0.130 3.413
0.350 0.130 3.428
0.350 0.130 3.442
0.350 0.130 3.457
0.350 0.130 3.472
0.350 0.130 3.486
0.350 0.130 3.501
0.350 0.130 3.516
0.350 0.130 3.530
0.350 0.130 3.545
0.350 0.130 3.560
Upvotes: 0
Views: 453
Reputation: 97331
You can use scipy.spatial.ConvexHull
to get the outter points and calculate the volume:
from scipy import spatial
ch = spatial.ConvexHull(points)
print(ch.volume)
# to plot the surface
import pylab as pl
from mpl_toolkits.mplot3d import Axes3D
fig = pl.figure()
ax = fig.add_subplot(1, 1, 1, projection='3d')
ax.plot_trisurf(points[:, 0], points[:, 1], points[:, 2], triangles=ch.simplices)
Upvotes: 2
Reputation: 967
One thing must be pointed out that connecting the outer dots that wraps the object and fitting a cylinder(or any other basic shape) are two different things. For wrapping the outer dots(this is called 3D convex hull problem), use pyhull
Python library which is an interface to Qhull library. Qhull can find the minimal wrapping object and calculate its volume effectively.
On the other hand, basic 3D shape fitting is a completely different topic. You can refer to this SO question for further information. Once you got cylinder, you can perform the volume calculation by simple algebra.
Upvotes: 1