(in-package #:photo)
-(defun aov-one-dim (focal-length frame-size
+(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
(:rectilinear
(radians->degrees (* 2 (atan (/ frame-size 2 focal-length
(1+ magnification))))))
- (:equisolid
+ (:equisolid
(radians->degrees (* 4 (asin (/ frame-size 4 focal-length)))))
- (:equidistance
+ (: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.
+ "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)
(defun image-distance-magnification (focal-length magnification)
- "Returns the image distance for a focused object at distance using the Gaussian
+ "Returns the image distance for a focused object at distance using the Gaussian
Lens Equation."
(* focal-length (1+ magnification)))
(setq image-distance (gaussian-lens
:focal-length focal-length
:object-distance object-distance
- :units units)))
+ :units units)))
((and (not object-distance) image-distance (not magnification))
(setq object-distance (gaussian-lens
- :focal-length focal-length
- :image-distance image-distance
- :units units)))
+ :focal-length focal-length
+ :image-distance image-distance
+ :units units)))
((and (not object-distance) (not image-distance) magnification)
(setf image-distance (image-distance-magnification focal-length magnification)
object-distance (when (numberp image-distance)
(mm->length (/ image-distance magnification) units))))
(t
- (error "Must set one, and only one, of the parameters: image-distance, object-distance, or magnification.")))
+ (error "Must set one, and only one, of the parameters: image-distance, object-distance, or magnification.")))
(%fov focal-length frame-width frame-height object-distance image-distance units
projection))
(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)))
+ (let ((dim (imager-dimensions format)))
(aov focal-length (car dim) (cdr dim) :projection projection)))
(defun magnification (&key focal-length object-distance image-distance (units :feet))
(t
(error "Must set two, and only two, of the parameters: image-distance, object-distance, and focal-length."))))
-(defun close-up (&key focal-length object-distance image-distance magnification (units :feet) &aux bellows-factor)
+(defun close-up (&key focal-length object-distance image-distance magnification (units :feet))
"Computes the parameters for focusing closer than infinity.
Requires two, and only two, of the input parameters.
Returns: focal-length object-distance image-distance magnification bellows-factor."
(cond
((and focal-length object-distance (not image-distance) (not magnification))
(setq magnification (magnification :focal-length focal-length
- :object-distance object-distance
- :units units))
+ :object-distance object-distance
+ :units units))
(setq image-distance (gaussian-lens :focal-length focal-length
- :object-distance object-distance
- :units units)))
+ :object-distance object-distance
+ :units units)))
((and focal-length (not object-distance) image-distance (not magnification))
(setq magnification (magnification :focal-length focal-length
- :image-distance image-distance
- :units units))
+ :image-distance image-distance
+ :units units))
(setq object-distance (gaussian-lens :focal-length focal-length
- :image-distance image-distance
- :units units)))
+ :image-distance image-distance
+ :units units)))
((and (not focal-length) object-distance image-distance (not magnification))
(setq magnification (magnification :object-distance object-distance
- :image-distance image-distance
- :units units))
+ :image-distance image-distance
+ :units units))
(setq focal-length (gaussian-lens :object-distance object-distance
- :image-distance image-distance
- :units units)))
+ :image-distance image-distance
+ :units units)))
((and focal-length (not object-distance) (not image-distance) magnification)
(setq image-distance (image-distance-magnification focal-length magnification))
(setq object-distance (gaussian-lens :focal-length focal-length
- :image-distance image-distance
- :units units)))
+ :image-distance image-distance
+ :units units)))
((and (not focal-length) object-distance (not image-distance) magnification)
(setq image-distance (* magnification (length->mm object-distance units)))
(setq focal-length (gaussian-lens :image-distance image-distance
- :object-distance object-distance
- :units units)))
+ :object-distance object-distance
+ :units units)))
((and (not focal-length) (not object-distance) image-distance magnification)
(setq object-distance (mm->length (float (/ image-distance magnification)) units))
(setq focal-length (gaussian-lens :image-distance image-distance
- :object-distance object-distance
- :units units)))
+ :object-distance object-distance
+ :units units)))
(t
(error "Must set two, and only two input parameters: focal-length, image-distance, object-distance, magnifcation.")))
(values focal-length object-distance image-distance magnification (1+ magnification)))
"Returns the bellows factor, the ratio of effective aperature to actual aperture."
(1+ (magnification :focal-length focal-length :object-distance object-distance)))
-(defun extension-tube (focal-length &key original-object-distance new-object-distance original-image-distance
- new-object-distnace original-magnification new-magification
- extension-length (units :feet))
+(defun n-args-not-nil (n &rest args)
+ "Returns T when count N of input args are not nil."
+ (= n (count-if-not #'null args)))
+
+(defun extension-tube (focal-length &key original-object-distance
+ original-image-distance original-magnification
+ new-object-distance new-image-distance
+ new-magnification extension-length (units :feet))
"Computes the parameters for using extension tubes.
Requires: 1. original-object-distance, original-image-distance, or original-magnification
2. new-object-distance, new-image-distance, new-magnification, or extension-length
-Returns: original-object-distance, original-image-distance, original-magnification,
+Returns: original-object-distance, original-image-distance, original-magnification, original-bellows-factor
new-object-distance, new-image-distance, new-magnification, extension-length."
- )
+ (when (or (not focal-length) (not units)
+ (not (n-args-not-nil 1 original-object-distance
+ original-image-distance
+ original-magnification))
+ (not (n-args-not-nil 1 new-object-distance
+ new-image-distance
+ new-magnification
+ extension-length)))
+ (error "Invalid arguments.
+Must set 1 of the following original-object-distance, original-image-distance,
+or original-magnification parameters as well as one of the following parameters
+new-object-distance, new-image-distance, new-magnification, or extension-length."))
+ (flet ((ret (ood oid om obf nod nid nm nbf e)
+ (list :focal-length focal-length :original-object-distance ood
+ :original-image-distance oid :original-magnification om
+ :original-bellows-factor obf :new-object-distance nod
+ :new-image-distance nid :new-magnification nm
+ :new-bellows-factor nbf :extension-length e)))
+
+ (multiple-value-bind (focal-length-original o-od o-id o-m o-bf)
+ (close-up :focal-length focal-length :object-distance original-object-distance
+ :image-distance original-image-distance :magnification original-magnification :units units)
+ (declare (ignore focal-length-original))
+
+ (cond
+ (extension-length
+ (multiple-value-bind (focal-length-new n-od n-id n-m n-bf)
+ (close-up :focal-length focal-length :image-distance (+ o-id extension-length) :units units)
+ (declare (ignore focal-length-new))
+ (ret o-od o-id o-m o-bf n-od n-id n-m n-bf extension-length)))
+ ((not extension-length)
+ (multiple-value-bind (focal-length-new n-od n-id n-m n-bf)
+ (close-up :focal-length focal-length :object-distance new-object-distance
+ :image-distance new-image-distance :magnification new-magnification :units units)
+ (declare (ignore focal-length-new))
+ (ret o-od o-id o-m o-bf n-od n-id n-m n-bf (- n-id o-id))))))))