フィルターのクリア

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

2 ビュー (過去 30 日間)
Aasha M V
Aasha M V 2022 年 4 月 21 日
回答済み: Steven Lord 2022 年 4 月 21 日
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.

採用された回答

Steven Lord
Steven Lord 2022 年 4 月 21 日
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.

その他の回答 (0 件)

カテゴリ

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