MATLAB: DelaunayTri output relation to inputs

delaunaytri

Hi,
This is likely a silly question, but if I have a vector of x,y coordinates which I pass to DelaunayTri:
dt = DelaunayTri(tri_x,tri_y);
What exactly is the relation between dt and tri_x and tri_y? Trying to understand this, I looked at the vertex attachments:
t = vertexAttachments(dt);
t{1}
ans = 726 820 822 821 735
Does that mean that the x,y coordinates of the points with vertexes attached by an edge to point 1 is tri_x(726), tri_y(726), etc.?
Thank you, Michael

Best Answer

Analyze this code, I think that it will help you to understand DelaunayTri:
[tri_x tri_y] = meshgrid(-1:.5:1);
tri_x = tri_x(:);
tri_y = tri_y(:);
dt = DelaunayTri(tri_x,tri_y);
vertexNumber = 13;
t = vertexAttachments(dt,vertexNumber);
fprintf('Simplices attached to vertex %i: ',vertexNumber)
disp(t{1})
% visualization
triplot(dt);
hold on
vxlabels = arrayfun(@(n) {sprintf('P%d', n)}, (1:25)');
Hpl = text(tri_x, tri_y, vxlabels, 'FontWeight', 'bold', 'HorizontalAlignment',...
'center', 'BackgroundColor', 'none');
ic = incenters(dt);
numtri = size(dt,1);
trilabels = arrayfun(@(x) {sprintf('T%d', x)}, (1:numtri)');
Htl = text(ic(:,1), ic(:,2), trilabels, 'FontWeight', 'bold', ...
'HorizontalAlignment', 'center', 'Color', 'blue');
triplot(dt(t{:},:),tri_x,tri_y,'Color','r')
hold off
axis off
Related Question