# DoF corrections for focus.c

*Created originally on Bitbucket by garry23 (Garry George)*

*Was already merged in Bitbucket before import, marked as merged by the import user*

These corrections correct two things.

First, the current form of the equations are not optimally coded in C and create integer division errors. This C-based 'problem' is now handled 'correctly'. Also, diffraction is now used in tenths of micron units to further reduce integer division rounding errors.

Second, the current HFD equation (incorrectly) uses a form of the diffraction equation that is focus (ie position) aware, ie through the magnification (mag, in fact inverse mag at the moment). By definition, magnification (=fl/(fd-fl)) is zero at infinity. HFD should not vary with focus. HFD is now calculated assuming the diffraction at infinity, ie independent of focus, ie diff = 2.44*freq*N*(1+mag), ie for HFD the diff = 2.44*freq*N

The DoF equation used is DoF(n/f) = fd*fl*fl/(fl*fl (+/-) N*c*(fd-fl)).

Finally, I want to apologize for 'being an idiot' and not remembering how to make a pull request. David thanks for the 're-education'.