From Trisha (her email includes images that are helpful).
Subject: Forgot to send you this code
These were the lines in PBRT that calculated for the intersection of a biconic.
The code that does the intersection can be found here.
However, when scrolling through I think the calculation is more complicated that I originally thought. Instead, the following equations might be more helpful. These are from a paper called "The Individual Virtual Eye: a Computer Model for Advanced Intraocular Lens Calculation," where I got a most of the biconic/aspheric equations from. I think I followed the paper pretty closely.
Firstly, we have the SAG equation for a biconic surface:
...
We will also need the derivative of z, the SAG later. We can solve for the partial derivatives of f(x,y) and g(x,y):
...
Note, he writes "z" here as the SAG function but later renames it to "u" to avoid confusing with the z-axis.
Now we have the ray origin (E) and its direction (D), so we can write the ray in its parametric form:
...
To find the intersection, we have the origin of the ray(E) and it's direction:
...
So we need to solve for "t" such that:
...
We solve this using a root finding method, which requires
After the intersection is solved, we also need to calculate for the normal in order to do Snell's law. I believe I calculated the normal by taking the cross product of the x and y derivatives, at the intersection, thus giving the normal vector. You can see that in the PBRT code here.
With the normal, we can do Snell's law.
...
I can also run through the C++ code with you if that would help. It was more complicated than I remember!
From Trisha (her email includes images that are helpful).
Subject: Forgot to send you this code
These were the lines in PBRT that calculated for the intersection of a biconic.
The code that does the intersection can be found here.
However, when scrolling through I think the calculation is more complicated that I originally thought. Instead, the following equations might be more helpful. These are from a paper called "The Individual Virtual Eye: a Computer Model for Advanced Intraocular Lens Calculation," where I got a most of the biconic/aspheric equations from. I think I followed the paper pretty closely.
Firstly, we have the SAG equation for a biconic surface:
...
We will also need the derivative of z, the SAG later. We can solve for the partial derivatives of f(x,y) and g(x,y):
...
Note, he writes "z" here as the SAG function but later renames it to "u" to avoid confusing with the z-axis.
Now we have the ray origin (E) and its direction (D), so we can write the ray in its parametric form:
...
To find the intersection, we have the origin of the ray(E) and it's direction:
...
So we need to solve for "t" such that:
...
We solve this using a root finding method, which requires
After the intersection is solved, we also need to calculate for the normal in order to do Snell's law. I believe I calculated the normal by taking the cross product of the x and y derivatives, at the intersection, thus giving the normal vector. You can see that in the PBRT code here.
With the normal, we can do Snell's law.
...
I can also run through the C++ code with you if that would help. It was more complicated than I remember!