X-Git-Url: http://git.kpe.io/?p=cl-photo.git;a=blobdiff_plain;f=fov.lisp;h=055f074a7b8b74cbccb6c3e6983f4ba57111ff65;hp=6cc5bb3a8a5095717bf4338faf4dc10dc229253e;hb=aa668443cbb520ebd5dd1d007c19aab2316562e5;hpb=7bf873d5bd726db6d3e67dcc0e4bd4524ef2d168 diff --git a/fov.lisp b/fov.lisp index 6cc5bb3..055f074 100755 --- a/fov.lisp +++ b/fov.lisp @@ -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)))