MATLAB: STL to Point cloud or Alpha shape

MATLABMATLAB and Simulink Student Suite

Hello, I was wondering if there was a way to convert an imported STL file to a 3D point cloud or alpha shape. Thanks

Best Answer

Hello Alec,
After importing an STL file to MATLAB (using any preferred method, such as the 'importGeometry' function), you can use the 'alphaShape' function to create a three-dimensional alpha shape using the geometric data imported from your STL:
shp = alphaShape(x,y,z)
where 'x', 'y' and 'z' correspond to the points of the shape in each dimension. In addition, if you have access to the Computer Vision System Toolbox, you can simply use the 'pointCloud' function to create a point cloud:
ptCloud = pointCloud(xyzPoints)
where 'xyzPoints' is a matrix with the x y and z point locations retrieved from your STL. You can read more about these functions and see some examples in the documentation below:
https://www.mathworks.com/help/matlab/ref/alphashape.html?s_tid=srchtitle
https://www.mathworks.com/help/vision/ref/pointcloud-class.html?s_tid=srchtitle
Related Question