Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function diffcalc(form) {
- coc1 = (document.form.format.options[document.form.format.selectedIndex].value);
- aperture = (document.form.aperture.options[document.form.aperture.selectedIndex].value);
- unit = form.unit.value;
- view_dist = (form.view_dist.value) / 100;
- print_size = form.print_size.value;
- eyesight = (document.form.eyesight.options[document.form.eyesight.selectedIndex].value);
- megapixels = form.megapixels.value;
- if (isNaN(print_size)) {
- alert('Please enter a numerical value for the maximum print dimension.');
- document.form.print_size.focus();
- document.form.print_size.select();
- }
- if (isNaN(megapixels)) {
- if (megapixels != "?") {
- alert('Please enter a numerical value for the megapixel resolution.');
- document.form.megapixels.focus();
- document.form.megapixels.select();
- }
- }
- if (megapixels == "?") {
- form.pix_out.value = "?";
- } else {
- if (coc1 < 0.0165) {
- aspectratio = 4 / 3;
- } else {
- aspectratio = 3 / 2;
- }
- pixelsize = (coc1 / 0.032) * 43266.6 / (Math.sqrt(aspectratio * megapixels * 1e6) * Math.sqrt(1 + 1 / (aspectratio * aspectratio)));
- form.pix_out.value = Math.round(10 * pixelsize) / 10 + " \u00B5" + "m";
- }
- if (document.form.usepixels.checked == true) {
- if (megapixels == "?") {
- alert('Please enter a numerical value for the megapixel resolution.');
- document.form.megapixels.focus();
- document.form.megapixels.select();
- } else {
- CoC = 2.5 * pixelsize;
- form.coc_out.value = Math.round(100 * CoC) / 100 + " \u00B5" + "m";
- }
- } else {
- CoC = 1000 * coc1 * eyesight * (view_dist / 0.25) * (10 * unit / print_size);
- form.coc_out.value = Math.round(100 * CoC) / 100 + " \u00B5" + "m";
- }
- airy = 2.43932 * 546e-9 * aperture * 1e6;
- form.airy_out.value = Math.round(10 * airy) / 10 + " \u00B5" + "m";
- if (CoC < airy) {
- form.diff_out.value = "YES";
- } else {
- form.diff_out.value = "NO";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment