1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| function [ xs, ys, alphas, betas ] = get_agents(radius, angle, numPts)
function set_title(n)
if (n==0)
title('');
elseif (n>0)
if (angle==360)
title(['Select positions of ' num2str(n) ' agents']);
else
title(['Select positions and orientations of ' num2str(n) ' agents']);
end
else
if (angle==360)
title('Select agent positions and press Enter');
else
title('Select agent positions and orientations and press Enter');
end
end
end
% Setup
if (nargin<3)
numPts=-1;
end
xs=[];
ys=[];
alphas=[];
betas=[];
% Get points
for i=1:50
% Get a position
set_title(numPts-i+1)
if (numPts>0) && (length(xs)==numPts)
press_space
break;
end
[x,y]=ginput(1);
if (length(x)<1)
break
end
xs=[xs;x];
ys=[ys;y]; |