X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=fov.lisp;h=6a43317c6131e828c373443bcea690510d79fac1;hb=4e83bf8dbe167504969d64842ccf8bfae859ca9b;hp=6cc5bb3a8a5095717bf4338faf4dc10dc229253e;hpb=2502270d59bbf71c29d82486997d38a3981b307c;p=cl-photo.git diff --git a/fov.lisp b/fov.lisp index 6cc5bb3..6a43317 100755 --- a/fov.lisp +++ b/fov.lisp @@ -9,8 +9,11 @@ ;;;; ;;;; $Id$ ;;;; -;;;; This file, part of cl-photo, is Copyright (c) 2005 by Kevin Rosenberg. -;;;; Rights of modification and redistribution are in the LICENSE file. +;;;; This file, part of cl-photo, is Copyright (c) 2005 by Kevin M. Rosenberg +;;;; +;;;; cl-photo users are granted the rights to distribute and use this software +;;;; as governed by the terms of the GNU General Public License v2 +;;;; (http://www.gnu.org/licenses/gpl.html) ;;;; ;;;; ************************************************************************* @@ -41,28 +44,19 @@ (fov-one-dim focal-length (diagonal frame-width frame-height) :projection projection))) +(defun fov-distance (focal-length frame-width frame-height distance + &key (projection :rectilinear)) + "Returns the field of view and image magnificaion ratio at a given distance. +NOTE: magnification assumes that distance is in the same units as frame size: mm" + (multiple-value-bind (fov-width fov-height fov-diagonal) + (fov focal-length frame-width frame-height :projection projection) + (let* ((d-width (* distance (sin (degrees->radians fov-width)))) + (d-height (* distance (sin (degrees->radians fov-height)))) + (d-diagonal (* distance (sin (degrees->radians fov-diagonal)))) + (mag (/ frame-width d-width))) + (values d-width d-height d-diagonal mag)))) + (defun fov-format (focal-length format &key (projection :rectilinear)) "Returns the angle of field of view for a focal length and frame size at infinity" - (ecase format - (:aps-c - (fov focal-length 22.7 15.1 :projection projection)) - (:aps - (fov focal-length 24 18 :projection projection)) - (:35mm - (fov focal-length 36 24 :projection projection)) - (:4.5x6 - (fov focal-length 45 60 :projection projection)) - (:6x6 - (fov focal-length 60 60 :projection projection)) - (:6x7 - (fov focal-length 60 70 :projection projection)) - (:6x9 - (fov focal-length 60 90 :projection projection)) - (:4x5 - (fov focal-length (* 4 +inches->mm+) (* 5 +inches->mm+) - :projection projection)) - (:8x10 - (fov focal-length (* 8 +inches->mm+) (* 10 +inches->mm+) - :projection projection)) - )) - + (let ((dim (format-dimensions format))) + (fov focal-length (car dim) (cdr dim) :projection projection)))