r10404: Initial import
[cl-photo.git] / fov.lisp
1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10; Package: photo -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name:          fov.lisp
6 ;;;; Purpose:       Field of view functions for cl-photo
7 ;;;; Programmer:    Kevin M. Rosenberg
8 ;;;; Date Started:  April 2005
9 ;;;;
10 ;;;; $Id: package.lisp 8596 2004-02-03 18:32:50Z kevin $
11 ;;;;
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.
14 ;;;;
15 ;;;; *************************************************************************
16
17 (in-package #:photo)
18
19 (defun fov-one-dim (focal-length frame-size 
20                                  &key (projection :rectilinear))
21   (ecase projection
22     (:rectilinear
23      (radians->degrees (* 2 (atan (/ frame-size 2 focal-length)))))
24     (:equisolid 
25      (radians->degrees (* 4 (asin (/ frame-size 4 focal-length)))))
26     (:equidistance 
27      (radians->degrees (/ (* 2 frame-size) focal-length)))
28     (:orthogonal
29      (radians->degrees (* 2 (asin (/ frame-size 2 focal-length)))))
30     (:stereographic
31      (radians->degrees (* 4 (atan (/ frame-size 4 focal-length)))))
32     ))
33     
34   
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"
38   (values
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)))
43
44 (defun fov-format (focal-length format &key (projection :rectilinear))
45   "Returns the angle of field of view for a focal length and frame size at infinity"
46   (ecase format
47     (:aps-c
48      (fov focal-length 22.7 15.1 :projection projection))
49     (:aps
50      (fov focal-length 24 18 :projection projection))
51     (:35mm
52      (fov focal-length 36 24 :projection projection))
53     (:4.5x6
54      (fov focal-length 45 60 :projection projection))
55     (:6x6
56      (fov focal-length 60 60 :projection projection))
57     (:6x7
58      (fov focal-length 60 70 :projection projection))
59     (:6x9
60      (fov focal-length 60 90 :projection projection))
61     (:4x5
62      (fov focal-length (* 4 +inches->mm+) (* 5 +inches->mm+)
63           :projection projection))
64     (:8x10
65      (fov focal-length (* 8 +inches->mm+) (* 10 +inches->mm+)
66           :projection projection))
67     ))
68