Matlab之创建和编辑Delaunay三角剖分

创建和编辑Delaunay三角剖分。此示例演示如何使用delaunayTriangulation类创建、编辑和查询Delaunay三角剖分。Delaunay三角网是科学计算中应用最广泛的三角网。与三角剖分相关的特性为解决各种几何问题提供了基础。还示出了约束Delaunay三角剖分的构造,以及覆盖中轴线计算和网格变形的应用。

东西/原料

  • 电脑
  • Matlab软件

方式/步调

  1. 1

    示例一:建立并绘制2D Delaunay三角剖分

    本示例申明若何计较2D Delaunay三角剖分以及若何将三角剖分与极点和三角形标签一路绘制。

    在号令行窗口,输入号令:

    x = rand(10,1);

    y = rand(10,1);

    dt = delaunayTriangulation(x,y)

    按“Enter键”。

    如图1所示。

  2. 2

    在号令行窗口,输入号令:

    triplot(dt);

    %

    % Display the Vertex and Triangle labels on the plot

    hold on

    vxlabels = arrayfun(@(n) {sprintf('P%d', n)}, (1:10)');

    Hpl = text(x, y, vxlabels, 'FontWeight', 'bold', 'HorizontalAlignment',...

       'center', 'BackgroundColor', 'none');

    ic = incenter(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');

    hold off

    按“Enter键”。

    如图2所示。

  3. 3

    示例二:建立并绘制3D Delaunay三角剖分

    本示例标的目的您展示若何计较3D Delaunay三角剖分以及若何绘制三角剖分。

    在号令行窗口,输入号令:

    X = rand(10,3)

    按“Enter键”。

    如图3所示。

  4. 4

    在号令行窗口,输入号令:

    dt = delaunayTriangulation(X)

    按“Enter键”。

    如图4所示。

  5. 5

    在号令行窗口,输入号令:

    tetramesh(dt, 'FaceColor', 'cyan');

    % To display large tetrahedral meshes use the convexHull method to

    % compute the boundary triangulation and plot it using trisurf.

    % For example;

    % triboundary = convexHull(dt)

    % trisurf(triboundary, X(:,1), X(:,2), X(:,3), 'FaceColor', 'cyan')

    按“Enter键”。

    如图5所示。

  6. 6

    示例三:拜候三角剖分数据布局

    有两种方式可以拜候三角测量数据布局。 一种方式是经由过程Triangulation属性,另一种方式是利用索引。

    从10个随机点建立2D Delaunay三角剖分。

    在号令行窗口,输入号令:

    X = rand(10,2)

    按“Enter键”。

    如图6所示。

  7. 7

    在号令行窗口,输入号令:

    dt = delaunayTriangulation(X)

    按“Enter键”。

    如图7所示。

  8. 8

    在号令行窗口,输入号令:

    % The triangulation datastructure is;

    dt.ConnectivityList

    按“Enter键”。

    如图8所示。

  9. 9

    在号令行窗口,输入号令:

    % Indexing is a shorthand way to query the triangulation. The format is

    % dt(i, j) where j is the j'th vertex of the i'th triangle, standard

    % indexing rules apply.

    % The triangulation datastructure is

    dt(:,:)

    按“Enter键”。

    如图9所示。

  10. 10

    第二个三角形是;

    在号令行窗口,输入号令:

    dt(2,:)

    按“Enter键”。

    如图10所示。

  11. 11

    第二个三角形的第三个极点是;

    在号令行窗口,输入号令:

    dt(2,3)

    按“Enter键”。

    如图11所示。

  12. 12

    前三个三角形;

    在号令行窗口,输入号令:

    dt(1:3,:)

    按“Enter键”。

    如图12所示。

原作者:Matlab教程举报
  • 发表于 2020-02-11 20:00
  • 阅读 ( 1070 )
  • 分类:其他类型

你可能感兴趣的文章

相关问题

0 条评论

请先 登录 后评论
联系我们:uytrv@hotmail.com 问答工具