function [x,y,range,bearing]=ll2xy(lat1,long1,lat2,long2,iinm,timelab,zlab)
% Call [x,y,range,bearing]=ll2xy(lat1,long1,lat2,long2,iinm,timelab,zlab)
% latitude in deg (pos for North, neg for South);
% longitude in deg (pos for East, neg for West);
% (lat1,long1) is at origin; range in km or nm; bearing in deg E of N;
% iinm=1 for nautical miles; iinm=0 for km;
% timelab (optional) is used to label points with times;
% zlab (optional) is used to label the origin.
[range,bearing]=ll2rb(lat1,long1,lat2,long2,iinm);
phi=(pi/2 - bearing); bearing=bearing*180/pi;
x=range.*cos(phi); y=range.*sin(phi);
if nargin>5,
	figure; hold on;
	plot_cfill2(x,y,'o','r',6); plot(x,y,'r-');
	plot_cfill2(0,0,'s','b',6); 
	%ax=axis; square_plot(ax); 
	xlabel('East-West Position  Ð km'); ylabel('North-South Position  Ð km');
	nlab=length(timelab);
	text(x,y,num2str(timelab(:),4));
%	for j=1:nlab,
%		text(x(j,:),y(j,:),num2str(timelab(j)));
%	end
	if nargin > 6,
		text(0,0,zlab);
	end
	axis('equal'); grid;
end
%
% COPYRIGHT (c) 2008
% 
% Applied Research Laboratories, The University of Texas at Austin
% (ARL:UT)
% All rights reserved.
% 
% This material may be reproduced by or for the U.S. Government
% only. This notice must appear in all copies of this file and its
% derivatives. Further distribution outside the U.S. Government is
% prohibited without the explicit written authorization from the
% Director of the Environmental Sciences Laboratory, ARL:UT.
% 
% THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
% EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE
% IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
% PURPOSE, OR NONINFRINGEMENT.
% 
% IN NO EVENT WILL ARL:UT BE LIABLE FOR ANY DAMAGES WHATSOEVER ARISING
% OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN IF ARL:UT HAS
% BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
