Can imported ZMX lens descriptions be reversed?
Show older comments
It's very common for imported aspheric lenses to be facing the wrong way for a model. They can have many parameters so reversing them requires understanding of a whole heirarchy e.g. of aspheric coefficients and how they relate to the surface direction and origin. It would seem that the model understands the whole geometry - does it have a simple way to flip the lens?
Answers (2)
Ashish Uthama
on 8 Jun 2026
1 vote
@Colin - can you give the attached code a try and see if it works for you?
(Feel free to DM me if you want to talk more)
opsys = zmximport("ACL12708U-A-Zemax-ZMX.zmx");
opsys.FieldPoints = fieldPoint("Position",[0 0],"ReferenceFrame","Image");
opsys.Wavelengths = 633;
ropsys = reverseSystem(opsys);
subplot(211), h1=view2d(opsys); h1.addRays;
subplot(212), h2=view2d(ropsys); h2.addRays;

Ashish Uthama
on 1 Jun 2026
It's very common for imported aspheric lenses to be facing the wrong way for a model.
I would like to understand this better, i.e why its common. I would rather this not happen in the first place! If there is a determinstic way to do the right thing, I would like to know.
Here's code for my interpretation of 'facing the wrong way'. The origin (position) and tilt angles are retained.
opsys = zmximport("systemWithAspherics.zmx");
tiledlayout
nexttile
h = view2d(opsys,Labels="surface");
% Assume surface 12 is the aspheric surface.
% Flip sign of the even aspheric terms and the raidus
opsys.Surfaces(12).Aspherics(2:2:end)= -opsys.Surfaces(12).Aspherics(2:2:end);
opsys.Surfaces(12).Radius = -opsys.Surfaces(12).Radius;
nexttile
h = view2d(opsys,Labels="surface");
3 Comments
Colin
on 2 Jun 2026
Colin
on 2 Jun 2026
Ashish Uthama
on 2 Jun 2026
I think I totally missed your point!
Is the use case to flip the whole system around so light goes 'the other' way? So instead of say, S1->S2->S3 in a doublet, you want light to go from S3->S2->S1?
Categories
Find more on Optics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!