PixelsPerDegree.m 874 B

1234567891011121314151617181920212223
  1. % function PixelsPerDegree:
  2. %
  3. % This function returns the approximation of pixels per degree for each
  4. % dimension. It doesn't take into account the change in distance as we move to
  5. % the edges of the monitor.
  6. %
  7. % input:
  8. % width - width of monitor in meters
  9. % height - height of monitor in meters
  10. % distance - distance of the viewer in meters
  11. % widthPixels - width of moitor in pixels
  12. % heightPixels - height of monitor in pixels
  13. % output:
  14. % pxPerDeg - pixels per degree on X axis(approx.)
  15. % pyPerDeg - pixels per degree on Y axis(approx.)
  16. function [pxPerDeg, pyPerDeg] = PixelsPerDegree(width, height, distance, widthPixels, heightPixels)
  17. thetaWtotal = 2*atan(width/(2*distance))*180/pi;
  18. thetaHtotal = 2*atan(height/(2*distance))*180/pi;
  19. pxPerDeg = widthPixels/thetaWtotal;
  20. pyPerDeg = heightPixels/thetaHtotal;
  21. end