Effacer les filtres
Effacer les filtres

To get x and y coordinates of the edges in a Delaunay Triangulation

2 vues (au cours des 30 derniers jours)
Hi,
I am having a delaunay triangulation DT. And edges are identified using e=DT.edges; If I run this
disp(DT.Points(e(i,1)));
disp(DT.Points(e(i,2)));
What might be am getting? suppose i=2. My aim is to identify the (x,y) coordinates of the ends of the edges. Please help.

Réponse acceptée

Steven Lord
Steven Lord le 21 Avr 2022
Let's build a sample delaunayTriangulation using the first example on its documentation page.
rng default;
P = rand([30 2]);
DT = delaunayTriangulation(P)
DT =
delaunayTriangulation with properties: Points: [30×2 double] ConnectivityList: [48×3 double] Constraints: []
What does this triangulation look like?
triplot(DT)
Which nodes make up the 42nd triangle?
triangle42 = DT.ConnectivityList(42, :)
triangle42 = 1×3
23 26 18
We can index into the Points property of DT to determine the X and Y coordinates of those three points. Each row in Points represents the coordinates of one of the points.
xy = DT.Points(triangle42, :)
xy = 3×2
0.8491 0.6551 0.7577 0.4984 0.9157 0.6463
Looking at the first element of triangle42 and the first row of xy we see that point 23 is at roughly x = 0.8491, y = 0.6551. Let's highlight these points in the plot using the coordinates in xy. I need to replot DT in a new figure because otherwise MATLAB Answers would not show the figure both above and here; it would wait to display it until this point. If you run this code in your desktop installation of MATLAB you could skip the first two lines below, starting with the hold call.
figure
triplot(DT)
hold on
plot(xy(:, 1), xy(:, 2), 'ro', MarkerSize=12, MarkerFaceColor='r')
Those points do make up one of the triangles in the delaunayTriangulation.

Plus de réponses (0)

Catégories

En savoir plus sur Delaunay Triangulation dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by