fix: thin lens pupil calculations - #375
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.