主要内容

boundaryshape

R2026b

从二维三角剖分创建 polyshape

描述

polyout = boundaryshape(TR) 从二维三角剖分的边界创建 polyshape 对象。TR 可以是 triangulation 对象或 delaunayTriangulation 对象。

创建 polyshape 对象 polyout 后,可以使用 polyshape 函数分析其属性或执行其他计算。例如,可以使用属性 polyout.Vertices 访问定义边界的顶点,使用命令 plot(polyout) 绘制形状。

示例

[polyout,vertexID] = boundaryshape(TR) 还返回向量 vertexID,它将 polyshape 的顶点映射到三角剖分的顶点。

示例

全部折叠

创建并绘制简单的 triangulation 对象。

P = [2.5 8.0;
     6.5 8.0;
     2.5 5.0;
     6.5 5.0;
     1.0 6.5;
     8.0 6.5];
T = [5 3 1;
     3 2 1;
     3 4 2;
     4 6 2];
TR = triangulation(T,P);
triplot(TR)
xlim([0 9])
ylim([4.5 8.5])

2-D triangulation with four triangles connecting six vertices

创建并绘制一个 polyshape 对象,其边界等于三角剖分的边界。

polyout = boundaryshape(TR);
plot(polyout)

Filled hexagonal polygon representing the outer boundary of the triangulation

创建并绘制 triangulation 对象。

T = [5 1 3;
     6 1 4;
     5 4 1;
     2 6 3;
     3 6 5;
     2 1 6];
P = [3 0.5;
     3.5 1.5;
     4 0.5;
     3.25 0.6;
     3.75 0.6;
     3.5 1];
TR = triangulation(T,P);
triplot(TR)
xlim([2.8 4.2])
ylim([0.4 1.8])

2-D triangulation with six triangles arranged around a central void

创建并绘制一个 polyshape 对象,其边界等于三角剖分的边界。由于三角剖分的内部和外部闭合边界,polyout 同时包含孔边界和实心边界。

polyout = boundaryshape(TR)
polyout = 
  polyshape with properties:

      Vertices: [7×2 double]
    NumRegions: 1
      NumHoles: 1

plot(polyout)

Filled triangular polygon with a smaller triangular hole in the center

输入参数

全部折叠

三角剖分,指定为二维 triangulation 对象或二维 delaunayTriangulation 对象。

输出参量

全部折叠

输出 polyshape,以 polyshape 对象形式返回。

顶点标识,以整数向量形式返回。vertexID 中的每个元素对应于 Points 属性中三角剖分顶点的行号。vertexID 的长度等于 polyshape 对象的 Vertices 属性中的行数。

数据类型: double

版本历史记录

在 R2018b 中推出