Reputation: 6835
I want to generate triangle meshes in MATLAB with the delaunay function in 2-D. So I declare the X- and Y- values and set tri=delaunay(X,Y). Then I use triplot to plot it. However, what does tri give me? Does it give each of my triangle a special designation number? After reading through some of the MATLAB tutorials I still DON'T understand it.
Upvotes: 1
Views: 953
Reputation: 7015
The delaunay
function returns tri
as an Mx3
matrix of triangle connectivity, where each of the M
triangles is represented as an integer triplet that indexes into the X,Y
vertex position arrays.
It's probably easier with a simple example:
%% a simple square box
X = [0.0; 1.0; 1.0; 0.0];
Y = [0.0; 0.0; 1.0; 1.0];
%% an example output from delaunay()
tri = [1,2,3 %% 1st triangle connects vertices 1,2,3
1,3,4 %% 2nd triangle connects vertices 1,3,4
];
The triangles are just numbered linearly - tri(1,:)
is the first triangle, tri(n,:)
is the nth triangle etc. If you wanted to re-order the list of traingles you could permute the array, but the indexing would always have to be linear - if there are M
triangles the indexing must encompass 1:M
.
Hope this helps.
Upvotes: 1