To get x and y coordinates of the edges in a Delaunay Triangulation
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Aasha M V
am 21 Apr. 2022
Beantwortet: Steven Lord
am 21 Apr. 2022
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.
0 Kommentare
Akzeptierte Antwort
Steven Lord
am 21 Apr. 2022
Let's build a sample delaunayTriangulation using the first example on its documentation page.
rng default;
P = rand([30 2]);
DT = delaunayTriangulation(P)
What does this triangulation look like?
triplot(DT)
Which nodes make up the 42nd triangle?
triangle42 = DT.ConnectivityList(42, :)
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, :)
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.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Delaunay Triangulation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!