ppd2distance.m 651 B

123456789101112131415161718192021
  1. % ppd2distance.m
  2. %
  3. % This function convert pixels per degree to a pair of two distances for a
  4. % monitor based experiment. It takes as input the distance from the monitor and
  5. % returns the second dimension
  6. %
  7. % input:
  8. % ppd - pixels per degree
  9. % pixNum - number of pixels
  10. % distance - distance from monitor. This can be any number since the system is
  11. % underdetermined
  12. %
  13. % output:
  14. % monitorDim - monitor size for the provided data
  15. function monitorDim = ppd2distance(ppd, pixNum, distance)
  16. thetaDeg = pixNum / ppd;
  17. thetaRad = thetaDeg * pi / 180;
  18. monitorDim = 2 * distance * tan(thetaRad / 2);
  19. end