How can I connect two 2D triangulated surfaces?

2 views (last 30 days)
Hi, I have the following surfaces created using the delaunayTriangulation function with the points in the attached .txt file (the yellow one has modified z coordinates):
How can I connect those two surfaces with a third triangulated one so that I get a volume similar to the one below (without center hole)?
The triangulation is very important, I dont want to just plot a surface between the points, I need a triangulated surface that connects the two. Thank you in advance guys :)
This is the code that generates the two surfaces:
nump = numel(app.pointsPinion(:,1));
C = [(1:(nump-1))' (2:nump)'; nump 1];
dt = delaunayTriangulation(app.pointsPinion(:,1),app.pointsPinion(:,2),C);
io = isInterior(dt); % Filter out the points outside the profile defined by the points
figure
h(1) = trisurf(dt.ConnectivityList(io,:),app.pointsPinion(:,1),app.pointsPinion(:,2),app.pointsPinion(:,3));
hold on
h(2) = trisurf(dt.ConnectivityList(io,:),app.pointsPinion(:,1),app.pointsPinion(:,2),app.pointsPinion(:,3)+app.optiTrans.b);
axis tight
pbaspect([1 1 1])

Accepted Answer

Radu Andrei Matei
Radu Andrei Matei on 22 Jun 2022
Edited: Radu Andrei Matei on 22 Jun 2022
Hi, I've solved it. What I did is the following:
points 1, 2, 3 and 4 are points from the top surface and 5,6,7 and 8 are points from the bottom surface. I need two triangles to connect 4 points together, which means 2 rows in the connectivity matrix. I created the ConnectSurfaces function, which generates a connectivity matrix given a certain number of points, which will be the nº of rows in the vector with coordinates:
% Delaunay constraints for 2D top and bottom surfaces
nump = numel(app.pointsPinion(:,1));
C = [(1:(nump-1))' (2:nump)'; nump 1];
% Triangulation
dt = delaunayTriangulation(app.pointsPinion(:,1),app.pointsPinion(:,2),C);
% For filtering triangles outside profile defined by the original points
io = isInterior(dt);
figure
h(1) = trisurf(dt.ConnectivityList(io,:),app.pointsPinion(:,1),app.pointsPinion(:,2),app.pointsPinion(:,3),'FaceColor','r','EdgeColor','k');
hold on
h(2) = trisurf(dt.ConnectivityList(io,:),app.pointsPinion(:,1),app.pointsPinion(:,2),app.pointsPinion(:,3)+app.optiTrans.b,'FaceColor','r','EdgeColor','k');
n_points = size(app.pointsPinion,1);
ConMat = ConnectSurfaces(n_points);
trisurf(ConMat,[app.pointsPinion(:,1);app.pointsPinion(:,1)],[app.pointsPinion(:,2);app.pointsPinion(:,2)],[app.pointsPinion(:,3);app.pointsPinion(:,3)+app.optiTrans.b],'FaceColor','r','EdgeColor','k')
axis tight
pbaspect([1 1 1])
function ConnectivityMatrix = ConnectSurfaces(n_points)
for j = 1:1:n_points-1
k = 2*j;
ConnectivityMatrix(k-1,1) = j;
ConnectivityMatrix(k-1,2) = j+1;
ConnectivityMatrix(k-1,3) = j+n_points;
ConnectivityMatrix(k,1) = j+n_points;
ConnectivityMatrix(k,2) = j+n_points+1;
ConnectivityMatrix(k,3) = j+1;
end
% The following is for connecting the last pair of points with the first to get a closed donut-like surface
ConnectivityMatrix = [ConnectivityMatrix;[n_points 1 n_points*2];[n_points*2 n_points+1 1]];
end
The above solution yields the following result, which is what I was looking for:

More Answers (0)

Categories

Find more on Delaunay Triangulation in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!