Guest User

Diffraction

a guest
Mar 14th, 2015
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function diffcalc(form) {
  2.     coc1 = (document.form.format.options[document.form.format.selectedIndex].value);
  3.     aperture = (document.form.aperture.options[document.form.aperture.selectedIndex].value);
  4.     unit = form.unit.value;
  5.     view_dist = (form.view_dist.value) / 100;
  6.     print_size = form.print_size.value;
  7.     eyesight = (document.form.eyesight.options[document.form.eyesight.selectedIndex].value);
  8.     megapixels = form.megapixels.value;
  9.     if (isNaN(print_size)) {
  10.         alert('Please enter a numerical value for the maximum print dimension.');
  11.         document.form.print_size.focus();
  12.         document.form.print_size.select();
  13.     }
  14.     if (isNaN(megapixels)) {
  15.         if (megapixels != "?") {
  16.             alert('Please enter a numerical value for the megapixel resolution.');
  17.             document.form.megapixels.focus();
  18.             document.form.megapixels.select();
  19.         }
  20.     }
  21.     if (megapixels == "?") {
  22.         form.pix_out.value = "?";
  23.     } else {
  24.         if (coc1 < 0.0165) {
  25.             aspectratio = 4 / 3;
  26.         } else {
  27.             aspectratio = 3 / 2;
  28.         }
  29.         pixelsize = (coc1 / 0.032) * 43266.6 / (Math.sqrt(aspectratio * megapixels * 1e6) * Math.sqrt(1 + 1 / (aspectratio * aspectratio)));
  30.         form.pix_out.value = Math.round(10 * pixelsize) / 10 + " \u00B5" + "m";
  31.     }
  32.     if (document.form.usepixels.checked == true) {
  33.         if (megapixels == "?") {
  34.             alert('Please enter a numerical value for the megapixel resolution.');
  35.             document.form.megapixels.focus();
  36.             document.form.megapixels.select();
  37.         } else {
  38.             CoC = 2.5 * pixelsize;
  39.             form.coc_out.value = Math.round(100 * CoC) / 100 + " \u00B5" + "m";
  40.         }
  41.     } else {
  42.         CoC = 1000 * coc1 * eyesight * (view_dist / 0.25) * (10 * unit / print_size);
  43.         form.coc_out.value = Math.round(100 * CoC) / 100 + " \u00B5" + "m";
  44.     }
  45.     airy = 2.43932 * 546e-9 * aperture * 1e6;
  46.     form.airy_out.value = Math.round(10 * airy) / 10 + " \u00B5" + "m";
  47.     if (CoC < airy) {
  48.         form.diff_out.value = "YES";
  49.     } else {
  50.         form.diff_out.value = "NO";
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment