modify return values of DOF to be front/rear DOF rather than near or far point. Corre...
authorKevin Rosenberg <kevin@rosenberg.net>
Sun, 9 Sep 2007 21:05:07 +0000 (15:05 -0600)
committerKevin Rosenberg <kevin@rosenberg.net>
Sun, 9 Sep 2007 21:05:07 +0000 (15:05 -0600)
debian/changelog
dof.lisp

index 822088b1ca4dac3d9288f6ff10b3e8539f0fd09f..7f718876de0e8032d91392335230684adda95178 100644 (file)
@@ -1,3 +1,9 @@
+cl-photo (0.12-1) unstable; urgency=low
+
+  * New upstream
+
+ -- Kevin M. Rosenberg <kmr@debian.org>  Sun,  9 Sep 2007 15:03:53 -0600
+
 cl-photo (0.12-1) unstable; urgency=low
 
   * Add new cameras
 cl-photo (0.12-1) unstable; urgency=low
 
   * Add new cameras
index f1cd7b245a71b07bd95e1afdcfcf81a5bc15bcce..917a20df3e34f76c46971343ff97b56f220f978f 100644 (file)
--- a/dof.lisp
+++ b/dof.lisp
@@ -86,22 +86,20 @@ Default resolving power is 5 lpm at 25cm."
 (defun dof-mm (focal-length f-stop distance coc &key (pupil-factor 1))
   "Returns depth of field based on focal-length, f-stop, distance, and coc.
 Six values are returned:
 (defun dof-mm (focal-length f-stop distance coc &key (pupil-factor 1))
   "Returns depth of field based on focal-length, f-stop, distance, and coc.
 Six values are returned:
-near point, far point, total dof, magnification, blur size at infinity (mm).
-Circle of confusion can either be a number or keyword designating format."
+near dof, far dof, total dof, magnification, blur size at infinity (mm).
+Circle of confusion can either be a number or keyword designating format.
+Reference: http://www.vanwalree.com/optics/dofderivation.html"
   (let* ((aperture (/ focal-length f-stop))
   (let* ((aperture (/ focal-length f-stop))
-         (numerator-1 (* (- pupil-factor 1) (- distance focal-length)
-                         coc focal-length))
-         (numerator-2 (* pupil-factor aperture focal-length distance))
-         (denominator-1 (* pupil-factor coc (- distance focal-length)))
-         (denominator-2 (* pupil-factor aperture focal-length))
-         (near (/ (+ numerator-1 numerator-2)
-                  (+ denominator-1 denominator-2)))
-         (far (/ (- numerator-1 numerator-2)
-                 (- denominator-1 denominator-2)))
+         (pd (* aperture pupil-factor))
+         (numerator (* coc (- distance focal-length) (+ focal-length (* pupil-factor (- distance focal-length)))))
+         (d1 (* pupil-factor coc (- distance focal-length)))
+         (d2 (* pd focal-length))
+         (front-dof (/ numerator (+ d1 d2)))
+         (rear-dof (/ numerator (- d1 d2)))
          (mag (float (/ focal-length (- distance focal-length))))
          (infinity-blur-diameter (/ (* mag focal-length) f-stop))
          (mag (float (/ focal-length (- distance focal-length))))
          (infinity-blur-diameter (/ (* mag focal-length) f-stop))
-         (depth (- far near)))
-    (values near far depth mag infinity-blur-diameter)))
+         (depth (+ front-dof rear-dof)))
+    (values front-dof rear-dof depth mag infinity-blur-diameter)))
 
 ;; Simplified calculation for symmetric lens
 (defun dof-symmetric-mm (focal-length f-stop distance coc)
 
 ;; Simplified calculation for symmetric lens
 (defun dof-symmetric-mm (focal-length f-stop distance coc)
@@ -109,23 +107,22 @@ Circle of confusion can either be a number or keyword designating format."
 Six values are returned:
 near dof, far dof, total dof, near point, far point, magnification,
 blur size at infinity (mm).
 Six values are returned:
 near dof, far dof, total dof, near point, far point, magnification,
 blur size at infinity (mm).
-Circle of confusion can either be a number or keyword designating format.
-Pupil factor is the ratio of the exit to enterance pupil diameters."
+Circle of confusion can either be a number or keyword designating format."
   (let* ((aperture (/ focal-length f-stop))
   (let* ((aperture (/ focal-length f-stop))
-         (numerator (* distance coc (- distance focal-length)))
-         (factor-1 (* focal-length aperture))
-         (factor-2 (* coc (- distance focal-length)))
-         (near (- distance (/ numerator (+ factor-1 factor-2))))
-         (far (+ distance (/ numerator (- factor-1 factor-2))))
-         (mag (magnification focal-length distance))
+         (numerator (* coc (- distance focal-length) (+ focal-length (* (- distance focal-length)))))
+         (d1 (* coc (- distance focal-length)))
+         (d2 (* aperture focal-length))
+         (front-dof (/ numerator (+ d1 d2)))
+         (rear-dof (/ numerator (- d1 d2)))
+         (mag (magnification :focal-length focal-length :object-distance distance :units :mm))
          (infinity-blur-diameter (/ (* mag focal-length) f-stop))
          (infinity-blur-diameter (/ (* mag focal-length) f-stop))
-         (depth (- far near)))
-    (values near far depth mag infinity-blur-diameter)))
+         (depth (+ front-dof rear-dof)))
+    (values front-dof rear-dof depth mag infinity-blur-diameter)))
 
 (defun dof (focal-length f-stop distance coc &key (units :mm) (pupil-factor 1))
   "Returns the Depth of Field.
 Input: FOCAL-LENGTH, F-STOP, DISTANCE, CIRCLE-OF-CONFUSION.
 
 (defun dof (focal-length f-stop distance coc &key (units :mm) (pupil-factor 1))
   "Returns the Depth of Field.
 Input: FOCAL-LENGTH, F-STOP, DISTANCE, CIRCLE-OF-CONFUSION.
-Output: NEAR-POINT, FAR-POINT, TOTAL-DOF, MAGNIFICATION, BLUR-SIZE-OF-INFINITY-POINT-IN-MM."
+Output: NEAR-DOF, FAR-DOF, TOTAL-DOF, MAGNIFICATION, BLUR-SIZE-OF-INFINITY-POINT-IN-MM."
   (multiple-value-bind (near-point far-point total-dof mag blur)
       (dof-mm focal-length f-stop (length->mm distance units) coc
               :pupil-factor pupil-factor)
   (multiple-value-bind (near-point far-point total-dof mag blur)
       (dof-mm focal-length f-stop (length->mm distance units) coc
               :pupil-factor pupil-factor)