function [qin,ind]=hull2int(q)

% HULL2INT    Interactive test routine for hull2d.
%
%             Example: axis([0 1 0 1]);
%                      [in,index]=hull2int(rand(100,2))                    
%
%             Christian C. Beardah 1998

q=q';
q(3,:)=1:length(q);

hold on;
b=1;
i=1;

while b~=3,
  [x,y,b]=ginput(1);
  plot(x,y,'wd');
  p(i,:)=[x y]; i=i+1;
end;  

v = hull2d(p)'; % hull2d wants nx2 data
plot(v(1,:),v(2,:),'w:');

in = outhul2d(q(1:2,:),v); % outconvex returns the number of violations,
qin = q(1:2,in==0)';       % so you need to form a logical vector with out>0
ind = q(3,in==0)';

hold off;