How to define constraints on delaunay triangulation

15 views (last 30 days)
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);

Answers (1)

Naga
Naga on 20 Sep 2024
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.

Categories

Find more on Delaunay Triangulation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!