Hey Mark,
All values in OpticStudio sequential mode are always calculated in local coordinates from one surface to the next. In order to convert from local to global, you’ll need to get the Global Rotation Matrix for the given surface and convert to global; this is the same operation that the Single Ray Trace does when you click “Global Coordinates”. The xo, yo, zo are the surface vertex offsets and the r## are the Euler rotation matrix. Below is Python code to calculate this (note this is only for XYZ values...LMN values are :
def l2g(self, surf, xl, yl, zl):
_, r11, r12, r13, r21, r22, r23, r31, r32, r33, xo, yo, zo = self.TheSystem.LDE.GetGlobalMatrix(surf, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
xg = r11 * xl + r12 * yl + r13 * zl
yg = r21 * xl + r22 * yl + r23 * zl
zg = r31 * xl + r32 * yl + r33 * zl
return xg, yg, zg]
As for a way in the API to return similar results to the Single Ray Trace, you will need to loop through each surface with the SingleRayNormUnpol method (rather than the CreateNormUnpol); this allows you to get the XYZ, LMN, and Normal vectors. Note that the “Path Length" is going to be the physical length of the ray, not the optical length, so you can calculate this with the Cartesian distance formula. Also, you will need to handle Non-Sequential Components separately since the SingleRayNormUnpol is only for sequential mode.