function [qin,ind]=hull3int1(q)

% HULL3INT1   Interactive test routine for hull3d.
%
%             Example: axis([0 1 0 1 0 1]);
%                      [in,index]=hull3int1(rand(100,3))                    
%
%             Christian C. Beardah 1998

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

hold on;

c=input('Centre of sphere (3 by 1 vector): ');
r=input('Radius of sphere: ');

t=0:pi/20:2*pi;
for i=-pi:pi/8:pi,
   plot3(c(1)+r*sin(i)*cos(t),c(2)+r*sin(i)*sin(t),c(3)+r*cos(i)*ones(size(t)),'y:');
end;

for i=1:length(q),
   in(i) = norm(q(1:3,i)-c)<r;
end;

qin = q(1:3,in==1)';
ind = q(4,in==1)';

hold off;