function b = oppdir(f1,f2,dif)
%
% Checks that all elements of f1 are opposite in direction to f2
% by dif or more
%     b = oppdir(f1,f2,dif)
% Returns:  0   if false
%           1   if true
%
dist8 = [0,1,2,3,4,3,2,1;
         1,0,1,2,3,4,3,2;
		 2,1,0,1,2,3,4,3;
		 3,2,1,0,1,2,3,4;
		 4,3,2,1,0,1,2,3;
		 3,4,3,2,1,0,1,2;
		 2,3,4,3,2,1,0,1;
		 1,2,3,4,3,2,1,0];
		 
val1 = zeros(1,8); val2 = zeros(1,8);
for index = 1:length(f1)
  val1(f1(index)+1) = 1;
end;
for index = 1:length(f2)
  val2(f2(index)+1) = 1;
end;
mindif = 4;
for i1 = 1:8
  if val1(i1)>0
    for i2 = 1:8
	  if val2(i2)>0
	    dif12 = dist8(i1,i2);
		mindif = min(mindif,dif12);
%i1
%i2
%dif12
	  end;
	end;
  end;
end;
if mindif>=dif
  b = 1;
else
  b = 0;
end;
