function PT = get_latlon(Azp,delta,pto)
%|--------------------------------------------------------------|
%| function PT = get_latlon(Azp,delta,pto)			|
%| Function to calculate coordinate of a point PT in		|
%|    [lon,lat] given the declination (azimuth) and a   	|
%|    point <pto> a distance delta (deg) away			|     PT-_ 
%| Input:							|      \  -_delta  
%|    Azp -  Azimuth of the great circle where PT lies [Nx1]	|	\   -_ pto
%|    pto -  Point O on great circle containing PT & O [Nx3]	|	 \ az /
%|    delta - distance in degree b/t PT and pto			|	  \  /
%| Output:							|	   S
%|    PT  -  Coordinate [lon,lat,topo] [Nx3]			|	 outh Pole
%| ATN 10.15.03							|
%|--------------------------------------------------------------|

if(max(size(Azp))==1);Azpp=Azp.*ones(size(pto,1),1);else;Azpp=Azp;end;

% -- get smaller angle of Azp
%i1=find(Azpp>180);if(isempty(i1)==0);Azpp(i1)=Azpp(i1)-180;end;clear i1
%i1=find(Azpp<-180);if(isempty(i1)==0);Azpp(i1)=360+Azpp(i1);end;clear i1

thetao=(90-pto(:,2)).*pi./180;		%co-latitude (rad)
deltar=delta*pi/180;				%rad
Azppr=Azpp.*pi/180;				%rad
thetaN = acos(cos(thetao).*cos(deltar)+sin(thetao).*sin(deltar).*cos(Azppr)).*180./pi;%deg
latN=90-thetaN;

deltaPhiN = asin(sin(deltar).*sin(Azppr)./sin(thetaN.*pi./180)).*180./pi;%deg
phiN = pto(:,1) + deltaPhiN;

PT=[phiN,latN,pto(:,3)];

return
