Viewing contents of file '../idllib/sdss/allpro/compute_sep.pro'
pro compute_sep,cat,index,sep,pa
;+
; NAME:
; COMPUTE_SEP
; PURPOSE:
; compute the seperation in arc seconds and position angle
; between an objects two children if it has two children
; position angle is an angle between 0 degrees and 180 degrees
; NOT 0 to 360
; so it is not really the position angle of ONE with
; respect to the OTHER (ie. it is order independent)
; 0 degrees is horizontal and 90 degrees vertical
; cat is the sdss photo structure and index is the index of the parent
; assumes two children are indices index+1 and index+2
;
; CALLING SEQUENCE:
; compute_sep,cat,index,separation,position_angle
;
;Revision History:
; David Johnston 5/20/99
;-
if n_params() LT 2 then begin
print,'-syntax compute_sep,cat,index,sep,pa'
return
endif
if cat(index).nchild ne 2 then begin
print,'COMPUTE_SEP : object must have two children'
print,'to compute seperation and pa'
endif
c1=cat(index+1).objc_colc
c2=cat(index+2).objc_colc
r1=cat(index+1).objc_rowc
r2=cat(index+2).objc_rowc
dc=c1-c2
dr=r1-r2
sep=.4*sqrt(dc^2+dr^2)
;.4 arcsec /pixel for sdss only
if sep lt .04 then begin
;sep less than .1 pixels so define pa to be 0 by default
;since it is not really meaningful
pa=0.0
endif else begin
pa=atan(dr,dc)
endelse
pa=pa*180.0/3.14159
if pa lt 0 then pa=180+pa
return
end