poster
2019-12-10, 16:49
我有一个具有V个顶点和n个开口的多边形。如何在MATLAB中使用Delaunay三角剖分为该多边形创建网格?
我知道我可以使用delaunay (http://www.mathworks.com/access/helpdesk/help/techdoc/ref/delaunay.html)函数,但是我不知道如何输入开头。
回答:
注意:较新版本的MATLAB建议使用delaunayTriangulation类 (http://www.mathworks.com/help/matlab/ref/delaunaytriangulation-class.html)及其关联方法。下面的解决方案对较旧的版本有效,并且应该易于适应较新的类。
您可以使用函数DelaunayTri (http://www.mathworks.com/help/techdoc/ref/delaunaytri.html)来创建Delaunay三角剖分,其边缘被约束为包括多边形的边界和开口的边缘。这将创建一个包含开口的三角剖分,因此您可以使用inOutStatus (http://www.mathworks.com/help/techdoc/ref/delaunaytri.inoutstatus.html)函数仅选择位于边界区域“内部”(即在多边形中但不在开口中)的那些三角形。
这是一个带有方孔的正方形的示例:
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]); 这是上面的代码创建的图:
https://i.stack.imgur.com/HZzpe.jpg (https://i.stack.imgur.com/HZzpe.jpg)
更多&回答... (https://stackoverflow.com/questions/1700522)
我知道我可以使用delaunay (http://www.mathworks.com/access/helpdesk/help/techdoc/ref/delaunay.html)函数,但是我不知道如何输入开头。
回答:
注意:较新版本的MATLAB建议使用delaunayTriangulation类 (http://www.mathworks.com/help/matlab/ref/delaunaytriangulation-class.html)及其关联方法。下面的解决方案对较旧的版本有效,并且应该易于适应较新的类。
您可以使用函数DelaunayTri (http://www.mathworks.com/help/techdoc/ref/delaunaytri.html)来创建Delaunay三角剖分,其边缘被约束为包括多边形的边界和开口的边缘。这将创建一个包含开口的三角剖分,因此您可以使用inOutStatus (http://www.mathworks.com/help/techdoc/ref/delaunaytri.inoutstatus.html)函数仅选择位于边界区域“内部”(即在多边形中但不在开口中)的那些三角形。
这是一个带有方孔的正方形的示例:
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]); 这是上面的代码创建的图:
https://i.stack.imgur.com/HZzpe.jpg (https://i.stack.imgur.com/HZzpe.jpg)
更多&回答... (https://stackoverflow.com/questions/1700522)