Output of delaunay function
조회 수: 2 (최근 30일)
이전 댓글 표시
My question is two part:
tri=delaunay(M(:,1),M(:,2));
trisurf(tri,M(:,1),M(:,2),M(:,3))
Q.1 How do I interpret the matrix tri?( i want to know how the numbering of the vertices are done.)
Q.2 How do I delete certain triangles after the applying the function delaunay? ( I am not concerned about losing the property of delaunay triangulation. )
Thank You
P.S: I am new to MATLAB and excuse me if the questions I asked are silly.
댓글 수: 0
채택된 답변
Kenneth Eaton
2011년 1월 25일
As per the function documentation, the matrix tri returned from DELAUNAY will be an N-by-3 matrix where N is the number of triangles created. Therefore, each row of tri represents one triangle. The three values for each row represent indices into the set of x and y vertices, which are M(:,1) and M(:,2), respectively, in your example.
For example, consider the case where the first row of tri is [1 2 4]. This defines a triangle whose 3 vertices are at coordinates ( M(1,1), M(1,2)), ( M(2,1), M(2,2)), and ( M(4,1), M(4,2)).
If you want to remove a triangle from tri, all you have to do is remove the given row. For example, if you want to remove the second triangle, you could do this:
tri(2,:) = [];
댓글 수: 2
David Jenkins
2011년 2월 13일
I'm having a similar problem.
Your explanation seems logical however when I enter the example given on the MATLAB help page:
[x,y]=meshgrid(1:15,1:15);
tri = delaunay(x,y);
z = peaks(15);
trimesh(tri,x,y,z)
My values of tri however don't seem to correspond to indices of x and y. x and y are 15x15 arrays however the first few lines of tri are:
[40 25 24; 18 4 3; 9 24 25]
How can I be getting values >15 if they are supposed to reference indices of a 15x15 array
Kenneth Eaton
2011년 2월 14일
@David: What happens is that the 15-by-15 arrays in x and y are reshaped into 225-by-1 column vectors within DELAUNAY, so the indices in tri represent linear indices into the original matrices.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Delaunay Triangulation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!