How to construct a ray diagram for depth of field

Tom Axford

Forum Pro
Messages
11,599
Solutions
57
Reaction score
13,499
Location
Midlands, UK
When I see someone present a ray diagram to show the depth of field, it usually appears to have been drawn largely by guesswork rather than following a well-defined procedure.

Yet it is not difficult to construct ray diagrams quite precisely following the usual rules of geometrical optics.

Here is one possible method for construction a DoF diagram. The final diagram we will construct is:

3b45a209977649e2a4785806dfcbe2fa.jpg.png

First, choose the positions for the subject plane (on which the camera will be focussed), the lens (assumed to be a thin lens for simplicity, hence shown as a plane) and the sensor plane.

Then mark two points Q' and R' on the sensor plane, so that the distance between Q' and R' is the required circle of confusion. Make Q' and R' an equal distance either side of the optical axis.

We know that the camera is focussed on the subject plane, so the lens brings all the rays from any given point in the subject plane to a focus at the image of that point in the sensor plane.

Hence we can quickly find the points Q and R in the subject plane, whose images are Q' and R' in the sensor plane. Simply draw straight lines through the centre of the lens (at V) from Q' to Q and from R' to R. (Rays hitting the centre of the lens pass straight through)

Now we know the positions of Q and R together with their images Q' and R'. It is now easy to fill in all the other rays in the diagram. For example, the ray from Q to T (at the top of the lens) continues as TQ'. The ray RU continues as UR'.

QT and RU intersect at P. TQ' and UR' intersect at P'. Hence P' is the image of P.

QU and RT intersect at S. UQ' and TR' intersect at S'. Hence S' is the image of S.

The distance PS is the depth of field (because points further away than P will produce a blur larger than the CoC, while points closer than S will also produce a blur larger than the CoC). In principle, if the diagram is drawn to scale, the depth of field could be measured from the diagram.
 
That is useful, thanks Tom.

For consistency it would be great when dealing with such subjects if we could all use the same symbol conventions. I tend to like those presented in Alan Robinson's unpublished “Depth of Field from Working F-number and Image magnification“, which is applicable not just to thin but to all lenses since it also shows pupils and principal planes.



fa7e52aa2364418d9647f2eefbd7ba38.jpg.png

But any consistent ones will do.

Jack
 
I think it depends on what you are trying to show. If you are trying to show everything about the lens, then Jack Hogan's version or equivalent, of course. (Although I personally hate the u-v notation, preferring x-x', distances to the focal points.) If you are trying to show the origin of the depth of field to demonstrate it simply, then I would break your diagram into at least two parts -- one for near objects and one for far objects. I think I would even omit the blue lines. But your diagram has the advantage of showing the whole depth of focus and depth of field, and distinguishes between them.

One reason to omit the blue lines is that the positions of the subject and image planes are arbitrary and undefined, and the focal length is unspecified, so we don't really need the blue lines to define the position of the image plane.
 
When I see someone present a ray diagram to show the depth of field, it usually appears to have been drawn largely by guesswork rather than following a well-defined procedure.

Yet it is not difficult to construct ray diagrams quite precisely following the usual rules of geometrical optics.

Here is one possible method for construction a DoF diagram. The final diagram we will construct is:

3b45a209977649e2a4785806dfcbe2fa.jpg.png

First, choose the positions for the subject plane (on which the camera will be focussed), the lens (assumed to be a thin lens for simplicity, hence shown as a plane) and the sensor plane.

Then mark two points Q' and R' on the sensor plane, so that the distance between Q' and R' is the required circle of confusion. Make Q' and R' an equal distance either side of the optical axis.

We know that the camera is focussed on the subject plane, so the lens brings all the rays from any given point in the subject plane to a focus at the image of that point in the sensor plane.

Hence we can quickly find the points Q and R in the subject plane, whose images are Q' and R' in the sensor plane. Simply draw straight lines through the centre of the lens (at V) from Q' to Q and from R' to R. (Rays hitting the centre of the lens pass straight through)

Now we know the positions of Q and R together with their images Q' and R'. It is now easy to fill in all the other rays in the diagram. For example, the ray from Q to T (at the top of the lens) continues as TQ'. The ray RU continues as UR'.

QT and RU intersect at P. TQ' and UR' intersect at P'. Hence P' is the image of P.

QU and RT intersect at S. UQ' and TR' intersect at S'. Hence S' is the image of S.

The distance PS is the depth of field (because points further away than P will produce a blur larger than the CoC, while points closer than S will also produce a blur larger than the CoC). In principle, if the diagram is drawn to scale, the depth of field could be measured from the diagram.
I think that's a good approach for geometrical optics, but geometrical optics is not very accurate when the lenses have significant aberrations (consider overcorrected and undercorrected SA) and the CoC is small.

--
 
The blue lines are necessary to ensure that the diagram is geometrically correct. They ensure that the diagram in object space (to the left of the lens) is consistent with the diagram in image space (to the right of the lens).

Of course, the blue lines could be erased after the diagram has been drawn, but I think it is probably a good idea to keep them as a reminder of how the diagram was constructed.
 
The blue lines are necessary to ensure that the diagram is geometrically correct. They ensure that the diagram in object space (to the left of the lens) is consistent with the diagram in image space (to the right of the lens).

Of course, the blue lines could be erased after the diagram has been drawn, but I think it is probably a good idea to keep them as a reminder of how the diagram was constructed.
They also limit you to a thin-lens approximation, which you don't want. It leaves many viewers convinced that your derivation only applies to a thin lens, which is not correct.

If you diagram a thick lens, or at least an asymmetrical thick lens, you will have difficulty avoiding extraneous complications, which will likely lead to people insisting that you must introduce the pupil magnification, etc., etc. So you need to deal with the complications of thick lenses verbally, perhaps stating in vague terms that it works the same. That might work, or with some readers you may get interminable arguments.

I personally would just show the object side of the lens. On the other hand, you want to show both QR and Q'R'. Sorry, nothing is perfect.
 
Last edited:
The blue lines are necessary to ensure that the diagram is geometrically correct. They ensure that the diagram in object space (to the left of the lens) is consistent with the diagram in image space (to the right of the lens).

Of course, the blue lines could be erased after the diagram has been drawn, but I think it is probably a good idea to keep them as a reminder of how the diagram was constructed.
They also limit you to a thin-lens approximation, which you don't want. It leaves many viewers convinced that your derivation only applies to a thin lens, which is not correct.

If you diagram a thick lens, or at least an asymmetrical thick lens, you will have difficulty avoiding extraneous complications, which will likely lead to people insisting that you must introduce the pupil magnification, etc., etc. So you need to deal with the complications of thick lenses verbally, perhaps stating in vague terms that it works the same. That might work, or with some readers you may get interminable arguments.

I personally would just show the object side of the lens. On the other hand, you want to show both QR and Q'R'. Sorry, nothing is perfect.
I don't disagree with your comments.

I haven't found an easy way to draw the depth of field diagrams for thick lenses without having to go into quite a lot of explanation about principal planes, pupils and pupil magnification. I didn't want to do that as the added complexity puts off many who are happy to talk about DoF for a thin lens, but who find principal points, entrance pupils, exit pupils, etc., a bit overwhelming. My diagram and its method of construction is aimed more at those people.
 
The blue lines are necessary to ensure that the diagram is geometrically correct. They ensure that the diagram in object space (to the left of the lens) is consistent with the diagram in image space (to the right of the lens).

Of course, the blue lines could be erased after the diagram has been drawn, but I think it is probably a good idea to keep them as a reminder of how the diagram was constructed.
They also limit you to a thin-lens approximation, which you don't want. It leaves many viewers convinced that your derivation only applies to a thin lens, which is not correct.

If you diagram a thick lens, or at least an asymmetrical thick lens, you will have difficulty avoiding extraneous complications, which will likely lead to people insisting that you must introduce the pupil magnification, etc., etc. So you need to deal with the complications of thick lenses verbally, perhaps stating in vague terms that it works the same. That might work, or with some readers you may get interminable arguments.

I personally would just show the object side of the lens. On the other hand, you want to show both QR and Q'R'. Sorry, nothing is perfect.
I don't disagree with your comments.

I haven't found an easy way to draw the depth of field diagrams for thick lenses without having to go into quite a lot of explanation about principal planes, pupils and pupil magnification. I didn't want to do that as the added complexity puts off many who are happy to talk about DoF for a thin lens, but who find principal points, entrance pupils, exit pupils, etc., a bit overwhelming. My diagram and its method of construction is aimed more at those people.
It sounds just right, then. The only thing is, maybe you ought to redraw it so the blue lines go through the center more accurately.
 
Hi Tom,

Your diagram is nice and very clear, though not 100% perfect.

One tool that is nice to draw diagrams is the drawing package for latex TiKz. It is very powerful with simple drawing instructions. It can calculate intersection points.

But your diagram is very nice, just wanted to mention this package in case you do not know it.
 
Honestly, I think you're conflating multiple concepts.

If you're going to take this approach I propose

3531af0c4b8a49a2a1982b76ee88d61e.jpg.png

I think P, X, and S could be more mnemonic like F, I, and N for Far, In-focus, and Near

Unclear to me what T, U, and V signify, They could be removed tooo.

--
Bill ( Your trusted source for independent sensor data at PhotonsToPhotos )
 
Honestly, I think you're conflating multiple concepts.

If you're going to take this approach I propose

3531af0c4b8a49a2a1982b76ee88d61e.jpg.png

I think P, X, and S could be more mnemonic like F, I, and N for Far, In-focus, and Near

Unclear to me what T, U, and V signify, They could be removed tooo.
Bingo!

That original version with the crossed blue lines really bothers me. This is much more consistent and logical in its approach, in my opinion.
 
Last edited:
Honestly, I think you're conflating multiple concepts.

If you're going to take this approach I propose

3531af0c4b8a49a2a1982b76ee88d61e.jpg.png

I think P, X, and S could be more mnemonic like F, I, and N for Far, In-focus, and Near

Unclear to me what T, U, and V signify, They could be removed tooo.
Shouldn't the distance between p' and x' be the same as the distance between s' and x'?

--
 
Honestly, I think you're conflating multiple concepts.

If you're going to take this approach I propose

3531af0c4b8a49a2a1982b76ee88d61e.jpg.png

I think P, X, and S could be more mnemonic like F, I, and N for Far, In-focus, and Near

Unclear to me what T, U, and V signify, They could be removed tooo.
Shouldn't the distance between p' and x' be the same as the distance between s' and x'?
No, consider what happens as the in focus object (X) approaches infinity :-)

Or, for that matter, when X is farther away than the hyperfocal point.

--
Bill ( Your trusted source for independent sensor data at PhotonsToPhotos )
 
Last edited:
Honestly, I think you're conflating multiple concepts.

If you're going to take this approach I propose

3531af0c4b8a49a2a1982b76ee88d61e.jpg.png
Yes, this diagram is more-or-less the traditional diagram for showing depth of field. The image side is well defined: once the position of the sensor plane has been decided (relative to the lens), then the positions of the points P' and S' can be determined geometrically if the circle of confusion is known.

However, if the points P and S are to be positioned correctly, the lens equation must be used to work out how far they are from the lens.

Using the more complete diagram with the blue lines included and the points Q, R, Q' and R' labelled has several advantages:

1. The positions of Q and R are determined geometrically (where the two diagonal blue lines intersect the subject plane). Hence the positions of P and S can also be determined geometrically. If the diagram is drawn to scale, then the depth of field can simply be measured on the diagram. I am not suggesting that anyone would want to do this, but to emphasise that the diagram is geometrically accurate.

2. There is a duality between image space and object space that can aid understanding. The points P', Q', R' and S' are the images of P, Q, R and S respectively. The blur Q'R' seen on the sensor is the image of the virtual blur QR in the plane of the subject.

3. Using algebraic geometry, it is not difficult to work out a formula for the depth of field in terms of other distances on the diagram.

4. Indeed, if the diagram is extended a little by adding a light ray from point Q parallel to the optical axis (so that ray goes through the focal point of the lens as well as through Q'), then it is not difficult to derive the lens equation purely from the geometry of the diagram.
 
Honestly, I think you're conflating multiple concepts.

If you're going to take this approach I propose

3531af0c4b8a49a2a1982b76ee88d61e.jpg.png
Yes, this diagram is more-or-less the traditional diagram for showing depth of field. The image side is well defined: once the position of the sensor plane has been decided (relative to the lens), then the positions of the points P' and S' can be determined geometrically if the circle of confusion is known.

However, if the points P and S are to be positioned correctly, the lens equation must be used to work out how far they are from the lens.

Using the more complete diagram with the blue lines included and the points Q, R, Q' and R' labelled has several advantages:

...
Just my opinionn.

You can make the Object (Subject) and Image (Sensor) planes whatever height you like and then place the lens at the intersection of the blue lines. So perhaps some dotted blue lines with no letter labels just to indicate how the position of the lens was determined.

You over-reach by trying to make this computational.
That would be difficult in real-life cases and an approximation.

Your stated intent was to keep the diagram simple.

--
Bill ( Your trusted source for independent sensor data at PhotonsToPhotos )
 
Hi Tom,

Your diagram is nice and very clear, though not 100% perfect.

One tool that is nice to draw diagrams is the drawing package for latex TiKz. It is very powerful with simple drawing instructions. It can calculate intersection points.

But your diagram is very nice, just wanted to mention this package in case you do not know it.
Just to complete with some interesting information. You can use variables.

Just imagine that you realize that it is better to position the focus plane further, then you would have to redraw everything.

With variables, no problems.
 

Keyboard shortcuts

Back
Top