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 fov-one-dim (focal-length frame-size
23 &key (projection :rectilinear))
26 (radians->degrees (* 2 (atan (/ frame-size 2 focal-length)))))
28 (radians->degrees (* 4 (asin (/ frame-size 4 focal-length)))))
30 (radians->degrees (/ (* 2 frame-size) focal-length)))
32 (radians->degrees (* 2 (asin (/ frame-size 2 focal-length)))))
34 (radians->degrees (* 4 (atan (/ frame-size 4 focal-length)))))
38 (defun fov (focal-length frame-width frame-height
39 &key (projection :rectilinear))
40 "Returns the angle of field of view for a focal length and frame size at infinity"
42 (fov-one-dim focal-length frame-width :projection projection)
43 (fov-one-dim focal-length frame-height :projection projection)
44 (fov-one-dim focal-length (diagonal frame-width frame-height)
45 :projection projection)))
47 (defun fov-distance (focal-length frame-width frame-height distance
48 &key (projection :rectilinear))
49 "Returns the field of view and image magnificaion ratio at a given distance.
50 NOTE: magnification assumes that distance is in the same units as frame size: mm"
51 (multiple-value-bind (fov-width fov-height fov-diagonal)
52 (fov focal-length frame-width frame-height :projection projection)
53 (let* ((d-width (* distance (sin (degrees->radians fov-width))))
54 (d-height (* distance (sin (degrees->radians fov-height))))
55 (d-diagonal (* distance (sin (degrees->radians fov-diagonal))))
56 (mag (/ frame-width d-width)))
57 (values d-width d-height d-diagonal mag))))
59 (defun fov-format (focal-length format &key (projection :rectilinear))
60 "Returns the angle of field of view for a focal length and frame size at infinity"
61 (let ((dim (format-dimensions format)))
62 (fov focal-length (car dim) (cdr dim) :projection projection)))