function in = InBox(rn,BoxWidth,BoxLength1, BoxLength2)
%function in = InBox(rn,BoxWidth,BoxLength1, BoxLength2)
%Check if coordinate is inside box.
BoxWidthD2=BoxWidth/2;
if (rn(1)<-BoxWidthD2| rn(2)<-BoxWidthD2| rn(3)<BoxLength1)
   in= 0;
elseif (rn(1)>BoxWidthD2| rn(2)>BoxWidthD2 | rn(3)>BoxLength2)
   in= 0;
else
   in = 1;
end
