function b = dopen(f1,f2,dif,i1,j1,dir1,i2,j2,dir2)
%
% Returns 1 for f1 and f2 opposed and aimed away from each other
%         0 otherwise
%   b = dopen(f1,f2,dif,i1,j1,dir1,i2,j2,dir2)
%
d2r = pi/180;
b = 0;    % initialize as false

if (length(f1)<1) | (length(f2)<1)
  return;
end;
opp = oppdir(f1,f2,dif);
if opp>0
  d = sqrt((j2-j1)^2 + (i2-i1)^2);
  u(1) = (j2-j1)/d;
  u(2) = (i2-i1)/d;
  theta1 = dir1*45*d2r;
  v(1) = cos(theta1);
  v(2) = sin(theta1);
  theta2 = dir2*45*d2r;
  w(1) = cos(theta2) + d*u(1);
  w(2) = sin(theta2) + d*u(2);
  t1 = u*v';
  t2 = u*w';
  if (t1<0) & (d<t2)
    b = 1;   % true
  end;
end;
