function adj_arw(strindex)

% function adj_arw(strindex)
%
% This function is used in conjunction with FD3.  It adjusts the arrow on the
% stream designated by FD3STREAMS(:,strindex) so that it is in the proper
% position.  'Strindex' may be a single stream index or a list of stream
% indices.  Arrows are always placed on the stream segments designated by the
% second-to-last and last xdata/ydata points.  See also 'make_arw'.
%
% ACP

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

global FD3SCALE FD3STREAMS

for i=strindex

   % Get xdata/ydata of stream.

   xdata=get(FD3STREAMS(1,i),'Xdata');
   ydata=get(FD3STREAMS(1,i),'Ydata');

   len=length(xdata);

   % Determine the angle of the last stream segment

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

   theta=atan2(dy,dx);

   % Determine the angles of the arrow sides

   theta1=theta+pi/6;
   theta2=theta-pi/6;

   arrowx=xdata(len)+[0 cos(theta1)*FD3SCALE/2 cos(theta2)*FD3SCALE/2];
   arrowy=ydata(len)+[0 sin(theta1)*FD3SCALE/2 sin(theta2)*FD3SCALE/2];

   % Give arrow its new x/ydata

   set(FD3STREAMS(3,i),'Xdata',arrowx,'Ydata',arrowy)

end
