pro qd_posang, pa, longin, lat, longout
;+
; NAME:
;	QD_POSANG
;
;
; PURPOSE:
;	Quick and dirty routine to compute tracks of specified
;	position angles.
;
;
; CATEGORY:
;	Utils
;
;
; CALLING SEQUENCE:
;	qd_posang, pa, longin, lat, longout
;
;
; INPUTS:
;	pa	float	The desired position angle (all 4 quadrants
;			are generated)
;	longin	float	The elongations at which to calculate its
;			latitude
;
;
; OUTPUTS:
;	lat	float	The latitudes computed
;	longout	float	The longitudes of those latitudes.
;
; RESTRICTIONS:
;	Only angles between 0 and 90 exclusive really mean anything.
;
;
; MODIFICATION HISTORY:
;	Original: 17/6/03; SJT
;-

locs = where(abs(longin) eq 90, np)
if np ne 0 then longin[locs] = longin[locs]+0.01

tl = tan(longin*!dtor)
cat = cos(atan(tl, sin(pa*!dtor)))
cl = cos(longin*!dtor)
locs = where(abs(cl) ge abs(cat), nv)

if nv eq 0 then return

lat = acos(cat[locs]/cl[locs])*!radeg
longout = longin[locs]

locs = where(lat gt 90., no)
if no ne 0 then lat[locs] = 180-lat[locs]

longout = [longout,  reverse(longout)]
lat = [lat,  -reverse(lat)]

end
