function []=compass2(w,linetype)
%COMPASS2 Compass plot.
%       COMPASS2(Z) draws a graph that displays the angle and magnitude
%       of the complex elements of Z as arrows emanating from the origin.
%
%       COMPASS2(Z,'S') uses line style 'S' where
%       'S' is any legal linetype as described under the PLOT command.
%
%  Rich Signell  12-19-91
%  USGS, Woods Hole
%  rsignell@crusty.er.usgs.gov

i=sqrt(-1);
%
%  Geometry of arrowheads (choosing HEADA and HEADL):
%    If the arrow is defined by the points A B C B D where A is the base of 
%  the arrow, B is the head, and C and D are the corners of the arrowhead, then
%  HEADA is the angle BAC (or BAD), and HEADL is the ratio of distances AC/AB.
%
HEADA=5*pi/180; HEADL=.75;
w=w(:);
z=zeros(w/w(1));
z=z(:);
if nargin ==1,
  linetype='r-';
end
r=w*HEADL; wr1=r*exp(+i*HEADA); wr2=r*exp(-i*HEADA);
wplot=ones(length(z),5); 
wplot(:,1)=z; 
wplot(:,[2 4])=(z+w)*ones(1,2);
wplot(:,3)=z+wr1; wplot(:,5)=z+wr2;
polar(angle(wplot)',abs(wplot)',linetype);
