Skip to content

f function of Sphere class in profile.py #132

Answered by mjhoptics
Pinnacleman asked this question in Q&A
Discussion options

You must be logged in to vote

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:

F = p[2] - 0.5*self.cv*(np.dot(p, p))

Expanded out, the expression is:

F = p[2] - 0.5*self.cv*(p[0]*p[0] + p[1]*p[1] + p[2]*p[2])

Spencer's notation corresponds to:

rho**2 = p[0]*p[0] + p[1]*p[1]
Z = p[2]

Substituting no…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Pinnacleman
Comment options

Answer selected by mjhoptics
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants