Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plotting a surface from a set of interior 3D scatter points in MATLAB

I have a large (~60,000) set of triplet data points representing x,y, and z coordinates, which are scattered throughout a Cartesian volume.

I'm looking for a way to use Matlab to visualize the non-convex shape/volume described by the maximum extent of the points.

I can of course visualize the individual points using scatter3, but given the large number of points the details of the shape are obscured by the noise of the dots.

As an analogy, imagine that you filled a hour glass with spheres of random sizes such as BBs, ping pong balls, and kix and then were given the coordinates of the center of each of each object. How would you take those coordinates and visualize the shape of the hour glass containing them?

My example uses different sized objects because the spacing between data points is non-uniform and effectively random; it uses an hourglass because the shape is non-convex.

like image 588
Adam Wuerl Avatar asked Mar 30 '11 21:03

Adam Wuerl


People also ask

Which command is for plotting a 3-D surface in MATLAB?

surf( X , Y , Z ) creates a three-dimensional surface plot, which is a three-dimensional surface that has solid edge colors and solid face colors.

How do you make a 3 dimensional scatter plot?

Create ChartAfter adding data, go to the 'Traces' section under the 'Structure' menu on the left-hand side. Choose the 'Type' of trace, then choose '3D Scatter' under '3D' chart type. Next, select 'X', 'Y' and 'Z' values from the dropdown menus. This will create a 3D scatter trace, as seen below.

Which two functions can be utilized together to plot a surface in 3-D using MATLAB?

Forming the sinc function and plotting Z with mesh results in the 3-D surface.

How do you make a surface in MATLAB?

surface( X , Y , Z ) creates a primitive, three-dimensional surface plot. The function plots the values in matrix Z as heights above a grid in the x-y plane defined by X and Y . The color of the surface varies according to the heights specified by Z .


2 Answers

If your surface enclosing the points can be described as a convex polyhedron (i.e. like the surface of a cube or a dodecahedron, without concave pits or jagged pointy parts), then I would start by creating a 3-D Delaunay triangulation of the points. This will fill the volume around the points with a series of tetrahedral elements with the points as their vertices, and you can then find the set of triangular faces that form the outer shell of the volume using the convexHull method of the DelaunayTri class.

Here's an example that generates 200 random points uniformly distributed within the unit cube, creates a tetrahedral mesh for these points, then finds the 3-D convex hull for the volume:

interiorPoints = rand(200,3);      %# Generate 200 3-D points
DT = DelaunayTri(interiorPoints);  %# Create the tetrahedral mesh
hullFacets = convexHull(DT);       %# Find the facets of the convex hull

%# Plot the scattered points:
subplot(2,2,1);
scatter3(interiorPoints(:,1),interiorPoints(:,2),interiorPoints(:,3),'.');
axis equal;
title('Interior points');

%# Plot the tetrahedral mesh:
subplot(2,2,2);
tetramesh(DT);
axis equal;
title('Tetrahedral mesh');

%# Plot the 3-D convex hull:
subplot(2,2,3);
trisurf(hullFacets,DT.X(:,1),DT.X(:,2),DT.X(:,3),'FaceColor','c')
axis equal;
title('Convex hull');

enter image description here

like image 190
gnovice Avatar answered Oct 27 '22 07:10

gnovice


You could treat your data as a sample from a three-dimensional probability density, and estimate that density on a grid, e.g. via a 3d histogram, or better a 3d kernel density estimator. Then apply a threshold and extract the surface using isosurface.

Unfortunately, hist3 included in the Statistics Toolbox is (despite its name) just a 2d histogram, and ksdensity works only with 1d data, so you would have to implement 3d versions yourself.

like image 36
A. Donda Avatar answered Oct 27 '22 09:10

A. Donda