帮助中心帮助中心
对 polyshape 边界进行排序
polyshape
polyout = sortboundaries(polyin,criterion,direction)
polyout = sortboundaries(polyin,'centroid',direction,'ReferencePoint',point)
示例
polyout = sortboundaries(polyin,criterion,direction) 返回根据指定的 criterion 和 direction 对边界进行排序后的 polyshape 对象。例如,polyout = sortboundaries(polyin,'area','ascend') 返回边界与 polyin 相同的 polyshape。polyout 按面积升序列出边界。
polyin
criterion
direction
polyout = sortboundaries(polyin,'area','ascend')
polyout
polyout = sortboundaries(polyin,'centroid',direction,'ReferencePoint',point) 返回根据每个边界的矩心到参考点的距离对边界进行排序后的 polyshape。
'centroid'
point
全部折叠
根据边数对多边形的边界进行排序,以便一次访问一个边界。
创建包含两个边界的多边形,一个边界有三条边,另一个有四条边。
x1 = [0 1 1 0]; y1 = [0 0 1 1]; x2 = [2 3 2.5]; y2 = [2 2 3]; polyin = polyshape({x1,x2},{y1,y2}); plot(polyin)
根据边数按降序对边界进行排序,以便在输出 polyshape 对象中先对有四条边的边界进行索引。
polyout = sortboundaries(polyin,'numsides','descend');
现在您可以基于边界的索引来引用有四条边的边界,例如,当您要访问该边界的顶点或计算其面积时,就可以这样做。
[x,y] = boundary(polyout,1)
x = 5×1 0 0 1 1 0
y = 5×1 0 1 1 0 0
area(polyout,1)
ans = 1
输入 polyshape,指定为标量、向量、矩阵或多维数组。
数据类型: polyshape
'area'
'perimeter'
'numsides'
排序标准,指定为下列值之一:
'area' - 按边界的面积排序。
'perimeter' - 按边界的周长排序。
'numsides' - 按每个边界的边数排序。
'centroid' - 按每个边界的矩心到参考点 (0,0) 的距离排序。
'ascend'
'descend'
排序方向,指定为 'ascend' 或 'descend'。
[0 0]
参考点,指定为二元素行向量。第一个元素是参考点的 x 坐标,第二个元素是 y 坐标。
用法说明和限制:
必须启用动态内存分配才能进行代码生成。
名称-值参量必须为编译时常量。
输出 polyshape 对象中的边界顺序可能与 MATLAB 中的不同。但是,将根据指定的输入标准对边界进行排序。
在 R2017b 中推出
rmboundary | sortregions | boundary | polyshape
rmboundary
sortregions
boundary
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office