- (near (/ numerator (+ factor-1 factor-2)))
- (far (/ numerator (- factor-1 factor-2)))
- (depth (+ far near)))
- (values near far depth (- distance near) (+ distance far))))
-
-(defun dof-feet (focal-length f-stop distance coc)
- (multiple-value-bind (near-dof far-dof total-dof near-point far-point)
- (dof focal-length f-stop (feet->mm distance) coc)
- (values (mm->feet near-dof) (mm->feet far-dof) (mm->feet total-dof)
- (mm->feet near-point) (mm->feet far-point))))
-
-(defun dof-meters (focal-length f-stop distance coc)
- (multiple-value-bind (near-dof far-dof total-dof near-point far-point)
- (dof focal-length f-stop (* 1000 distance) coc)
- (values (* 0.001 near-dof) (* 0.001 far-dof) (* 0.001 total-dof)
- (* 0.001 near-point) (* 0.001 far-point))))
-
-(defun hyperfocal (focal-length f-stop coc)
- (+ focal-length (/ (* focal-length focal-length) (* f-stop coc))))
-
-(defun hyperfocal-feet (focal-length f-stop coc)
- (mm->feet (hyperfocal focal-length f-stop coc)))
-
-
+ (near (- distance (/ numerator (+ factor-1 factor-2))))
+ (far (+ distance (/ numerator (- factor-1 factor-2))))
+ (mag (magnification focal-length distance))
+ (infinity-blur-diameter (/ (* mag focal-length) f-stop))
+ (depth (- far near)))
+ (values near far depth mag infinity-blur-diameter)))
+
+(defun dof (focal-length f-stop distance coc &key (units :mm) (pupil-factor 1))
+ "Returns the Depth of Field.
+Input: FOCAL-LENGTH, F-STOP, DISTANCE, CIRCLE-OF-CONFUSION.
+Output: NEAR-POINT, FAR-POINT, TOTAL-DOF, MAGNIFICATION, BLUR-SIZE-OF-INFINITY-POINT-IN-MM."
+ (multiple-value-bind (near-point far-point total-dof mag blur)
+ (dof-mm focal-length f-stop (length->mm distance units) coc
+ :pupil-factor pupil-factor)
+ (values (mm->length near-point units)
+ (mm->length far-point units)
+ (mm->length total-dof units)
+ mag blur)))
+
+(defun hyperfocal (focal-length f-stop coc &key (units :mm))
+ (mm->length (+ focal-length (/ (* focal-length focal-length) f-stop coc)) units))
+
+(defun effective-aperture (focal-length distance aperture)
+ (* aperture (bellows-factor focal-length distance)))
+
+(defun mtf-scanner (freq dscan-freq &optional (order 3))
+ (abs (expt (kmrcl:sinc (* pi (/ freq dscan-freq))) order)))
+
+(defun freq-mtf-scanner (dscan-freq mtf &optional (order 3))
+ (* dscan-freq (/ (asin (* x (exp (/ (log mtf) order)))) pi)))