function [qin,ind]=hull3int2(q)

% HULL3INT2   Interactive test routine.
%
%             Example: axis([0 1 0 1 0 1]);
%                      [in,index]=hull3int2(rand(100,3))
%
%             Christian C. Beardah 1999

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

hold on;

xr=input('x range(2 by 1 vector): ');
yr=input('y range(2 by 1 vector): ');
zr=input('z range(2 by 1 vector): ');

xc=[xr(1) xr(1) xr(2) xr(2) xr(1)];
yc=[yr(1) yr(2) yr(2) yr(1) yr(1)];
zc=[zr(1) zr(1) zr(1) zr(1) zr(1)];
plot3(xc,yc,zc,'--')
xc=[xr(1) xr(1) xr(2) xr(2) xr(1)];
yc=[yr(1) yr(2) yr(2) yr(1) yr(1)];
zc=[zr(2) zr(2) zr(2) zr(2) zr(2)];
plot3(xc,yc,zc,'--')
xc=[xr(1) xr(1)];
yc=[yr(1) yr(1)];
zc=[zr(1) zr(2)];
plot3(xc,yc,zc,'--')
xc=[xr(1) xr(1)];
yc=[yr(2) yr(2)];
zc=[zr(1) zr(2)];
plot3(xc,yc,zc,'--')
xc=[xr(2) xr(2)];
yc=[yr(2) yr(2)];
zc=[zr(1) zr(2)];
plot3(xc,yc,zc,'--')
xc=[xr(2) xr(2)];
yc=[yr(1) yr(1)];
zc=[zr(1) zr(2)];
plot3(xc,yc,zc,'--')

for i=1:length(q),
   xin = ((q(1,i) > xr(1)) & (q(1,i) < xr(2)));
   yin = ((q(2,i) > yr(1)) & (q(2,i) < yr(2)));
   zin = ((q(3,i) > zr(1)) & (q(3,i) < zr(2)));
   in(i) = (xin & yin & zin);
end;

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