How to fix the incorrect shape of a mesh
Ältere Kommentare anzeigen
I have 3D points that represent a cuboid saved in F which I extracted from an image. F is 8x3 double array. When I converted the data to a triangulated mesh and plotted it, I got this incorrect shape, see the image below. It should produce a cuboid with 6 faces, but the resulted one has 8 faces. Anyone can help me how to fix the problem to plot the correct shape? However, when I write the values of x,y, and z manually (see the code below the image), the code plots the shape correctly.
The code is:
x = F(:,1);
y = F(:,2);
z = F(:,3);
shp = alphaShape(x,y,z);
[elements,nodes] = boundaryFacets(shp);
model = createpde(); % requires Partial Differential Equation Toolbox
geometryFromMesh(model,nodes',elements');
pdegplot(model,'FaceLabels','on','FaceAlpha',0.5)
generateMesh(model);

% This section is the manual values of x, y, and z. Here the plot is correct. But if I use the existed one, the plot is not correct
F = [0.014 -0.4472 0
0.4055 -0.4472 0
0.409 -0.6478 0
0.014 -0.6478 0
0.014 -0.4472 -0.18
0.4055 -0.4472 -0.18
0.409 -0.6478 -0.18
0.014 -0.6478 -0.18];
Akzeptierte Antwort
Weitere Antworten (1)
KSSV
am 1 Sep. 2022
0 Stimmen
You need to arrange the vertices in an order...get the order from the above file exchange..
2 Kommentare
Mohammad Abu Haifa
am 1 Sep. 2022
KSSV
am 1 Sep. 2022
Check the order of the vertices...
Kategorien
Mehr zu Geometry and Mesh finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!