Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
![]() |
#1 |
高级会员
注册日期: 2019-11-21
帖子: 3,006
声望力: 66 ![]() |
![]()
假设我有一个多边形,并且想对其进行网格化。为了进一步限制我得到的网格,我将提供一个固定点列表(必须位于多边形内),以便它们必须通过生成的三角形元素进行连接。
matlab命令可以做什么?我尝试了delaunay命令,但是它不适用于凹面多边形,因为delaunay命令将始终向我返回包含凸面区域的元素列表。 回答: 您要使用的函数是DelaunayTri ,您将按照以下步骤操作:
polygonVertices = [0 0;... %# Concave polygon vertices 0 1;... 1 1;... 0.5 0.5;... 1 0]; polygonEdges = [1 2;... %# Polygon edges (indices of connected vertices) 2 3;... 3 4;... 4 5;... 5 1]; otherVertices = [0.5.*rand(5,1) rand(5,1)]; %# Additional vertices to be added %# inside the polygon vertices = [polygonVertices; otherVertices]; %# Collect all the vertices dt = DelaunayTri(vertices,polygonEdges); %# Create a constrained triangulation isInside = inOutStatus(dt); %# Find the indices of inside triangles faces = dt(isInside,:); %# Get the face indices of the inside triangles 现在,可以使用变量faces和vertices来绘制网格多边形 。 使用旧版本的MATLAB ... 查看存档的版本文档 ( 注意:需要使用MathWorks帐户),可以看到DelaunayTri首次出现在版本7.8.0(2009a)中。在此之前,唯一可用于执行二维Delaunay三角剖分的内置功能是delaunay ,它基于Qhull ,因此无法支持约束三角剖分或非凸曲面的三角剖分。 较新的DelaunayTri使用CGAL 。因此,对于版本低于7.8.0的用户,一种选择是创建MEX文件以在MATLAB中连接CGAL例程。例如,如果您要对一个凹面多边形进行三角剖分,则可以创建一个MEX文件来连接CGAL中的一个凸面分区例程 ,以便将凹面多边形分解为一组凸面多边形。然后可以使用delaunay对每个凸多边形进行三角剖分,并将最终的三角剖分分组为一个更大的凹多边形三角剖分。 更多&回答... |
![]() |
![]() |