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 Rosenberg.
13 ;;;; Rights of modification and redistribution are in the LICENSE file.
15 ;;;; *************************************************************************
19 (defun fov-one-dim (focal-length frame-size
20 &key (projection :rectilinear))
23 (radians->degrees (* 2 (atan (/ frame-size 2 focal-length)))))
25 (radians->degrees (* 4 (asin (/ frame-size 4 focal-length)))))
27 (radians->degrees (/ (* 2 frame-size) focal-length)))
29 (radians->degrees (* 2 (asin (/ frame-size 2 focal-length)))))
31 (radians->degrees (* 4 (atan (/ frame-size 4 focal-length)))))
35 (defun fov (focal-length frame-width frame-height
36 &key (projection :rectilinear))
37 "Returns the angle of field of view for a focal length and frame size at infinity"
39 (fov-one-dim focal-length frame-width :projection projection)
40 (fov-one-dim focal-length frame-height :projection projection)
41 (fov-one-dim focal-length (diagonal frame-width frame-height)
42 :projection projection)))
44 (defun fov-distance (focal-length frame-width frame-height distance
45 &key (projection :rectilinear))
46 "Returns the field of view and image magnificaion ratio at a given distance.
47 NOTE: magnification assumes that distance is in the same units as frame size: mm"
48 (multiple-value-bind (fov-width fov-height fov-diagonal)
49 (fov focal-length frame-width frame-height :projection projection)
50 (let* ((d-width (* distance (sin (degrees->radians fov-width))))
51 (d-height (* distance (sin (degrees->radians fov-height))))
52 (d-diagonal (* distance (sin (degrees->radians fov-diagonal))))
53 (mag (/ frame-width d-width)))
54 (values d-width d-height d-diagonal mag))))
56 (defun fov-format (focal-length format &key (projection :rectilinear))
57 "Returns the angle of field of view for a focal length and frame size at infinity"
58 (let ((dim (format-dimensions format)))
59 (fov focal-length (car dim) (cdr dim) :projection projection)))