X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=fov.lisp;h=9b5ac79d1e8acc1216cee3663899ad01ab2e5228;hb=01efbdaa2981abb7f7a399f5a7f7ff3c431432d5;hp=6cc5bb3a8a5095717bf4338faf4dc10dc229253e;hpb=2502270d59bbf71c29d82486997d38a3981b307c;p=cl-photo.git diff --git a/fov.lisp b/fov.lisp index 6cc5bb3..9b5ac79 100755 --- a/fov.lisp +++ b/fov.lisp @@ -9,18 +9,25 @@ ;;;; ;;;; $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) ;;;; ;;;; ************************************************************************* (in-package #:photo) -(defun fov-one-dim (focal-length frame-size - &key (projection :rectilinear)) +(defun aov-one-dim (focal-length frame-size + &key (projection :rectilinear) + (magnification 0)) + "Returns the angle of view in one dimension. Default is infinity which +has an magnification of 0." (ecase projection (:rectilinear - (radians->degrees (* 2 (atan (/ frame-size 2 focal-length))))) + (radians->degrees (* 2 (atan (/ frame-size 2 focal-length + (1+ magnification)))))) (:equisolid (radians->degrees (* 4 (asin (/ frame-size 4 focal-length))))) (:equidistance @@ -32,37 +39,35 @@ )) -(defun fov (focal-length frame-width frame-height - &key (projection :rectilinear)) - "Returns the angle of field of view for a focal length and frame size at infinity" +(defun aov (focal-length frame-width frame-height + &key (projection :rectilinear) + (magnification 0)) + "Returns the angle of field of view for a focal length and frame size. +Default is infinity (magnification 0)" (values - (fov-one-dim focal-length frame-width :projection projection) - (fov-one-dim focal-length frame-height :projection projection) - (fov-one-dim focal-length (diagonal frame-width frame-height) - :projection projection))) + (aov-one-dim focal-length frame-width :projection projection :magnification magnification) + (aov-one-dim focal-length frame-height :projection projection :magnification magnification) + (aov-one-dim focal-length (diagonal frame-width frame-height) + :projection projection :magnification magnification))) -(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)) - )) +(defun gaussian-lens (focal-length object-distance) + "Returns the image distance for a focused object at distance." + (float (/ 1 (- (/ 1 focal-length) (/ 1 object-distance))))) + +(defun fov (focal-length frame-width frame-height object-distance + &key (projection :rectilinear)) + "Returns the field of view and image magnificaion ratio at a given distance." + (let* ((image-distance (gaussian-lens focal-length object-distance)) + (magnification (/ image-distance object-distance))) + (multiple-value-bind (aov-width aov-height aov-diagonal) + (aov focal-length frame-width frame-height :projection projection + :magnification magnification) + (let* ((d-width (* 2 object-distance (tan (degrees->radians (/ aov-width 2))))) + (d-height (* 2 object-distance (tan (degrees->radians (/ aov-height 2))))) + (d-diagonal (* 2 object-distance (tan (degrees->radians (/ aov-diagonal 2)))))) + (values d-width d-height d-diagonal magnification))))) +(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))) + (aov focal-length (car dim) (cdr dim) :projection projection)))