;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10; Package: photo -*- ;;;; ************************************************************************* ;;;; FILE IDENTIFICATION ;;;; ;;;; Name: fov.lisp ;;;; Purpose: Field of view functions for cl-photo ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: April 2005 ;;;; ;;;; $Id$ ;;;; ;;;; This file, part of cl-photo, is Copyright (c) 2005 by Kevin M. Rosenberg ;;;; ;;;; cl-photo users are granted the rights to distribute and use this software ;;;; as governed by the terms of the GNU General Public License v2 ;;;; (http://www.gnu.org/licenses/gpl.html) ;;;; ;;;; ************************************************************************* (in-package #:photo) (defun aov-one-dim (focal-length frame-size &key (projection :rectilinear) (magnification 0)) "Returns the angle of view in one dimension. Default is infinity which has an magnification of 0." (ecase projection (:rectilinear (radians->degrees (* 2 (atan (/ frame-size 2 focal-length (1+ magnification)))))) (:equisolid (radians->degrees (* 4 (asin (/ frame-size 4 focal-length))))) (:equidistance (radians->degrees (/ (* 2 frame-size) focal-length))) (:orthogonal (radians->degrees (* 2 (asin (/ frame-size 2 focal-length))))) (:stereographic (radians->degrees (* 4 (atan (/ frame-size 4 focal-length))))) )) (defun aov (focal-length frame-width frame-height &key (projection :rectilinear) (magnification 0)) "Returns the angle of field of view for a focal length and frame size. Default is infinity (magnification 0)" (values (aov-one-dim focal-length frame-width :projection projection :magnification magnification) (aov-one-dim focal-length frame-height :projection projection :magnification magnification) (aov-one-dim focal-length (diagonal frame-width frame-height) :projection projection :magnification magnification))) (defun image-distance (focal-length object-distance) "Returns the image distance for a focused object at distance using the Gaussian Lens Equation." (if (= focal-length object-distance) 0 (float (/ 1 (- (/ 1 focal-length) (/ 1 object-distance)))))) (defun fov (focal-length frame-width frame-height object-distance &key (projection :rectilinear)) "Returns the field of view and image magnificaion ratio at a given distance." (let* ((image-distance (image-distance focal-length object-distance)) (magnification (/ image-distance object-distance))) (multiple-value-bind (aov-width aov-height aov-diagonal) (aov focal-length frame-width frame-height :projection projection :magnification magnification) (let* ((d-width (* 2 object-distance (tan (degrees->radians (/ aov-width 2))))) (d-height (* 2 object-distance (tan (degrees->radians (/ aov-height 2))))) (d-diagonal (* 2 object-distance (tan (degrees->radians (/ aov-diagonal 2)))))) (values d-width d-height d-diagonal magnification))))) (defun aov-format (focal-length format &key (projection :rectilinear)) "Returns the angle of field of view for a focal length and frame size at infinity" (let ((dim (imager-dimensions format))) (aov focal-length (car dim) (cdr dim) :projection projection))) (defun magnification (focal-length distance) "Returns the image magnification: the ratio of image size to objecct size." (float (/ focal-length (- distance focal-length)))) (defun bellows-factor (focal-length distance) "Returns the bellows factor, the ratio of effective aperature to actual aperture." (1+ (magnification focal-length distance)))