⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 orderaroundconvexhull.m

📁 Matlab程序
💻 M
字号:
function [polyBoundaryCellOut, indVec] = OrderAroundConvexHull( polyBoundaryCell )

%orders the polygons clockwise along their convex hull

numPolys = length(polyBoundaryCell);


allPointsVec = [];
    indVec = [ ];
for polyLoop = 1:numPolys
    allPointsVec = [allPointsVec, polyBoundaryCell{polyLoop}];
    indVec = [indVec, polyLoop * ones(1, size(polyBoundaryCell{polyLoop},2) ) ];
end

k = convhull(allPointsVec(1,:), allPointsVec(2,:));

indVec = indVec(k);

for polyLoop = 1:numPolys
    
    ind = find(indVec == polyLoop);
    indVec(ind(2:end)) = 0;
end

indVec = indVec(find(indVec));

assert('length(indVec) == numPolys', 'not all polys on the convex hull')


for polyLoop = 1:numPolys
   polyBoundaryCellOut{polyLoop} = polyBoundaryCell{indVec(polyLoop)};
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -