Hi Hans,
There is not a 100% equivalent method with the simplicity of RAYTRACE in the ZPL. The closest method is the SingleRayNormUnpol
under the IOpticalSystemTools interface. The 2 biggest differences is:
- SingleRayNormUnpol will only trace to a single surface, so if you want all the surfaces you’ll need to call this method inside a for loop
- All results are in local coordinates, so if you want something like
RAG*
, then you’ll need to get the Global Rotation Matrix for the given surface.
Some pseudo code would look like the following:
var tool = TheSystem.Tools.OpenBatchRayTrace();
for (int surf = 1; surf < TheSystem.LDE.NumberOfSurfaces; surf++)
{
var raytrace = tool.SingleRayNormUnpol(RaysType.Real, surf, wavenumber, hx, hy, px, py, true,
out int errorCode, out int vignetteCode,
out double x, out double y, out double z,
out double l, out double m, out double n,
out double nx, out double ny, out double nz,
out double opd, out double intensity);
if (useGlobal){
TheSystem.LDE.GetGlobalMatrix(surf,
out double r11, out double r12, out double r13,
out double r21, out double r22, out double r23,
out double r31, out double r32, out double r33,
out double xo, out double yo, out double zo);
double xg = xo + r11 * x + r12 * y + r13 * z;
double yg = yo + r21 * x + r22 * y + r23 * z;
double zg = zo + r31 * x + r32 * y + r33 * z;
x = xg;
y = yg;
z = zg;
}
}
tool.Close();