How to define constraints on delaunay triangulation
15 次查看(过去 30 天)
显示 更早的评论
I have a set of boundray points of human foreground and I want the triangle meshes to be inside the boundray
I try the constrianted delaunay triangulation but i didn't know how to define the constriants
this my code
[sPostionX,sPostionY]=find(foregrounds(69).foreground==1);
sPostions=[sPostionX,sPostionY];
boundries=boundary(sPostions,0.97);
plot(sPostions(boundries,1),sPostions(boundries,2));
tri = DelaunayTri(sPostions(boundries,:)); % Delaunay triangulation
hold on
triplot(tri);
0 个评论
回答(1 个)
Naga
2024-9-20
Hi Amal,
To perform Constrained Delaunay Triangulation (CDT) with a set of boundary points, you need to ensure that the triangulation respects the constraints defined by the boundary. MATLAB provides a function called delaunayTriangulation which can be used to achieve CDT by specifying edges that need to be preserved.
Here's how you can modify your code to incorporate constraints:
% Get the boundary indices
boundaries = boundary(sPostions, 0.97);
% Create the edges that represent the boundary
edges = [boundaries, circshift(boundaries, -1)];
% Create a constrained Delaunay triangulation
tri = delaunayTriangulation(sPostions, edges);
% Plot the boundary and triangulation
figure;
plot(sPostions(boundaries, 1), sPostions(boundaries, 2), 'r-', 'LineWidth', 2);
hold on;
triplot(tri);
hold off;
The delaunayTriangulation function takes both the points and the edges, ensuring the triangulation respects the specified constraints.This approach should help you create a triangulation that remains within the specified boundary.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Delaunay Triangulation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!