2D & 3D Delaunay Triangulation of data?

17 次查看(过去 30 天)
I'm working on a surface etching model for a research project. I want to model a surface by using MATLABs delaunay or delaunayTriangulation functions. I've been able to produce the surface that I want using delaunay, and the following code:
if true
[x,y] = meshgrid(0:10,0:10);
z = ones(size(x));
tri = delaunay(x,y);
trisurf(tri,x,y,z);
end
Which yields the following surface:
However, the delaunay function will not allow me to access the vertices of the triangles so that I can perform the "etching" reaction. I know that I need to use delaunayTriangulation(). But I'm having trouble reproducing the same results that I have with delaunay(). I've tried this code:
if true
x = 0:10;
y = 0:10;
tri = delaunayTriangulation(x,y);
end
It outputs a triangulation that does not have any "Connectivity List" but only a 11:2 double. How can I remedy this, and create a surface similar to that of the delaunay() function? I've also tried using:
if true
x = 0:10;
y = 0:10;
z = ones([1 11]);
tri = delaunayTriangulation(x,y,z);
end
With the same result. Once I get this going, I'll be inputing a nanoscale scan of a metallic surface so that I can simulate a diffusion reaction. I'm just starting with this, so that I can learn how to manipulate the triangles and the vertices.

采纳的回答

Walter Roberson
Walter Roberson 2016-2-8
You can get the triangle coordinates from the delaunay output.
[x,y] = meshgrid(0:10,0:10);
z = ones(size(x));
tri = delaunay(x,y);
trisurf(tri,x,y,z);
tri_num = [5, 9]; %name some specific triangles
tx = x(tri(tri_num,:)); %get their coordinates
ty = y(tri(tri_num,:));
tz = z(tri(tri_num,:));
txc = [tx, tx(:,1)]; %close them for plotting
tyc = [ty, ty(:,1)];
tzc = [tz, tz(:,1)];
hold on
plot3(txc.', tyc.', tzc.', 'r');
hold off
Or in short, the unclosed coordinates for all of the triangles at the same time are
tx = x(tri);
ty = y(tri);
tz = z(tri);
  2 个评论
Brandon Johnson
Brandon Johnson 2016-2-8
Thank you! I'm wondering, for instance "tx," which indices are the coordinates in x,y? I notice there are 3 outputs
Walter Roberson
Walter Roberson 2016-2-8
Row K of tx gives the x coordinates for triangle #K . Three outputs because there are three vertices for the triangle.
plot(tx(K,:), ty(K,:), tz(K,:)) %unclosed, K'th triangle
"unclosed" meaning that this does not draw back to the initial vertex. The txc, tyc, tzc that I showed adds the initial vertex to the end of the list so as to close the triangles.
tx(K,1) - x of first vertex of triangle #K
tx(K,2) - x of second vertex of triangle #K
tx(K,3) - x of third vertex of triangle #K
ty(K,1) - y of first vertex of triangle #K
ty(K,2) - y of second vertex of triangle #K
and so on

请先登录,再进行评论。

更多回答(1 个)

John BG
John BG 2016-2-8
if it doesn't work try shaking it:
tri3 = delaunayTriangulation(randperm(11)',randperm(11)',randperm(11)');
now the nodes of tri3 are not empty
while reading d'Errico's approved answer
John does not recommend delaunay for rectangular regular meshes, makes sense.
You may still have to reorder the vertices.
If this answer helps you progress in this tiny step through your nanomachining research, please click on the thumbs-up vote link above, thanks in advance.
John

类别

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