DelaunayTri output relation to inputs

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

 Réponse acceptée

Grzegorz Knor
Grzegorz Knor le 26 Nov 2011
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

Plus de réponses (0)

Catégories

En savoir plus sur Aerospace Blockset dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by