필터 지우기
필터 지우기

How can I calculate the perimeters of Delaunay triangles?

조회 수: 2 (최근 30일)
ZhG
ZhG 2014년 4월 14일
댓글: Subrata Bhatacharjee 2019년 3월 10일
Hello,
Assume I have a set of point coordinates in a 2D plane. x = [ 16 16 16 17 18 19 19 20 21 21 23 23 23 ] y = [ 151 369 397 208 84 93 177 326 112 243 164 213 390 ]
Then, I use these points to obtain the Delaunay triangles. I found in a thread which asked about the calculation of area of each triangle. But if I want to calculate the perimeter of each triangle, how can I do for that? If possible, I also want to know the vertices (coordiantes) of each triangle.
Thanks.

답변 (1개)

Sven
Sven 2014년 4월 14일
Hi ZhG,
Here is some code that shows a few different ways of getting the perimeter of triangles. It first just shows the lengths of each edge in the Delaunay Triangulation. Then it sums up the perimeter of the boundary of the triangulation. Then it shows the perimeter of each face (displayed in red).
x = [ 16 16 16 17 18 19 19 20 21 21 23 23 23 ]
y = [ 151 369 397 208 84 93 177 326 112 243 164 213 390 ]
DT = delaunayTriangulation(x',y')
figure, triplot(DT), hold on
edges = DT.edges;
edgeLens = zeros(size(edges,1),1);
for i = 1:size(edges,1)
thisEdgePts = DT.Points(edges(i,:),:);
edgeCpt = mean(thisEdgePts,1);
edgeLen = sqrt(sum(diff(thisEdgePts,[],1).^2));
edgeLens(i) = edgeLen;
text(edgeCpt(1),edgeCpt(2),sprintf('%0.1f',edgeLen),'HorizontalAlignment','center')
end
outerBoundaryPerim = sum(edgeLens(ismember(DT.edges, DT.freeBoundary,'rows')))
for i = 1:size(DT.ConnectivityList,1)
thisVerts = DT.Points(DT.ConnectivityList(i,:),:);
faceEdgeLens = sqrt(sum(diff(thisVerts([1:end 1],:),[],1).^2,2));
facePerim = sum(faceEdgeLens);
faceCpt = mean(thisVerts,1);
text(faceCpt(1),faceCpt(2), sprintf('%0.1f',facePerim),'Color','r')
end
Did that help you out and answer your question?
  댓글 수: 3
Sven
Sven 2014년 4월 15일
편집: Sven 2014년 4월 15일
Oh, that's ok, you can still use the "DelaunayTri" class in 2011a.
There will be some minor differences:
  1. DT = delaunayTriangulation should be replaced with DT = DelaunayTri
  2. DT.Points should be replaced with DT.X
  3. DT.ConnectivityList should be replaced with DT.Triangulation
Everything else will work just the same.
Subrata Bhatacharjee
Subrata Bhatacharjee 2019년 3월 10일
yes, I can see the perimeter in red color. But I want to save all triangle's perimeter and calculater sum and average. Can you please solve this problem?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Delaunay Triangulation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by