X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=fov.lisp;h=055f074a7b8b74cbccb6c3e6983f4ba57111ff65;hb=aa668443cbb520ebd5dd1d007c19aab2316562e5;hp=b4df2b633943e40a28818c657dbf36f3cd42c7a2;hpb=0c8ab037b4267adebe22e07249e0e36fe7ca5f17;p=cl-photo.git diff --git a/fov.lisp b/fov.lisp index b4df2b6..055f074 100755 --- a/fov.lisp +++ b/fov.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: April 2005 ;;;; -;;;; $Id: package.lisp 8596 2004-02-03 18:32:50Z kevin $ +;;;; $Id$ ;;;; ;;;; This file, part of cl-photo, is Copyright (c) 2005 by Kevin Rosenberg. ;;;; Rights of modification and redistribution are in the LICENSE file. @@ -41,28 +41,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)))