As a guide with a professional photography background, I sometimes see aspiring photographers struggle with various aspects of the craft, from creative to technical and these things naturally come up in our conversations.
One of the important things to master is an intuition for how the focal length, aperture, and object distance combine to create the final image, and put certain parts of the scene in sharp focus while others remain blurred – either a desired effect if one would like to visually separate a subject from the background, or a major challenge if the goal would be rather to capture the entire depth of the scenery in full sharpness.
This interactive sketch illustrates a somewhat idealized camera model where it is possible to experiment with these parameters. It shows how two points on the left side are captured by the lens and focused onto an image plane on the right. A sharp image is produced exactly where the lens rays converge again (“AF” simulates an autofocus locked onto the red point). Experiment with aperture, focal length and other parameters and observe how spread out the lens rays (ie. how out of focus) are for the other point.
This simulation is based on the thin lens equation. It models basic lens characteristics, but real lenses are of course a much more complicated arrangement that optimizes focusing and certain effects not represented in this simplified model. Source code available on JSFiddle.