Skip to main content

When I simulate my setup, in MATLAB using the ZOS-API for raytracing, it seems to ignore or improperly account for aperture. I assume I am missing something, but don’t know what, and am looking for help on how to simulate apertures properly with raytracing. Any tips would be appreciated.

 

 

Hi Sebastian,

 

It’s hard to say without seeing your file, but the ReadNextResult methods often have an integer return parameter called vignetteCode that should tell you whether a ray is vignetted. You can then decide not to plot the rays based on this parameter. The vignetteCode should be zero if the ray isn’t vignetted, otherwise I think it is the surface number at which the ray gets vignetted.

Have a look at example 22 in the ZOS-API Syntax Help, here’s an excerpt of how they read the rays:

while success
if ((errCode == 0 ) && (vigCode == 0))
x_ary(field, wave, rayNumber) = x;
y_ary(field, wave, rayNumber) = y;
end

As you can see, they ignore the rays whose vigCode (which is the vignetteCode) are non zero.

Hope this helps.

Take care,

 

David


Thank you David,

Only using rays with no errors and no vignetting worked. Thank you very much.

x = x(0 == rayData.vignetteCode.double & 0 == rayData.errorCode.double);
y = y(0 == rayData.vignetteCode.double & 0 == rayData.errorCode.double);

 


I provided additional details in this post:  link.

Checking the codes will only be useful if you ensure that you only trace rays that are inside the normalized pupil.  If you trace Px=1.0, Py=1.0 it will not throw an error or change the vignette code > 0.

-B


Reply