pro dist_circle ,im, n, xcen ,ycen, DOUBLE = double On_error,2 ;Return to caller if an error occurs if N_params() LT 2 then begin print,'Syntax - DIST_CIRCLE, im, n,[ xcen, ycen, /DOUBLE ]' print,'IM - output image array' print,'N - size of the output image array, scalar or 2 element vector' print,'XCEN,YCEN - position from which to specify distances' return endif if N_elements(N) EQ 2 then begin nx = n[0] ny = n[1] endif else if N_elements(N) EQ 1 then begin ny = n nx = n ;Make a row endif else message, $ 'ERROR - Output size parameter N must contain 1 or 2 elements' if N_params() LT 4 then begin xcen = (nx-1)/2. & ycen = (ny-1)/2. endif if keyword_set(DOUBLE) then begin x_2 = (dindgen(nx) - xcen) ^ 2 ;X distances (squared) y_2 = (dindgen(ny) - ycen) ^ 2 ;Y distances (squared) im = dblarr( nx, ny, /NOZERO) ;Make uninitialized output array endif else begin x_2 = (findgen(nx) - xcen) ^ 2 ;X distances (squared) y_2 = (findgen(ny) - ycen) ^ 2 ;Y distances (squared) im = fltarr( nx, ny, /NOZERO) ;Make uninitialized output array endelse for i = 0L, ny-1 do begin ;Row loop im[0,i] = sqrt(x_2 + y_2[i]) ;Euclidian distance endfor return end