Afra Mirhosseini
Afra Mirhosseini

Reputation: 51

Obtaining a triangle pair that have a shared edge from triangle set obtained from Delaunay Triangulation

I want to obtain triangles which are from triangle set obtained from Delaunay Triangulation. I wrote the following code. How can I obtain triangles which have a shred edge with each other (please see the image)? According to this image, I want to obtain triangle1 and 2 from triangle set obtained from Delaunay Triangulation.

rng default;

P = rand([32 2]);

DT = delaunayTriangulation(P);

triplot(DT)

enter image description here

Upvotes: 2

Views: 185

Answers (1)

cuda12
cuda12

Reputation: 660

Short answer: neighbors(DT).

Example:

rng default
P = rand([12 2]);
DT = delaunayTriangulation(P);

IC = incenter(DT);

% visualize incl. ID in the center
figure
triplot(DT)
hold on
text(IC(:,1), IC(:,2), num2str([1:size(IC,1)]'))

% find all neighboring triangles
neighbors(DT)

% for the first triangle
neighbors(DT, 1)

Upvotes: 3

Related Questions