createconvexpolygon.m

来自「This set of files show some of the princ」· M 代码 · 共 14 行

M
14
字号
function [xpoly, ypoly , h] = CreateConvexPolygon(ContainingSquareWidth,NbPointsMax)
h = figure;

rectangle('Position',[0,0,ContainingSquareWidth,ContainingSquareWidth]);
rand('twister',0);
Points = ContainingSquareWidth * rand(NbPointsMax,2);
K = convhull(Points(:,1),Points(:,2));

xpoly = Points(K,1);
ypoly = Points(K,2);
hold on;

plot(xpoly,ypoly,'-r','LineWidth',2);

⌨️ 快捷键说明

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