How do I specify a hole with its coordinates ?
조회 수: 5 (최근 30일)
이전 댓글 표시
Hi,
How do i specify a hole in MATLAB ?
in other words, How do i make matlab realize a hole, from points in cloud ?
Example: Below is code for a slab with a hole. The coordinates of hole and corners of slab are specified. But the faces of hole are not being realized , when the code if executed.
vert = [0 0 0;10 0 0;10 20 0; 0 20 0; 5 5 0;7.5 5 0;7.5 10 0;5 10 0; 5 5 3;7.5 5 3;7.5 10 3;5 10 3; 0 0 3;10 0 3;10 20 3; 0 20 3];
GG = delaunayTriangulation(vert);
faceColor = [0.6875 0.8750 0.8984];
figure
tetramesh(GG,'FaceColor',faceColor,'FaceAlpha',0.3);
[FBtri,FBpoints] = freeBoundary(GG);
size(FBtri)
size(FBpoints)
Note: The actual answer has to be 32 faces instead of 28. The problem is the faces inside a hole is not taken into account here.
댓글 수: 0
답변 (1개)
DGM
2025년 10월 8일 17:41
You can't use delaunayTriangulation() to do constrained triangulation in 3D. Without constraints, you get the convex hull of the point set. Just do 2D constrained triangulation of the top side, then extrude into 3D.
% start in 2D
% define the model by its closed constraint curves
% for simplicity, order the vertices as they are to be used
Vc = {[0 0; 10 0; 10 20; 0 20]; % outside (ccw)
[5 10; 7.5 10; 7.5 5; 5 5]}; % inside (cw)
% construct the edge (constraint) lists in the same direction
sz = cellfun(@(x) size(x,1),Vc); % length of each vertex list
szc = [0; cumsum(sz)];
Ec = cell(numel(Vc),1);
for k = 1:numel(Vc)
v = 1+szc(k):szc(k+1);
Ec{k} = [v; circshift(v,-1)].';
end
% consolidate lists
V = cell2mat(Vc);
E = cell2mat(Ec);
% do constrained triangulation in 2D
T = delaunayTriangulation(V,E);
[F V] = t2fv(T); % F covers the convex hull of V in x,y
F = F(isInterior(T),:); % discard triangles outside the constraints
% extrude the part into 3D
[F V] = extrude(F,V,3);
% display it using patch()
patch('faces',F,'vertices',V,'facecolor',[1 1 1]*0.9,'edgecolor','k');
view(3); camlight; view(10,33)
axis equal; grid on
xlabel('X'); ylabel('Y'); zlabel('Z')
The tools t2fv(), extrude() and support files are part of FEX #182013. They wouldn't have been available in 2014, but they work in 2014. In other words, if this were done in 2014, the example would just be more verbose, but there isn't a substantial difference in what operations need to be done.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Triangulation Representation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
