Skip to main content

ZOS-API interface 2024 R2

ZOSAPI.Tools.RayTrace.IBatchRayTrace Interface Reference

Last update: 17.07.2025

Interfaces and methods for running a ray trace on multiple rays at a time. This interface can be accessed via the IOpticalSystemTools interface. More...

Inheritance diagram for ZOSAPI.Tools.RayTrace.IBatchRayTrace:

Public Member Functions

IRayTraceNormUnpolData CreateNormUnpol (int MaxRays, RaysType rayType, int toSurface)
 Performs a batch unpolarized ray trace, using normalized pupil coordinates. See the OpticStudio help manual for more information.
 
bool SingleRayNormUnpol (RaysType rayType, int toSurf, int waveNumber, double Hx, double Hy, double Px, double Py, bool calcOPD, out int ErrorCode, out int vignetteCode, out double xo, out double yo, out double zo, out double lo, out double mo, out double no, out double l2o, out double m2o, out double n2o, out double opd, out double intensity)
 Performs the same calculation as CreateNormUnpol, but for one ray at a time.
 
IRayTraceDirectUnpolData CreateDirectUnpol (int MaxRays, RaysType rayType, int startSurface, int toSurface)
 Performs a batch unpolarized ray trace, using direct x/y/z coordinates. See the OpticStudio help manual for more information.
 
bool SingleRayDirectUnpol (RaysType rayType, int startSurface, int toSurface, int waveNumber, double X, double Y, double Z, double L, double M, double N, out int ErrorCode, out int vignetteCode, out double xo, out double yo, out double zo, out double lo, out double mo, out double no, out double l2o, out double m2o, out double n2o, out double intensity)
 Performs the same calculation as CreateDirectUnpol, but for one ray at a time.
 
IRayTraceNormPolData CreateNormPol (int MaxRays, RaysType rayType, double Ex, double Ey, double phaX, double phaY, int toSurface)
 Performs a batch polarized ray trace, using normalized pupil coordinates. See the OpticStudio help manual for more information.
 
bool SingleRayNormPol (RaysType rayType, double Ex, double Ey, double phaX, double phaY, int toSurf, int waveNumber, double Hx, double Hy, double Px, double Py, double exr, double exi, double eyr, double eyi, double ezr, double ezi, out int ErrorCode, out double exro, out double exio, out double eyro, out double eyio, out double ezro, out double ezio, out double intensity)
 Performs the same calculation as CreateNormPol, but for one ray at a time.
 
bool SingleRayNormPolFull (RaysType rayType, double Ex, double Ey, double phaX, double phaY, int toSurf, int waveNumber, double Hx, double Hy, double Px, double Py, double exr, double exi, double eyr, double eyi, double ezr, double ezi, out int ErrorCode, out double xo, out double yo, out double zo, out double lo, out double mo, out double no, out double exro, out double exio, out double eyro, out double eyio, out double ezro, out double ezio, out double intensity)
 Performs the same calculation as CreateNormPol, but for one ray at a time.
 
IRayTraceDirectPolData CreateDirectPol (int MaxRays, RaysType rayType, double Ex, double Ey, double phax, double phay, int startSurface, int toSurface)
 Performs a batch polarized ray trace, using direct x/y/z coordinates. See the OpticStudio help manual for more information.
 
bool SingleRayDirectPol (RaysType rayType, double Ex, double Ey, double phaX, double phaY, int startSurface, int toSurface, int waveNumber, double X, double Y, double Z, double L, double M, double N, out int ErrorCode, out int vignetteCode, out double exro, out double exio, out double eyro, out double eyio, out double ezro, out double ezio, out double intensity)
 Performs the same calculation as CreateDirectPol, but for one ray at a time.
 
bool SingleRayDirectPolFull (RaysType rayType, double Ex, double Ey, double phaX, double phaY, int startSurface, int toSurface, int waveNumber, double X, double Y, double Z, double L, double M, double N, out int ErrorCode, out int vignetteCode, out double xo, out double yo, out double zo, out double lo, out double mo, out double no, out double exro, out double exio, out double eyro, out double eyio, out double ezro, out double ezio, out double intensity)
 Performs the same calculation as CreateDirectPol, but for one ray at a time.
 
IRayTraceNSCData CreateNSC (int MaxRays, int maxSegments, double coherenceLength)
 Creates a interface to define custom non-sequential rays.
 
IRayTraceNSCSourceData CreateNSCSourceData (int maxSegments, double coherenceLength)
 
bool GetDirectFieldCoordinates (int waveNumber, RaysType rayType, double Hx, double Hy, double Px, double Py, out double X, out double Y, out double Z, out double L, out double M, out double N)
 Convert from Normalized pupil coordinates to X/Y/Z coordinates.
 
void GetPhase (double L, double M, double N, double jx, double jy, double xPhaseDeg, double yPhaseDeg, double intensity, out double exr, out double exi, out double eyr, out double eyi, out double ezr, out double ezi)
 
- Public Member Functions inherited from ZOSAPI.Tools.ISystemTool
bool Run ()
 Start the tool. Note that for synchronous tools (see IsAsynchronous), this call will block until completion. If it is asynchronous it will start running but return immediately.
 
bool RunAndWaitForCompletion ()
 Sames as calling Run followed by WaitForCompletion.
 
bool WaitForCompletion ()
 Waits for the asynchronous tool to complete.
 
bool Cancel ()
 Cancels the currently running asynchronous tool.
 
bool Close ()
 Closes this tool and frees up and associated resources.
 
RunStatus WaitWithTimeout (double timeOutSeconds)
 Waits for the currently running tool to complete, with a specified time out value. Note that if the timeout is exceeded this method will return, however the tool will continue to run. Also note that this method will not start the tool running if it is not already.
 
RunStatus RunAndWaitWithTimeout (double timeOutSeconds)
 Starts the tool running, and waits for it to complete with the specified timeout value. Note that if the timeout is exceeded this method will return, however the tool will continue to run.
 

Additional Inherited Members

- Properties inherited from ZOSAPI.Tools.ISystemTool
int Progress [get]
 Gets the progress of the current tool, if supported.
 
string Status [get]
 Gets the status of the current tool, if supporoted.
 
bool IsRunning [get]
 Gets a value indicating whether the tool is currently running asynchronously.
 
bool CanCancel [get]
 Gets a value indicating whether the tool can be cancelled.
 
bool IsAsynchronous [get]
 Gets a value indicating whether the tool runs asynchronously (i.e. on a thread).
 
bool IsFiniteDuration [get]
 Gets a value indicating whether this tool will complete on its own.
 
bool IsValid [get]
 Gets a value indicating whether the input settings are valid.
 
bool Succeeded [get]
 Gets a value indicating whether the tool execution succeeded.
 
string ErrorMessage [get]
 If Succeeded is false, get the error messages; otherwise, null.
 

Detailed Description

Interfaces and methods for running a ray trace on multiple rays at a time. This interface can be accessed via the IOpticalSystemTools interface.

Usage (see Example 22 for a full sample)

C#

// Set up Batch Ray Trace
ZOSAPI.Tools.RayTrace.IBatchRayTrace raytrace = TheSystem.Tools.OpenBatchRayTrace();
int nsur = TheSystem.LDE.NumberOfSurfaces;
int max_rays = 30;
ZOSAPI.Tools.RayTrace.IRayTraceNormUnpolData normUnPolData = raytrace.CreateNormUnpol((max_rays + 1) * (max_rays + 1), ZOSAPI.Tools.RayTrace.RaysType.Real, nsur);
Interfaces and methods for running a ray trace on multiple rays at a time. This interface can be acce...
Definition: RayTrace.cs:239
IRayTraceNormUnpolData CreateNormUnpol(int MaxRays, RaysType rayType, int toSurface)
Performs a batch unpolarized ray trace, using normalized pupil coordinates. See the OpticStudio help ...
Definition: RayTrace.cs:12
Definition: FileSource.cs:4
The ZOSAPI namespace contains classes for initially connecting to zemax. See also ZOSAPI_Connection,...
Definition: IAS_FieldCurvatureAndDistortion.cs:5

C++

// Set up Batch Ray Trace
IBatchRayTracePtr raytrace = TheSystem->Tools->OpenBatchRayTrace();
int nsur = TheSystem->LDE->NumberOfSurfaces;
int max_rays = 30;
IRayTraceNormUnpolDataPtr normUnPolData = raytrace->CreateNormUnpol((max_rays + 1) * (max_rays + 1), RaysType::RaysType_Real, nsur);

Matlab

% Set up Batch Ray Trace
raytrace = TheSystem.Tools.OpenBatchRayTrace();
nsur = TheSystem.LDE.NumberOfSurfaces;
max_rays = 30;
normUnPolData = raytrace.CreateNormUnpol((max_rays + 1) * (max_rays + 1),ZOSAPI.Tools.RayTrace.RaysType.Real,nsur);

Python

# Set up Batch Ray Trace
raytrace = TheSystem.Tools.OpenBatchRayTrace()
nsur = TheSystem.LDE.NumberOfSurfaces
max_rays = 30
normUnPolData = raytrace.CreateNormUnpol((max_rays + 1) * (max_rays + 1), ZOSAPI.Tools.RayTrace.RaysType.Real, nsur)
Examples
CSharpStandalone_22_seq_spot_diagram.cs, and CSharpStandalone_23_ray_fan_native_manual_comparison.cs.

Member Function Documentation

◆ CreateDirectPol()

IRayTraceDirectPolData ZOSAPI.Tools.RayTrace.IBatchRayTrace.CreateDirectPol ( int  MaxRays,
RaysType  rayType,
double  Ex,
double  Ey,
double  phax,
double  phay,
int  startSurface,
int  toSurface 
)

Performs a batch polarized ray trace, using direct x/y/z coordinates. See the OpticStudio help manual for more information.

Parameters
MaxRaysThe maximum rays.
rayTypeType of the ray.
Exex.
Eyey.
phaxphase x.
phayphase y.
startSurfaceThe start surface.
toSurfaceTo surface.
Returns

◆ CreateDirectUnpol()

IRayTraceDirectUnpolData ZOSAPI.Tools.RayTrace.IBatchRayTrace.CreateDirectUnpol ( int  MaxRays,
RaysType  rayType,
int  startSurface,
int  toSurface 
)

Performs a batch unpolarized ray trace, using direct x/y/z coordinates. See the OpticStudio help manual for more information.

Parameters
MaxRaysThe maximum rays.
rayTypeType of the ray.
startSurfaceThe start surface.
toSurfaceTo surface.
Returns

◆ CreateNormPol()

IRayTraceNormPolData ZOSAPI.Tools.RayTrace.IBatchRayTrace.CreateNormPol ( int  MaxRays,
RaysType  rayType,
double  Ex,
double  Ey,
double  phaX,
double  phaY,
int  toSurface 
)

Performs a batch polarized ray trace, using normalized pupil coordinates. See the OpticStudio help manual for more information.

Parameters
MaxRaysThe maximum rays.
rayTypeType of the ray.
Exex.
Eyey.
phaXphase x.
phaYphase y.
toSurfaceTo surface.
Returns

◆ CreateNormUnpol()

IRayTraceNormUnpolData ZOSAPI.Tools.RayTrace.IBatchRayTrace.CreateNormUnpol ( int  MaxRays,
RaysType  rayType,
int  toSurface 
)

Performs a batch unpolarized ray trace, using normalized pupil coordinates. See the OpticStudio help manual for more information.

Usage (see Example 23 for a full sample)

C#

// Set up Batch Ray Trace
ZOSAPI.Tools.RayTrace.IBatchRayTrace raytrace = TheSystem.Tools.OpenBatchRayTrace();
int nsur = TheSystem.LDE.NumberOfSurfaces;
ZOSAPI.Tools.RayTrace.IRayTraceNormUnpolData normUnPolData = raytrace.CreateNormUnpol(max_rays + 1, ZOSAPI.Tools.RayTrace.RaysType.Real, nsur);

C++

// Set up Batch Ray Trace
IBatchRayTracePtr raytrace = TheSystem->Tools->OpenBatchRayTrace();
int nsur = TheSystem->LDE->NumberOfSurfaces;
IRayTraceNormUnpolDataPtr normUnPolData = raytrace->CreateNormUnpol(max_rays + 1, RaysType_Real, nsur);

Matlab

% Set up Batch Ray Trace
raytrace = TheSystem.Tools.OpenBatchRayTrace();
nsur = TheSystem.LDE.NumberOfSurfaces;
normUnPolData = raytrace.CreateNormUnpol(max_rays + 1, ZOSAPI.Tools.RayTrace.RaysType.Real, nsur);

Python

# Set up Batch Ray Trace
raytrace = TheSystem.Tools.OpenBatchRayTrace()
nsur = TheSystem.LDE.NumberOfSurfaces
normUnPolData = raytrace.CreateNormUnpol(max_rays + 1, ZOSAPI.Tools.RayTrace.RaysType.Real, nsur)
Parameters
MaxRaysThe maximum rays.
rayTypeType of the ray.
toSurfaceTo surface.
Returns
Examples
CSharpStandalone_22_seq_spot_diagram.cs, and CSharpStandalone_23_ray_fan_native_manual_comparison.cs.

◆ CreateNSC()

IRayTraceNSCData ZOSAPI.Tools.RayTrace.IBatchRayTrace.CreateNSC ( int  MaxRays,
int  maxSegments,
double  coherenceLength 
)

Creates a interface to define custom non-sequential rays.

Parameters
MaxRaysThe maximum rays.
maxSegmentsThe maximum segments.
coherenceLengthThe coherence length to use if performing a polarized ray trace.
If set to 0, the same coherence value will be used for all rays. Any other value will result in a random coherence value for each ray (for more information, see the OpticStudio documentation regarding Coherence Length).
Returns

◆ CreateNSCSourceData()

IRayTraceNSCSourceData ZOSAPI.Tools.RayTrace.IBatchRayTrace.CreateNSCSourceData ( int  maxSegments,
double  coherenceLength 
)

◆ GetDirectFieldCoordinates()

bool ZOSAPI.Tools.RayTrace.IBatchRayTrace.GetDirectFieldCoordinates ( int  waveNumber,
RaysType  rayType,
double  Hx,
double  Hy,
double  Px,
double  Py,
out double  X,
out double  Y,
out double  Z,
out double  L,
out double  M,
out double  N 
)

Convert from Normalized pupil coordinates to X/Y/Z coordinates.

Parameters
waveNumberThe wave number.
rayTypeType of the ray.
Hxhx.
Hyhy.
Pxpx.
Pypy.
Xx.
Yy.
Zz.
Ll.
Mm.
Nn.
Returns

◆ GetPhase()

void ZOSAPI.Tools.RayTrace.IBatchRayTrace.GetPhase ( double  L,
double  M,
double  N,
double  jx,
double  jy,
double  xPhaseDeg,
double  yPhaseDeg,
double  intensity,
out double  exr,
out double  exi,
out double  eyr,
out double  eyi,
out double  ezr,
out double  ezi 
)

◆ SingleRayDirectPol()

bool ZOSAPI.Tools.RayTrace.IBatchRayTrace.SingleRayDirectPol ( RaysType  rayType,
double  Ex,
double  Ey,
double  phaX,
double  phaY,
int  startSurface,
int  toSurface,
int  waveNumber,
double  X,
double  Y,
double  Z,
double  L,
double  M,
double  N,
out int  ErrorCode,
out int  vignetteCode,
out double  exro,
out double  exio,
out double  eyro,
out double  eyio,
out double  ezro,
out double  ezio,
out double  intensity 
)

Performs the same calculation as CreateDirectPol, but for one ray at a time.

Parameters
rayTypeType of the ray.
Exex.
Eyey.
phaXphase x.
phaYphase y.
startSurfaceThe start surface.
toSurfaceTo surface.
waveNumberThe wave number.
Xx.
Yy.
Zz.
Ll.
Mm.
Nn.
ErrorCodeThe error code.
vignetteCodeThe vignette code.
exroexro.
exioexio.
eyroeyro.
eyioeyio.
ezroezro.
ezioezio.
intensityThe intensity.
Returns

◆ SingleRayDirectPolFull()

bool ZOSAPI.Tools.RayTrace.IBatchRayTrace.SingleRayDirectPolFull ( RaysType  rayType,
double  Ex,
double  Ey,
double  phaX,
double  phaY,
int  startSurface,
int  toSurface,
int  waveNumber,
double  X,
double  Y,
double  Z,
double  L,
double  M,
double  N,
out int  ErrorCode,
out int  vignetteCode,
out double  xo,
out double  yo,
out double  zo,
out double  lo,
out double  mo,
out double  no,
out double  exro,
out double  exio,
out double  eyro,
out double  eyio,
out double  ezro,
out double  ezio,
out double  intensity 
)

Performs the same calculation as CreateDirectPol, but for one ray at a time.

Parameters
rayTypeType of the ray.
Exex.
Eyey.
phaXphase x.
phaYphase y.
startSurfaceThe start surface.
toSurfaceTo surface.
waveNumberThe wave number.
Xx.
Yy.
Zz.
Ll.
Mm.
Nn.
ErrorCodeThe error code.
vignetteCodeThe vignette code.
xooutput x.
yooutput y.
zooutput z.
looutput l.
mooutput m.
nooutput n.
exrooutput exr.
exiooutput exi.
eyrooutput eyr.
eyiooutput eyi.
ezrooutput ezr.
eziooutput ezi.
intensityThe intensity.
Returns

◆ SingleRayDirectUnpol()

bool ZOSAPI.Tools.RayTrace.IBatchRayTrace.SingleRayDirectUnpol ( RaysType  rayType,
int  startSurface,
int  toSurface,
int  waveNumber,
double  X,
double  Y,
double  Z,
double  L,
double  M,
double  N,
out int  ErrorCode,
out int  vignetteCode,
out double  xo,
out double  yo,
out double  zo,
out double  lo,
out double  mo,
out double  no,
out double  l2o,
out double  m2o,
out double  n2o,
out double  intensity 
)

Performs the same calculation as CreateDirectUnpol, but for one ray at a time.

Parameters
rayTypeType of the ray.
startSurfaceThe start surface.
toSurfaceTo surface.
waveNumberThe wave number.
Xx.
Yy.
Zz.
Ll.
Mm.
Nn.
ErrorCodeThe error code.
vignetteCodeThe vignette code.
xoxo.
yoyo.
zozo.
lolo.
momo.
nono.
l2ol2o.
m2om2o.
n2on2o.
intensityThe intensity.
Returns

◆ SingleRayNormPol()

bool ZOSAPI.Tools.RayTrace.IBatchRayTrace.SingleRayNormPol ( RaysType  rayType,
double  Ex,
double  Ey,
double  phaX,
double  phaY,
int  toSurf,
int  waveNumber,
double  Hx,
double  Hy,
double  Px,
double  Py,
double  exr,
double  exi,
double  eyr,
double  eyi,
double  ezr,
double  ezi,
out int  ErrorCode,
out double  exro,
out double  exio,
out double  eyro,
out double  eyio,
out double  ezro,
out double  ezio,
out double  intensity 
)

Performs the same calculation as CreateNormPol, but for one ray at a time.

Parameters
rayTypeType of the ray.
Exex.
Eyey.
phaXphase x.
phaYphase y.
toSurfTo surf.
waveNumberThe wave number.
Hxhx.
Hyhy.
Pxpx.
Pypy.
exrexr.
exiexi.
eyreyr.
eyieyi.
ezrezr.
eziezi.
ErrorCodeThe error code.
exroexro.
exioexio.
eyroeyro.
eyioeyio.
ezroezro.
ezioezio.
intensityThe intensity.
Returns

◆ SingleRayNormPolFull()

bool ZOSAPI.Tools.RayTrace.IBatchRayTrace.SingleRayNormPolFull ( RaysType  rayType,
double  Ex,
double  Ey,
double  phaX,
double  phaY,
int  toSurf,
int  waveNumber,
double  Hx,
double  Hy,
double  Px,
double  Py,
double  exr,
double  exi,
double  eyr,
double  eyi,
double  ezr,
double  ezi,
out int  ErrorCode,
out double  xo,
out double  yo,
out double  zo,
out double  lo,
out double  mo,
out double  no,
out double  exro,
out double  exio,
out double  eyro,
out double  eyio,
out double  ezro,
out double  ezio,
out double  intensity 
)

Performs the same calculation as CreateNormPol, but for one ray at a time.

Parameters
rayTypeType of the ray.
Exex.
Eyey.
phaXphase x.
phaYphase y.
toSurfTo surf.
waveNumberThe wave number.
Hxhx.
Hyhy.
Pxpx.
Pypy.
exrexr.
exiexi.
eyreyr.
eyieyi.
ezrezr.
eziezi.
ErrorCodeThe error code.
xooutput x.
yooutput y.
zooutput z.
looutput l.
mooutput m.
nooutput n.
exrooutput exr.
exiooutput exi.
eyrooutput eyr.
eyiooutput eyi.
ezrooutput ezr.
eziooutput ezi.
intensityThe intensity.
Returns

◆ SingleRayNormUnpol()

bool ZOSAPI.Tools.RayTrace.IBatchRayTrace.SingleRayNormUnpol ( RaysType  rayType,
int  toSurf,
int  waveNumber,
double  Hx,
double  Hy,
double  Px,
double  Py,
bool  calcOPD,
out int  ErrorCode,
out int  vignetteCode,
out double  xo,
out double  yo,
out double  zo,
out double  lo,
out double  mo,
out double  no,
out double  l2o,
out double  m2o,
out double  n2o,
out double  opd,
out double  intensity 
)

Performs the same calculation as CreateNormUnpol, but for one ray at a time.

Parameters
rayTypeType of the ray.
toSurfTo surf.
waveNumberThe wave number.
Hxhx.
Hyhy.
Pxpx.
Pypy.
calcOPDif set to true the Optical Path Difference will be calculated. Note that this can only be done when tracing rays to the Image surface.
ErrorCodeThe error code.
vignetteCodeThe vignette code.
xoxo.
yoyo.
zozo.
lolo.
momo.
nono.
l2ol2o.
m2om2o.
n2on2o.
opdThe OPD, if calculated.
intensityThe intensity.
Returns

Connect with Ansys