calcunitcoordinates.m 689 B

123456789101112131415161718
  1. function [xx,yy] = calcunitcoordinates(res)
  2. % function [xx,yy] = calcunitcoordinates(res)
  3. %
  4. % <res> is the number of pixels on a side
  5. %
  6. % return <xx> and <yy> which contain x- and y-coordinates corresponding
  7. % to equally spaced points within the space bounded by -.5 and .5.
  8. % these points can be treated as centers of pixels.
  9. %
  10. % example:
  11. % [xx,yy] = calcunitcoordinates(2);
  12. % isequal(xx,[-.25 .25; -.25 .25]) & isequal(yy,[.25 .25; -.25 -.25])
  13. % notice that the second argument proceeds from .5 to -.5.
  14. % this ensures that the results match the usual coordinate axes
  15. % where the top is the positive y-axis.
  16. [xx,yy] = meshgrid(linspacepixels(-.5,.5,res),linspacepixels(.5,-.5,res));