function th=make_lbl(xdata,ydata,str)

% function h=make_lbl(xdata,ydata)
%
% This function is used in conjunction with FD3.  Given the 'xdata' and 
% 'ydata' for a stream, it creates a label, 'str', adjacent to the stream
% segment desigated by the second-to-last and last xdata/ydata points. The
% handle of the label, 'th', is returned.   See also 'adj_lbl'.
%
% ACP

% Last update:  July 7, 1993
% Author:       Adrian C. Penisson

global FD3SCALE

len=length(xdata);

% Get angle of last stream segment.

dy=ydata(len)-ydata(len-1);
dx=xdata(len)-xdata(len-1);

theta=atan2(dy,dx);

% Use that angle to find position of label.

if (theta>0 & theta<(pi/2)) | (theta>(-pi) & theta<(-pi/2))
   x=mean(xdata([len len-1]))-abs(sin(theta)*.6*FD3SCALE);
else
   x=mean(xdata([len len-1]))+abs(sin(theta)*.6*FD3SCALE);
end

y=mean(ydata([len len-1]))+abs(cos(theta)*.6*FD3SCALE);

% Make label

th=nice_txt(x,y,str,0);
