【问题标题】:MATLAB: Create Delaunay Triangulation with OpeningMATLAB:创建带开口的 Delaunay 三角剖分
【发布时间】:2010-12-14 14:31:10
【问题描述】:

我有一个具有V 顶点和n 开口数的多边形。如何在 MATLAB 中为这个多边形使用 Delaunay 三角剖分创建网格?

我知道我可以使用delaunay 函数,但我不知道如何输入开头。

【问题讨论】:

    标签: matlab delaunay


    【解决方案1】:

    注意: 较新版本的 MATLAB 建议使用 delaunayTriangulation class 及其相关方法。下面的解决方案对旧版本有效,应该很容易适应新的类。


    您可以使用函数 DelaunayTri 创建一个 Delaunay 三角剖分,其中的边被约束为包含多边形的边界和开口的边。这将创建一个包含开口的三角剖分,因此您可以使用函数inOutStatus 仅选择边界区域“内部”的那些三角形(即在多边形中但不在开口中)。

    这是一个带有方孔的正方形示例:

    x = [0 1 2 3 3 3 3 2 1 0 0 0 1 2 2 1].';
    y = [0 0 0 0 1 2 3 3 3 3 2 1 1 1 2 2].';
    c = [(1:11).' (2:12).'; 12 1; (13:15).' (14:16).'; 16 13];  % Constrained edges
    dt = DelaunayTri(x, y, c);   % Create constrained triangulation
    isInside = inOutStatus(dt);  % Find triangles inside the constrained edges
    tri = dt(isInside, :);       % Get end point indices of the inner triangles
    triplot(tri, x, y);          % Plot the inner triangles
    hold on;
    plot(x(c(1:12, :)), y(c(1:12, :)), 'r', 'LineWidth', 2);    % Plot the outer edges
    plot(x(c(13:16, :)), y(c(13:16, :)), 'r', 'LineWidth', 2);  % Plot the inner edges
    axis equal;
    axis([-0.5 3.5 -0.5 3.5]);
    

    这是上面代码创建的情节:

    【讨论】:

      猜你喜欢
      • 2015-01-07
      • 2014-07-29
      • 2020-10-20
      • 2019-04-18
      • 2021-05-27
      • 2023-03-30
      • 2021-05-14
      • 2013-05-12
      • 1970-01-01
      相关资源
      最近更新 更多