Solved

Intersection algorithm

  • 9 March 2024
  • 2 replies
  • 95 views

Help please!Does anyone know the algorithm for finding intersection points between rays and aspherical surfaces in Zemax?How is the intersection calculated? The intersection algorithm is what?I would be extremely grateful if you could help me. 🙏🏻

icon

Best answer by MichaelH 10 March 2024, 02:34

View original

2 replies

Userlevel 6
Badge +2

Hi Zane,

In sequential mode, Zemax first traces to the plane tangent to the vertex of the next surface and then calculates the extra distance from the tangent plane to the actual surface.  Zemax uses the XYZ value of the ray at the tangent plane and the LMN direction cosines to propagate to the actual surface.

There are a few algorithms used to find the intersection of a ray with a surface:

  1. a simple analytic algorithm
  2. a slightly better iterative algorithm
  3. a very complex, robust, proprietary iterative algorithm

Zemax publishes the simple analytic algorithm (#1) and a slightly better iterative algorithm (#2), but they do not publish their complex, robust iterative algorithm (#3) (it’s their secret sauce so it makes sense they don’t publish it).  The first two algorithms can be found in the Zemax\DLL\Surfaces with the following files being the most useful:

  • us_anamr.c
  • us_anasp.c
  • us_array.c
  • us_tera.c
  • us_ogive.c

All examples are under case 5 (real ray trace).  Note that to have a truly robust algorithm that traces in all cases you will have to put in a lot of extra work, especially for aspheres with high fields of view.  The reason for this is the example above has a limit on the clear aperture so the uncontrolled surface outside the clear aperture “explodes” to infinity...the surface actually looks like below:

You can see that from a mathematical standpoint, the initial XYZ and LMN values will hit the asymptotic part of the surface outside the clear aperture first before hitting the “traceable part of the surface.  Furthermore, a surface like this can be created so the base curvature equation (see below) is actually smaller than XY intercept on the tangent plane, so mathematically the piece-wise function cannot be computed with the initial XY values:

For extreme surfaces like this, Zemax falls back on their complex, robust, proprietary algorithm.  I believe this algorithm is more like the non-sequential ray trace engine and unfortunately there is no published documentation about the inner workings of teh non-sequential ray trace engine. 

Hi Zane,

In sequential mode, Zemax first traces to the plane tangent to the vertex of the next surface and then calculates the extra distance from the tangent plane to the actual surface.  Zemax uses the XYZ value of the ray at the tangent plane and the LMN direction cosines to propagate to the actual surface.

There are a few algorithms used to find the intersection of a ray with a surface:

  1. a simple analytic algorithm
  2. a slightly better iterative algorithm
  3. a very complex, robust, proprietary iterative algorithm

Zemax publishes the simple analytic algorithm (#1) and a slightly better iterative algorithm (#2), but they do not publish their complex, robust iterative algorithm (#3) (it’s their secret sauce so it makes sense they don’t publish it).  The first two algorithms can be found in the Zemax\DLL\Surfaces with the following files being the most useful:

  • us_anamr.c
  • us_anasp.c
  • us_array.c
  • us_tera.c
  • us_ogive.c

All examples are under case 5 (real ray trace).  Note that to have a truly robust algorithm that traces in all cases you will have to put in a lot of extra work, especially for aspheres with high fields of view.  The reason for this is the example above has a limit on the clear aperture so the uncontrolled surface outside the clear aperture “explodes” to infinity...the surface actually looks like below:

You can see that from a mathematical standpoint, the initial XYZ and LMN values will hit the asymptotic part of the surface outside the clear aperture first before hitting the “traceable part of the surface.  Furthermore, a surface like this can be created so the base curvature equation (see below) is actually smaller than XY intercept on the tangent plane, so mathematically the piece-wise function cannot be computed with the initial XY values:

For extreme surfaces like this, Zemax falls back on their complex, robust, proprietary algorithm.  I believe this algorithm is more like the non-sequential ray trace engine and unfortunately there is no published documentation about the inner workings of teh non-sequential ray trace engine. 

Thank you very much for your kind help sir!

Reply