Skip to content

fix: thin lens pupil calculations - #375

Merged
kmdouglass merged 3 commits into
mainfrom
fix_thin_lens_stop
Jun 20, 2026
Merged

fix: thin lens pupil calculations#375
kmdouglass merged 3 commits into
mainfrom
fix_thin_lens_stop

Conversation

@kmdouglass

@kmdouglass kmdouglass commented Jun 20, 2026

Copy link
Copy Markdown
Owner

Reverse paraxial ray tracing (used for entrance pupil and front focal point/principal plane calculations) inverts each refraction step by negating the gap thickness and swapping n_0/n_1. For Conic and Sphere surfaces this swap also negates the surface's power for free, because their power formula (n_1 - n_0) / roc is antisymmetric in (n_0, n_1); but ThinLens overrides power() to be media-independent (1 / focal_length regardless of arguments), so the swap had no effect and reverse traces used the wrong sign of power through any thin lens.

This produced incorrect entrance pupil locations whenever a thin lens sat between the object and the aperture stop, e.g. the epifluorescence excitation path's entrance pupil was computed 31.58 mm after the first thin lens instead of 54.55 mm before it.

surface_to_rtm now takes the reverse flag explicitly and negates the power directly when reversed, by calling power() with the original (un-swapped) n_0/n_1 ordering rather than relying on the formula's antisymmetry. This keeps Conic/Sphere behavior unchanged while fixing ThinLens.

Adds the wf_epi_excitation example/test reproducing the reported system and asserting the hand-calculated entrance pupil location.

Reverse paraxial ray tracing (used for entrance pupil and front
focal point/principal plane calculations) inverts each refraction
step by negating the gap thickness and swapping n_0/n_1. For Conic
and Sphere surfaces this swap also negates the surface's power for
free, because their power formula (n_1 - n_0) / roc is antisymmetric
in (n_0, n_1) — but ThinLens overrides power() to be media-independent
(1 / focal_length regardless of arguments), so the swap had no effect
and reverse traces used the wrong sign of power through any thin lens.

This produced incorrect entrance pupil locations whenever a thin lens
sat between the object and the aperture stop — e.g. the epifluorescence
excitation path's entrance pupil was computed 31.58 mm after the first
thin lens instead of 54.55 mm before it.

surface_to_rtm now takes the reverse flag explicitly and negates the
power directly when reversed, by calling power() with the original
(un-swapped) n_0/n_1 ordering rather than relying on the formula's
antisymmetry. This keeps Conic/Sphere behavior unchanged while fixing
ThinLens.

Adds the wf_epi_excitation example/test reproducing the reported
system and asserting the hand-calculated entrance pupil location.
@kmdouglass kmdouglass changed the title Fix thin lens pupil calculations fix: thin lens pupil calculations Jun 20, 2026
@kmdouglass
kmdouglass merged commit c076c07 into main Jun 20, 2026
1 check passed
@kmdouglass
kmdouglass deleted the fix_thin_lens_stop branch June 20, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant