-(defun fov-format (focal-length format &key (projection :rectilinear))
- "Returns the angle of field of view for a focal length and frame size at infinity"
- (ecase format
- (:aps-c
- (fov focal-length 22.7 15.1 :projection projection))
- (:aps
- (fov focal-length 24 18 :projection projection))
- (:35mm
- (fov focal-length 36 24 :projection projection))
- (:4.5x6
- (fov focal-length 45 60 :projection projection))
- (:6x6
- (fov focal-length 60 60 :projection projection))
- (:6x7
- (fov focal-length 60 70 :projection projection))
- (:6x9
- (fov focal-length 60 90 :projection projection))
- (:4x5
- (fov focal-length (* 4 +inches->mm+) (* 5 +inches->mm+)
- :projection projection))
- (:8x10
- (fov focal-length (* 8 +inches->mm+) (* 10 +inches->mm+)
- :projection projection))
- ))
+(defun gaussian-lens (focal-length object-distance)
+ "Returns the image distance for a focused object at distance."
+ (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 (gaussian-lens 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)))))