r10440: add tables
authorKevin M. Rosenberg <kevin@rosenberg.net>
Fri, 22 Apr 2005 19:30:34 +0000 (19:30 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Fri, 22 Apr 2005 19:30:34 +0000 (19:30 +0000)
cameras.lisp
fov.lisp
package.lisp
tables.lisp

index 6e4e74bd8a713d9821ed78cf0ee33b7b7f4eb54a..2184ebfad510ab94ac64c173e93f84336de61586 100644 (file)
@@ -20,7 +20,7 @@
 (in-package #:photo)
 
 (defun sensor-dimensions-megapixels (format megapixels)
 (in-package #:photo)
 
 (defun sensor-dimensions-megapixels (format megapixels)
-  (let* ((dim (format-dimensions format))
+  (let* ((dim (imager-dimensions format))
          (aspect-ratio (/ (car dim) (cdr dim)))
          (width (round (sqrt (* aspect-ratio 1000000 megapixels)))))
     (cons width (round (/ width aspect-ratio)))))
          (aspect-ratio (/ (car dim) (cdr dim)))
          (width (round (sqrt (* aspect-ratio 1000000 megapixels)))))
     (cons width (round (/ width aspect-ratio)))))
index 23ca941d517f28b73f5a0b96ac81107442ba7e76..572a55b256652cd2e2dad18d4351de7f3fbdd6c1 100755 (executable)
--- a/fov.lisp
+++ b/fov.lisp
@@ -53,7 +53,9 @@ Default is infinity (magnification 0)"
 (defun image-distance (focal-length object-distance)
   "Returns the image distance for a focused object at distance using the Gaussian 
 Lens Equation."
 (defun image-distance (focal-length object-distance)
   "Returns the image distance for a focused object at distance using the Gaussian 
 Lens Equation."
-  (float (/ 1 (- (/ 1 focal-length) (/ 1 object-distance)))))
+  (if (= focal-length object-distance)
+      0
+    (float (/ 1 (- (/ 1 focal-length) (/ 1 object-distance))))))
 
 (defun fov (focal-length frame-width frame-height object-distance
                          &key (projection :rectilinear))
 
 (defun fov (focal-length frame-width frame-height object-distance
                          &key (projection :rectilinear))
@@ -70,7 +72,7 @@ Lens Equation."
 
 (defun aov-format (focal-length format &key (projection :rectilinear))
   "Returns the angle of field of view for a focal length and frame size at infinity"
 
 (defun aov-format (focal-length format &key (projection :rectilinear))
   "Returns the angle of field of view for a focal length and frame size at infinity"
-  (let ((dim (format-dimensions format))) 
+  (let ((dim (imager-dimensions format))) 
     (aov focal-length (car dim) (cdr dim) :projection projection)))
 
 (defun magnification (focal-length distance)
     (aov focal-length (car dim) (cdr dim) :projection projection)))
 
 (defun magnification (focal-length distance)
index 253ca02ddcbf7891b633821756719710596d1b4a..7c6f44758f1a76552d5089074abc3361c64038f3 100755 (executable)
@@ -48,8 +48,9 @@
    #:effective-aperture
 
    ;; tables.lisp
    #:effective-aperture
 
    ;; tables.lisp
-   #:hyperfocal-list
    #:hyperfocal-table
    #:aov-table
    #:hyperfocal-table
    #:aov-table
+   #:fov-table
+   #:dof-table
    ))
 
    ))
 
index c0df801e1f25201bd6577876f5039390e9f2f18a..0b256a514bd23f4e48424a862c0bf0be370b605c 100755 (executable)
 (defparameter +focal-lengths+ '(12 24 35 50 70 85 105 135 200 300 400 500 600))
 (defparameter +distances-feet+ '(0.5 1 3 8 15 25 50 100 200))
 
 (defparameter +focal-lengths+ '(12 24 35 50 70 85 105 135 200 300 400 500 600))
 (defparameter +distances-feet+ '(0.5 1 3 8 15 25 50 100 200))
 
-(defun hyperfocal-list (focal-length coc &key (units :feet))
-  (loop for f-stop in +f-stops+
-        collect (hyperfocal focal-length f-stop coc :units units)))
-
 (defun hyperfocal-table (focal-length coc &key (units :feet) (output *standard-output*))
   (loop for f-stop in +f-stops+
         do (format output "~4,1F ~,1F~%" 
 (defun hyperfocal-table (focal-length coc &key (units :feet) (output *standard-output*))
   (loop for f-stop in +f-stops+
         do (format output "~4,1F ~,1F~%" 
   (let ((imager-dim (etypecase imager
                       (cons imager)
                       (symbol (imager-dimensions imager)))))
   (let ((imager-dim (etypecase imager
                       (cons imager)
                       (symbol (imager-dimensions imager)))))
+    (format output "~5A ~5A ~5A ~5A~%" "FOCAL" "AOV-W" "AOV-H" "AOV-D")
     (loop for focal-length in +focal-lengths+
           do (let ((aov (multiple-value-list (aov focal-length (car imager-dim) (cdr imager-dim)
                                                   :projection projection))))
     (loop for focal-length in +focal-lengths+
           do (let ((aov (multiple-value-list (aov focal-length (car imager-dim) (cdr imager-dim)
                                                   :projection projection))))
-               (format output "~4D ~5,1F ~5,1F ~5,1F~%" 
+               (format output "~5D ~5,1F ~5,1F ~5,1F~%" 
                        focal-length (nth 0 aov) (nth 1 aov) (nth 2 aov)))))
   (values))
 
                        focal-length (nth 0 aov) (nth 1 aov) (nth 2 aov)))))
   (values))
 
+(defun fov-table (imager focal-length
+                         &key (output *standard-output*) (projection :rectilinear)
+                         (units :feet))
+  (let ((imager-dim (etypecase imager
+                      (cons imager)
+                      (symbol (imager-dimensions imager))))
+        (distances (mapcar 'feet->mm +distances-feet+)))
+    (format output "~8A  ~6A ~6A ~6A ~6A~%" "DISTANCE" "WIDTH" "HEIGHT" "DIAGON" "MAG")
+    (loop for distance in distances
+          do (let ((fov (multiple-value-list (fov focal-length
+                                                  (car imager-dim) (cdr imager-dim)
+                                                  distance
+                                                  :projection projection))))
+               (format output "~8F: ~6F ~6F ~6F ~6F~%" 
+                       (mm->length distance units)
+                       (nth 0 fov) (nth 1 fov) (nth 2 fov) (nth 3 fov)))))
+  (values))
+
 (defun dof-table (focal-length coc &key (output *standard-output*) (units :feet))
   (let ((distances (mapcar (lambda (mm) (mm->length mm units))
                            (mapcar 'feet->mm +distances-feet+))))
 (defun dof-table (focal-length coc &key (output *standard-output*) (units :feet))
   (let ((distances (mapcar (lambda (mm) (mm->length mm units))
                            (mapcar 'feet->mm +distances-feet+))))
-    (format output "~&~5A" "")
+    (format output "~&~5A  " "FStop")
     (dolist (distance distances)
     (dolist (distance distances)
-      (format output " ~10F" distance))
+      (format output " ~10F " distance))
     (format output "~%")
     (dolist (f-stop +f-stops+)
     (format output "~%")
     (dolist (f-stop +f-stops+)
-      (format output "~5,1F " f-stop)
+      (format output "~5,1F  " f-stop)
       (dolist (distance distances)
         (multiple-value-bind (near far dof mag blur) (dof focal-length f-stop distance coc
                                                           :units units)
       (dolist (distance distances)
         (multiple-value-bind (near far dof mag blur) (dof focal-length f-stop distance coc
                                                           :units units)
-          (when (minusp far) (setq far "Inf"))
-          (format output "~4,1F/~4,1F " near far)))
+          (when (minusp far) (setq far "Inf  "))
+          (format output "~5F/~5F " near far)))
       (format output "~%")))
   (values))
       (format output "~%")))
   (values))