MATLAB:使用Opening创建Delaunay三角剖分

Gra*_*ton 4 matlab delaunay

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

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

gno*_*ice 5

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


您可以使用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]);
Run Code Online (Sandbox Code Playgroud)

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

在此输入图像描述