Skip to main content
Hello, 





I'm studying the raytrace using ZOS-API and Matlab. I could get the raytrace results using Batch raytrace example. (example # 22) 


The results show the each ray position(on the interesting surface) in local coordinate. If I want to convert this local coordinate to global, which way is best? I'm thinking of using global surface coordinate to use it as a reference for conversion. But, I cannot find the exporting global coordinate of the each surface as well. So my question is 





1) Can the batch raytace result be exported in global coordinate?


2) How do I get the global coordinate of each surface?





Thanks in advance for your help! 
Hello,





You can convert local coordinates to global coordinates by using the GetGlobalMatrix method from the ILensDataEditor Interface:




















For more information on the rotation matrix, you can check out this knowledgebase article:





https://my.zemax.com/en-US/Knowledge-Base/kb-article/?ka=KA-01638





I hope this helps!
Thanks for comments.


I tried this way, but the batch raytrace results wasn't change. The coordinate are still on the local axis. 
You will need to write a line similar to below to obtain the global matrix for each surface in the optical system. In the example below, the global matrix is returned for the image plane. This matrix can then be used to convert from the local to global coordinates.





nsur = TheSystem.LDE.NumberOfSurfaces;





 [validSurf, R11, R12, R13, R21, R22, R23, R31, R32, R33, X0, Y0, Z0] = TheLDE.GetGlobalMatrix(nsur-1)











I hope this helps!
Hello, Alastair. 





Oh, I got it. This coordinate is the global coordinate of the origin of local axis of surface. And R matrix indicates the tilt amount. 


Then I can convert the batch raytrace result to global using this information.





Thanks, it's helpful! 


Have a nice rest of the day. 


 

Reply