makshape.m
function D = makshape
% Allows user to create a 2D shape using picks in the graphics
% window. The shape is stored in array D where the 1st column
% is vector of x-coordinates, 2nd column is vector of y-coordinates
%
% USAGE: D = makshape
%
% to make the shape:
% LEFT MOUSE BUTTON - pick a point
% RIGHT MOUSE BUTTON - end shape creation
clf
fx = [-10 10 10 -10 -10];
fy = [-10 -10 10 10 -10];
plot(fx,fy) % draws a 10 X 10 frame
axis('equal')
hold on
i = 0;
b = 1;
while b < 2 % read picks until right button
[tx, ty, b] = ginput(1); % read single pick point and button
if b == 1 % left button -> store point coordinates and plot
i = i+1;
x(i) = tx; y(i) = ty;
plot(tx,ty,'b+')
end
end
D(:,1) = x';
D(:,2) = y';
x(i+1) = x(1);
y(i+1) = y(1);
plot(x,y)