# Determining lens and sensor distance for narrow focus

I have the following items:

I need to take a picture of the target object, through the lens, using the camera sensor. I'm trying to figure out how to position these items (distances between them) such that the object is in focus and fills the camera sensor.

This online calculator suggests that for a lens with the above specifications, and a target area of 6mm x 8mm, the object should be 4.44cm from the front of the lens. How, though, do I calculate the distance from the back of the lens to the camera sensor? I know I could use the focal length for a focus at infinity, but that would require the object to be at least 5m or so beyond the lens, which is far outside of the allowable distance for this application.

$$\frac{1}{d} + \frac{1}{d'} = \frac{1}{f}$$
where $$f$$ is the focal length ($$20\;\mathrm{mm}$$ in your case), $$d$$ is the lens-object distance and $$d'$$ the lens-image distance. This calculation will be a bit off as your lens is not thin, but you can adjust the position by hand.
The magnification is $$m = d'/d$$ by the way, this calculation is easy enough that you can do it on your own (solve the system of the two equations for the given $$m$$ and $$f$$).