【发布时间】:2013-05-22 22:35:14
【问题描述】:
如果我在 matlab 的图中有随机排序的点,并且在绘制时会产生各种闭合形状。给定一个封闭形状左侧的特定点,我如何才能以矢量形式获取该形状的所有点,记住收集点的惯例是顺时针方向移动。
【问题讨论】:
-
也许这个question/answer对你有帮助?
标签: matlab
如果我在 matlab 的图中有随机排序的点,并且在绘制时会产生各种闭合形状。给定一个封闭形状左侧的特定点,我如何才能以矢量形式获取该形状的所有点,记住收集点的惯例是顺时针方向移动。
【问题讨论】:
标签: matlab
注释示例:
cla
% Random data
x = rand(15,1);
y = rand(15,1);
scatter(x,y)
% Random point to the left
hold on
p = [-0.1, rand(1)*0.2 + 0.5];
plot(p(1),p(2),'*r')
% Separate points that lie above your point
idx = y >= p(2);
% Sort x then y increasing for upper half and x then y decreasing for lower half
shape = [sortrows([x( idx) y( idx)],[1 2])
sortrows([x(~idx) y(~idx)],[-1 -2])];
通过绘制一条空线检查shape 是否包含顺时针排序的坐标:
% Plot clockwise open line
plot(shape(1:end ,1),shape(1:end,2),'k')
【讨论】: