1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10; Package: photo -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
6 ;;;; Purpose: Field of view functions for cl-photo
7 ;;;; Programmer: Kevin M. Rosenberg
8 ;;;; Date Started: April 2005
12 ;;;; This file, part of cl-photo, is Copyright (c) 2005 by Kevin M. Rosenberg
14 ;;;; cl-photo users are granted the rights to distribute and use this software
15 ;;;; as governed by the terms of the GNU General Public License v2
16 ;;;; (http://www.gnu.org/licenses/gpl.html)
18 ;;;; *************************************************************************
22 (defun aov-one-dim (focal-length frame-size
23 &key (projection :rectilinear)
25 "Returns the angle of view in one dimension. Default is infinity which
26 has an magnification of 0."
29 (radians->degrees (* 2 (atan (/ frame-size 2 focal-length
30 (1+ magnification))))))
32 (radians->degrees (* 4 (asin (/ frame-size 4 focal-length)))))
34 (radians->degrees (/ (* 2 frame-size) focal-length)))
36 (radians->degrees (* 2 (asin (/ frame-size 2 focal-length)))))
38 (radians->degrees (* 4 (atan (/ frame-size 4 focal-length)))))
42 (defun aov (focal-length frame-width frame-height
43 &key (projection :rectilinear)
45 "Returns the angle of field of view for a focal length and frame size.
46 Default is infinity (magnification 0)"
48 (aov-one-dim focal-length frame-width :projection projection :magnification magnification)
49 (aov-one-dim focal-length frame-height :projection projection :magnification magnification)
50 (aov-one-dim focal-length (diagonal frame-width frame-height)
51 :projection projection :magnification magnification)))
53 (defun image-distance (focal-length object-distance)
54 "Returns the image distance for a focused object at distance using the Gaussian
56 (if (= focal-length object-distance)
58 (float (/ 1 (- (/ 1 focal-length) (/ 1 object-distance))))))
60 (defun fov (focal-length frame-width frame-height object-distance
61 &key (projection :rectilinear))
62 "Returns the field of view and image magnificaion ratio at a given distance."
63 (let* ((image-distance (image-distance focal-length object-distance))
64 (magnification (/ image-distance object-distance)))
65 (multiple-value-bind (aov-width aov-height aov-diagonal)
66 (aov focal-length frame-width frame-height :projection projection
67 :magnification magnification)
68 (let* ((d-width (* 2 object-distance (tan (degrees->radians (/ aov-width 2)))))
69 (d-height (* 2 object-distance (tan (degrees->radians (/ aov-height 2)))))
70 (d-diagonal (* 2 object-distance (tan (degrees->radians (/ aov-diagonal 2))))))
71 (values d-width d-height d-diagonal magnification)))))
73 (defun aov-format (focal-length format &key (projection :rectilinear))
74 "Returns the angle of field of view for a focal length and frame size at infinity"
75 (let ((dim (imager-dimensions format)))
76 (aov focal-length (car dim) (cdr dim) :projection projection)))
78 (defun magnification (focal-length distance)
79 "Returns the image magnification: the ratio of image size to objecct size."
80 (float (/ focal-length (- distance focal-length))))
82 (defun bellows-factor (focal-length distance)
83 "Returns the bellows factor, the ratio of effective aperature to actual aperture."
84 (1+ (magnification focal-length distance)))