% ----------------------------- GetMousePts.m --------------- % % function [x,y,MouseCorners] = GetMousePts; % % outputs: x,y = coordinates of points clicked, not including % last point (right button to exit) % MouseCorners = indices of points identified as % corners by the right button. function [x,y,MouseCorners] = GetMousePts; x=[]; y=[]; MouseCorners=[]; cont = 1; hold off, clf, axis([-1 1 -1 1]), grid, hold on while (cont) [xin,yin,button]=ginput(1); if (button==1) % left mouse click, noncorner point plot(xin,yin,'ro'); x=[x,xin];y=[y,yin]; elseif (button==3) % right mouse click, corner point plot(xin,yin,'b+') x=[x,xin];y=[y,yin]; MouseCorners=[MouseCorners,length(x)]; else % any key on keyboard hit, end of input cont = 0; end end