function r = relpar(segs,t)
%
% relpar: computes the parallel relation
% 
% On input:
%    segs: output of seginfo
%    t: angle in degrees within which two lines must be to be parallel
% On output:
%   r: Boolean encoding of parallel relation (0 -> False; 1-> True)
%

[m,n] = size(segs);
r = zeros(m,m);
for i1 = 1:m-1
  x11 = 0; y11 = segs(i1,2)*x11 + segs(i1,3);
  x12 = 1; y12 = segs(i1,2)*x12 + segs(i1,3);
  x12 = 1-x11; y12 = y12-y11;
  l1 = sqrt(x12^2 + y12^2);
  if segs(i1,1)>4
    for i2 = i1+1:m
	  if segs(i2,1)>4
        x21 = 0; y21 = segs(i2,2)*x21 + segs(i2,3);
        x22 = 1; y22 = segs(i2,2)*x22 + segs(i2,3);	
		x22 = x22-x21; y22 = y22-y21;
		l2 = sqrt(x22^2 + y22^2);
		ti1i2 = (180/pi)*acos((x12*x22 + y12*y22)/(l1*l2));
        if ti1i2<t
	      r(i1,i2) = 1;
	    end
	  end
    end
  end
end
