# delete the top and bottom triangular faces of the 3D object

1 visualización (últimos 30 días)
Alberto Acri el 5 de Oct. de 2023
Comentada: Alberto Acri el 9 de Oct. de 2023
Hi! Is there a way to delete the top and bottom triangular faces of the tube?
nodes = importdata("NODES.mat");
faces = importdata("FACES.mat");
figure
plot3(nodes(:,1),nodes(:,2),nodes(:,3),'k.','Markersize',2);
hold on
trimesh(faces(:,:),nodes(:,1),nodes(:,2),nodes(:,3),'EdgeColor','k','Linewidth',0.1,'Facecolor','b','FaceAlpha',1)
hold off
axis equal
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Fabio Freschi el 5 de Oct. de 2023
By looking at your data I see that the top and bottom triangles have a predominant z direction of the face normals. So I play with this
nodes = importdata("NODES.mat");
faces = importdata("FACES.mat");
figure
plot3(nodes(:,1),nodes(:,2),nodes(:,3),'k.','Markersize',2);
hold on
trimesh(faces(:,:),nodes(:,1),nodes(:,2),nodes(:,3),'EdgeColor','k','Linewidth',0.1,'Facecolor','b','FaceAlpha',1)
hold off
axis equal
% create triangulation object to easily calculate face normals
TR = triangulation(faces,nodes);
P = incenter(TR);
F = faceNormal(TR);
% plot on the previous plot to see what's happening
hold on
quiver3(P(:,1),P(:,2),P(:,3), ...
F(:,1),F(:,2),F(:,3),0.5,'color','r');
% dot product with z directed unit vector
proj = F*[0 0 1].';
% threshold (play with this value)
idx = abs(proj) > 0.6;
% remove faces
faces(idx,:) = [];
% new plot without faces
figure
trimesh(faces(:,:),nodes(:,1),nodes(:,2),nodes(:,3),'EdgeColor','k','Linewidth',0.1,'Facecolor','b','FaceAlpha',1)
Hope it helps
##### 13 comentariosMostrar 11 comentarios más antiguosOcultar 11 comentarios más antiguos
Fabio Freschi el 9 de Oct. de 2023
% find normals oriented like u1 (dot product)
idx1 = abs(F*u1.') > 0.9999;
% find normals oriented like u2 (dot product)
idx2 = abs(F*u2.') > 0.9999;
% find barycenters laying on the magenta plane
ipln1 = abs(sum(P.*u1,2)-sum(u1.*P1,2)) < 0.001;
% find barycenters laying on the magenta plane
ipln2 = abs(sum(P.*u2,2)-sum(u2.*P2,2)) < 0.001;
% remove bottom lid
faces((idx1 & ipln1) | (idx2 & ipln2),:) = [];
Alberto Acri el 9 de Oct. de 2023
Thank you!

Iniciar sesión para comentar.

### Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

R2021b

### Community Treasure Hunt

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

Start Hunting!

Translated by