MATLAB: Interpolate Points of a 3D Point Cloud

interpolationMATLAB and Simulink Student Suitepoint cloudtriangulation

I am trying to interpolate data points (x, y, z) to get a point cloud with higher density.
I have triangulation points (x-y-z coordinates) and faces from a .stl-file (imported with stlread()) that I can work with. (DATA is attached).
In the attached image you can see the given data points (BLUE) and indicated the points I want to create (RED) – but for the whole geometry and in larger numbers.
Any ideas?

Best Answer

  • Use griddata to create surface
  • Use contour3 to create crossection
clc,clear
load data.txt
x = data(:,1);
y = data(:,2);
z = data(:,3);
[t,r] = cart2pol(x,y);
rr = linspace(min(r),max(r),20);
tt = linspace(0,2*pi,20);
[T,R] = meshgrid(tt,rr); % new mesh
[X,Y] = pol2cart(T,R); % convert new mesh to cartesian
Z = griddata(x,y,z,X,Y); % according Z coordinates
plot3(x,y,z,'.b')
hold on
surf(X,Y,Z,'faceColor','none','edgecolor',[1 1 1]*0.8)
contour3(X,Y,Z,[34 38])
hold off
axis equal
Result
Related Question