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

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

有帮助吗?

解决方案

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


您可以使用该功能 德劳内特里 创建 Delaunay 三角剖分,其边缘约束为包括多边形的边界和开口的边缘。这将创建一个包含开口的三角剖分,因此您可以仅选择那些位于有界区域“内部”的三角形(即在多边形中但不在开口中)通过使用该函数 输入输出状态.

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

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]);

这是由上面的代码创建的图:

enter image description here

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top