pro qd_elong, elong, longin, lat, longout
;+
; NAME:
;	QD_ELONG
;
;
; PURPOSE:
;	Quick & dirty routine to calculate path of lines of a given
;	elongation 
;
;
; CATEGORY:
;	utils
;
;
; CALLING SEQUENCE:
;	qd_elong, elong, longin, lat, longout
;
;
; INPUTS:
;	elong	float	The elongation line desired.
;	longin	float	The longitudes at which to calculate its
;			latitude
;
;
; OUTPUTS:
;	lat	float	The latitudes computed
;	longout	float	The longitudes of those latitudes.
;
;
; RESTRICTIONS:
;	Care must be take with elongations > 90 to ensure that there
;	are no discontinuities in the outputs (only do one side and
;	start from the edge).
;
;
; MODIFICATION HISTORY:
;	Original: 17/6/03; SJT
;	Add dirty fix for the broken lines at 80 & 100: 24/7/03; SJT
;-

er = elong*!dtor
cl = cos(longin*!dtor)
locs = where(abs(cl) ge cos(er)*0.9999, nv)

if nv eq 0 then return

lat = acos((cos(er)/cl[locs]) < 1.0 > (-1.0))

longout = longin[locs]
lat = lat*!radeg

longout = [longout, reverse(longout)]
lat = [lat, -reverse(lat)]
locs = where(abs(lat) le 90.,  nv)
if nv ne 0 then begin
    lat = lat[locs]
    longout = longout[locs]
endif

end
