optiland icon indicating copy to clipboard operation
optiland copied to clipboard

draw in xz and xy plane and 3D at fixed angles

Open ZvejysMegejas opened this issue 4 months ago • 1 comments

A 3D model (a modified version of the Tutorial 1e)

import numpy as np
from optiland import analysis, optic, optimization

lens = optic.Optic()

# System settings
lens.set_aperture(aperture_type="EPD", value=10.0)
lens.set_field_type(field_type="angle")
lens.add_field(y=0)
lens.add_wavelength(value=0.633, is_primary=True)

# Lens data
lens.add_surface(   index=0, radius=np.inf, z=-np.inf, rx=0, ry=0, rz=0)
lens.add_surface(   index=1, z=0, rx=0, ry=0, rz=0)
lens.add_surface(   index=2, z=5, radius=100, material="bk7",  is_stop=True, rx=0, ry=0, rz=0, aperture=15)  # material in
lens.add_surface(   index=3, z=10, radius=-100, material="air", rx=0, ry=0, rz=0, aperture=15)  # material out
lens.add_surface(   index=4, z=25, material="mirror", rx=-(np.radians(45)+ np.radians(2)), ry=0, rz=0, aperture= 15)  # first mirror
lens.add_surface(   index=5, z=25, y=-15, material="mirror", rx=-(np.radians(45) + np.radians(2)) , ry= np.pi / 2, rz=0, aperture=15)  # second mirror
lens.add_surface(   index=6, z=25, y=-15, x=50, rx=0, ry= np.radians(90), rz=0)  # Image plane

lens.draw(num_rays=10)
lens.draw3D(num_rays=10)

In principle it is a 2D galvo setup.

It would great to have possibility to 'draw' in xz and xy as well. Also setting a 'draw3D' view angle would be great too.

The system give a warning: [optiland\visualization\system\surface.py:153]: UserWarning: Gimbal lock detected. Setting third angle to zero since it is not possible to uniquely determine all angles. actor = transform_3d(actor, self.surf)'

I set all rx, ry, rz=0, still the same warning.

In the example lens.draw creates at a vertical line of unknown origin - a bug?

Image

ZvejysMegejas avatar Aug 18 '25 14:08 ZvejysMegejas

Hi @ZvejysMegejas,

Thanks for opening this issue!

I have confirmed the issue. This is a bug in the 2D plotting. I will investigate this and see if there is a simple fix. I'll use this issue to track the progress.

It would great to have possibility to 'draw' in xz and xy as well.

This is a very good suggestion. We can add it to the roadmap.

Best, Kramer

HarrisonKramer avatar Aug 18 '25 16:08 HarrisonKramer