;+ ; NAME: ; makerho ; ; PURPOSE: ; Creates an array whose values are the distances ; from the center of each pixel in the array. ; ; CATEGORY: ; Geometry, computed holography ; ; CALLING SEQUENCE: ; rho = makerho() ; ; INPUTS: ; none ; ; KEYWORD PARAMETERS: ; cal: [xc,yc,xfac] coordinates of optical axis on SLM face ; and scale factor for x-coordinate. ; Setting this parameter overrides global ; calibrations. ; nocal : if set, ignore CAL and do not use global ; calibration constants. ; dim : one- or two-component specification of the phase-mask's ; dimensions. If set, overrides and **overwrites** ; global calibrations. ; ; OUTPUTS: ; theta: array of angles around center, in radians ; ; COMMON BLOCKS: ; HOLO_COMMON: ; Contains global calibration constants. ; ; PROCEDURE: ; straightforward. ; ; EXAMPLE: ; rho = makerho() ; ; MODIFICATION HISTORY: ; 10/8/2004 David G. Grier, New York Universty, created. ; 06/05/2006: DGG. Use calibration constants from HOLO_COMMON. ; Added NOCAL keyword. ; ; Copyright (c) 2006 David G. Grier ; ; LICENSE ; ; This program is free software; you can redistribute it and/or ; modify it under the terms of the GNU General Public License as ; published by the Free Software Foundation; either version 2 of the ; License, or (at your option) any later version. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ; General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with this program; if not, write to the Free Software ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ; 02111-1307 USA ; ; If the Internet and WWW are still functional when you are using ; this, you shold be able to access the GPL here: ; http://www.gnu.org/copyleft/gpl.html ;- function makerho, dim = dim, cal = cal, nocal = nocal common holo_common, c w = c.doe_w h = c.doe_h if n_elements(dim) ge 1 then begin w = dim[0] if n_elements(dim) eq 2 then $ h = dim[1] $ else $ h = w c.doe_w = w c.doe_h = h endif if keyword_set(nocal) then begin xc = 0. yc = 0. xfac = 1. endif else if n_elements(cal) ge 2 then begin xc = double(cal[0]) yc = double(cal[1]) if n_elements(cal) ge 3 then $ xfac = double(cal[2]) endif else begin xc = c.xc yc = c.yc xfac = c.xscale endelse x = (findgen(w, h) mod w) - (w - 1.)/2. y = floor(findgen(w, h) / w) - (h - 1)/2. rho = sqrt((y - yc)^2 + (xfac*x - xc)^2) return, rho end