Hello there friends from the Zemax community,
I am trying to use the ZOS-API to perform some ray tracing calculations via python.
In general I have a basic working system and my question is specifically related to how can I express the obtained direction cosines at a given surface in terms of the global coordinate system.
First at all, I do:
normUnpol = raytr.CreateNormUnpol(maxrays, ZOSAPI.Tools.RayTrace.RaysType.Real, surf)
Here, I am trying to get all relevant information for the rays traces until the surface surf right? Then, I extract the relevant information via:
output = normUnpol.ReadNextResult(sysInt, sysInt, sysInt,
sysDbl, sysDbl, sysDbl, sysDbl, sysDbl, sysDbl, sysDbl, sysDbl, sysDbl, sysDbl, sysDbl);
In where output contains all of the relevant information to each traced ray(position, surface normals, direction cosines, etc). Now, I know that this information is given in the local coordinate system associated to each traced ray. Also, after checking the other posts in this community forum, I found that all of these quantities can be expressed in terms of the global coordinate system by obtaining a rotation matrix associated to my surface as:
(success,
R11, R12, R13, \
R21, R22, R23, \
R31, R32, R33, \
XO, YO, ZO) = TheSystem.LDE.GetGlobalMatrix(
int(surf),
sysDbl, sysDbl, sysDbl, sysDbl,
sysDbl, sysDbl, sysDbl, sysDbl,
sysDbl, sysDbl, sysDbl, sysDbl,
)
However, the rotation matrix assembled from the R11, R12, .., etc, components is just an identity matrix in my case. What am I missing in this case? If I just transform my direction cosines vectors by this identity matrix, I just get the same vectors.
Also, the direction cosines obtained from the ray tracing at each surface (the direction cosines in the output vector), are these the incident direction cosines or the direction cosines after refraction? Finally, just to double check, these vectors are expressed in the local coordinate system for each ray right? i.e, with the local z axis aligned with the corresponding normal vector to the surface at each given point. Is this correct?
In advance, thanks a lot for the feedback!