f function of Sphere class in profile.py #132
-
Hi, I'm trying to add a new type of surface profile to rayoptics. I know I need to implement the sag function and the surface derivative function for the new surface type I want to add. So I'm studying the profile.py module and particularly the Sphere class since it is the simplest surface profile. I'm having hard time to understand the f function in Sphere class, which I re-posted below def f(self, p): This f function should be Eq. (16) of Spencer's paper, which is basically the sag function of a sphere . But I cannot derive it into the implemented form. Is there something wrong with my understanding? Thanks, John |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hello @Pinnacleman, |
Beta Was this translation helpful? Give feedback.
-
Hello @Pinnacleman, I've looked into the code more closely and I believe it is correct. It is an implementation of Spencer's eq 25, for conic surfaces. The virtue of this form of the equation is that a sqrt() isn't required. Back in the day, specializing to avoid a sqrt() delivered significant speed gains in the ray trace. Spherical is by far the most frequently used profile, and so paying attention to algorithm efficiency has some benefit here. Starting with the code:
Expanded out, the expression is:
Spencer's notation corresponds to:
Substituting notations, the code becomes
which is Spencer's eq 25 for kappa=1. I've added comments to f() in Spherical and Conic to document this. Regards, Mike Hayford |
Beta Was this translation helpful? Give feedback.
Hello @Pinnacleman,
I've looked into the code more closely and I believe it is correct. It is an implementation of Spencer's eq 25, for conic surfaces. The virtue of this form of the equation is that a sqrt() isn't required. Back in the day, specializing to avoid a sqrt() delivered significant speed gains in the ray trace. Spherical is by far the most frequently used profile, and so paying attention to algorithm efficiency has some benefit here.
Starting with the code:
Expanded out, the expression is:
Spencer's notation corresponds to:
Substituting no…