MATLAB 帮助中心
对 polyshape 区域进行排序
polyshape
polyout = sortregions(polyin,criterion,direction)
polyout = sortregions(polyin,'centroid',direction,'ReferencePoint',point)
polyout = sortregions(polyin,criterion,direction) 返回根据指定的 criterion 和 direction 对区域进行排序后的 polyshape 对象。例如,polyout = sortregions(polyin,'area','ascend') 返回实心区域与 polyin 相同并按面积升序排列后的 polyshape。
polyin
criterion
direction
polyout = sortregions(polyin,'area','ascend')
示例
polyout = sortregions(polyin,'centroid',direction,'ReferencePoint',point) 返回根据每个区域的矩心到参考点的距离对区域进行排序后的 polyshape。
'centroid'
point
全部折叠
首先对多边形的区域进行排序,以确定和访问每个区域。
创建包含两个实心区域和一个孔的多边形。
t = 0.05:0.5:2*pi; x1 = cos(t); y1 = sin(t); x2 = 0.5*cos(t); y2 = 0.5*sin(t); x3 = 2*cos(t); y3 = 2*sin(t); polyin = polyshape({x1,x2,x3},{y1,y2,y3})
polyin = polyshape with properties: Vertices: [41×2 double] NumRegions: 2 NumHoles: 1
plot(polyin)
根据多边形每个区域的周长按升序对区域进行排序。然后可以使用 regions 函数创建一个 polyshape 对象数组 R,R 的每个元素对应于 polyout 的一个区域。R 的元素与 polyout 的区域按同样的顺序进行索引,因此您可以根据索引来访问和计算每个区域。
regions
R
polyout
polyout = sortregions(polyin,'perimeter','ascend'); R = regions(polyout); plot(R)
smallregion = area(R(1))
smallregion = 0.7541
bigregion = area(R(2))
bigregion = 9.0488
输入 polyshape,指定为标量、向量、矩阵或多维数组。
数据类型: polyshape
'area'
'perimeter'
'numsides'
排序标准,指定为下列值之一:
'area' - 按区域的面积排序。
'perimeter' - 按区域的周长排序。
'numsides' - 按每个区域的边数排序。
'centroid' - 按每个区域的矩心到参考点 (0,0) 的距离排序。
'ascend'
'descend'
排序方向,指定为 'ascend' 或 'descend'。
[0 0]
参考点,指定为二元素行向量。第一个元素是参考点的 x 坐标,第二个元素是 y 坐标。
在 R2017b 中推出
sortboundaries | polyshape | regions
sortboundaries
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
欧洲
亚太
联系您当地的办事处