function  [gr,z] = make_grid(n,st)

%MAKE_GRID -- Make a linear grid with N elrmrnts, centered on 0
%
% [gr,z] = make_grid(n,st)
% 
% N is a positive integer specifying the number of points on the grid.
% ST defines the distance b/n any two points on the grid.
%
% The result GR is a row vector of length N centered around zero.
% Z is the origin of the new coordinate system.
%
% Example: For odd N, the middle pixel is exactly zero:
%   [gr,z] = make_grid(5,0.5)  ==>  gr = [-1 -0.5 0 0.5 1], z = 3
%
% Example: For even N, the two middle pixels bracket the zero:
%   [gr,z] = make_grid(4,0.5)  ==>  gr = [-.75 -.25 .25 .75], z = 2.5
%
% Conversion between world coordinates and pixel indices
%   ix = x./st+z     % perhaps round(...)
%    x = (ix-z).*st
%
% See also MESHGRID, NDGRID, FFTMESH.

%
% Original coding by Alex Petrov, Ohio State University
% $Revision: 1.0 $  $Date: 2006/06/06 16:43 $
%
% Part of the utils toolbox version 1.1 for MATLAB version 5 and up.
% http://alexpetrov.com/softw/utils/
% Copyright (c) Alexander Petrov 1999-2006, http://alexpetrov.com
% Please read the LICENSE and NO WARRANTY statement in ../utils_license.m

gr = [0.5:n-0.5] .* st ;
gr = gr - (gr(ceil(n/2)) + gr(ceil((n+1)/2)))./2 ;
z = 1 - gr(1)/st ;

%--- Return GR and z
%%%%% End of file MAKE_GRID.M
