From 4c11fbdc404582b4b8590dca68e80db9f19a77b2 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Fri, 22 Apr 2005 19:30:34 +0000 Subject: [PATCH] r10440: add tables --- cameras.lisp | 2 +- fov.lisp | 6 ++++-- package.lisp | 3 ++- tables.lisp | 35 +++++++++++++++++++++++++---------- 4 files changed, 32 insertions(+), 14 deletions(-) diff --git a/cameras.lisp b/cameras.lisp index 6e4e74b..2184ebf 100644 --- a/cameras.lisp +++ b/cameras.lisp @@ -20,7 +20,7 @@ (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))))) diff --git a/fov.lisp b/fov.lisp index 23ca941..572a55b 100755 --- 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." - (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)) @@ -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" - (let ((dim (format-dimensions format))) + (let ((dim (imager-dimensions format))) (aov focal-length (car dim) (cdr dim) :projection projection))) (defun magnification (focal-length distance) diff --git a/package.lisp b/package.lisp index 253ca02..7c6f447 100755 --- a/package.lisp +++ b/package.lisp @@ -48,8 +48,9 @@ #:effective-aperture ;; tables.lisp - #:hyperfocal-list #:hyperfocal-table #:aov-table + #:fov-table + #:dof-table )) diff --git a/tables.lisp b/tables.lisp index c0df801..0b256a5 100755 --- a/tables.lisp +++ b/tables.lisp @@ -23,10 +23,6 @@ (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~%" @@ -37,26 +33,45 @@ (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)))) - (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)) +(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+)))) - (format output "~&~5A" "") + (format output "~&~5A " "FStop") (dolist (distance distances) - (format output " ~10F" distance)) + (format output " ~10F " distance)) (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) - (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)) -- 2.34.1