How to define constraints on delaunay triangulation

14 ビュー (過去 30 日間)
Amal Alshomrani
Amal Alshomrani 2020 年 2 月 26 日
回答済み: Naga 2024 年 9 月 20 日
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);

回答 (1 件)

Naga
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.

カテゴリ

Help Center および File ExchangeDelaunay Triangulation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by