How to use the raytracing.Lens function in raytracing

To help you get started, we’ve selected a few raytracing examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DCC-Lab / RayTracing / examples / argsExamples / example4.py View on Github external
from raytracing import ImagingPath, Space, Lens, Aperture

'''Demo #4 - Aperture behind lens
Notice the aperture stop (AS) identified after the lens, not at the lens. Again, since there is no field stop,
we cannot restrict the object to the field of view because it is infinite.'''


path = ImagingPath()
path.label = "Demo #4: Aperture behind lens"
path.append(Space(d=10))
path.append(Lens(f=5, diameter=3))
path.append(Space(d=3))
path.append(Aperture(diameter=3))
path.append(Space(d=17))
path.display()
github DCC-Lab / RayTracing / examples / argsExamples / example13.py View on Github external
from raytracing import ImagingPath, Space, Lens


'''Demo #13: - An object at z=0 (front edge) is used. It is shown in blue. The image (or any intermediate images) are shown in red.\n\
This will use the default objectHeight and fanAngle but they can be changed with:
path.objectHeight = 1.0
path.fanAngle = 0.5
path.fanNumber = 5
path.rayNumber = 3'''


M1 = Space(d=10)
M2 = Lens(f=5)
M3 = M2 * M1
print(M3.forwardConjugate())
print(M3.backwardConjugate())
github DCC-Lab / RayTracing / examples / argsExamples / example10.py View on Github external
from raytracing import ImagingPath, Space, Lens, Aperture

'''
    Demo #10 - A retrofocus has a back focal length longer than the effective focal length. It comes from a diverging lens followed by a converging
    lens. We can always obtain the effective focal lengths and the back focal length of a system.
'''


path = ImagingPath()
path.fanAngle = 0.05
path.append(Space(d=20))
path.append(Lens(f=-10, label='Div'))
path.append(Space(d=7))
path.append(Lens(f=10, label='Foc'))
path.append(Space(d=40))
(focal, focal) = path.effectiveFocalLengths()
bfl = path.backFocalLength()
path.label = "Demo #10: Retrofocus $f_e$={0:.1f} cm, and BFL={1:.1f}".format(focal, bfl)
path.display()
github DCC-Lab / RayTracing / examples / argsExamples / example3.py View on Github external
from raytracing import ImagingPath, Space, Lens

'''Demo #3 - A finite lens
   An object at z=0 (front edge) is used with default properties (see Demo #1). Notice the aperture stop (AS)
   identified at the lens which blocks the cone of light. There is no field stop to restrict the field of view,
   which is why we must use the default object and cannot restrict the field of view. Notice how the default
   rays are blocked.'''


path = ImagingPath()
path.label = "Demo #3: Finite lens"
path.append(Space(d=10))
path.append(Lens(f=5, diameter=2.5))
path.append(Space(d=3))
path.append(Space(d=17))
path.display()
github DCC-Lab / RayTracing / examples / argsExamples / example5.py View on Github external
'''Demo #5 - Simple microscope system
The aperture stop (AS) is at the entrance of the objective lens, and the tube lens, in this particular microscope, is
the field stop (FS) and limits the field of view. Because the field stop exists, we can use limitObjectToFieldOfView=True
when displaying, which will set the objectHeight to the field of view, but will still trace all the rays using our parameters.
'''

path = ImagingPath()
path.label = "Demo #5: Simple microscope system"
path.fanAngle = 0.1  # full fan angle for rays
path.fanNumber = 5  # number of rays in fan
path.rayNumber = 5  # number of points on object
path.append(Space(d=4))
path.append(Lens(f=4, diameter=0.8, label='Obj'))
path.append(Space(d=4 + 18))
path.append(Lens(f=18, diameter=5.0, label='Tube Lens'))
path.append(Space(d=18))
path.display()
github DCC-Lab / RayTracing / examples / argsExamples / example2.py View on Github external
from raytracing import ImagingPath, Space, Lens

'''Demo #2 - Two lenses, infinite diameters
An object at z=0 (front edge) is used with default properties (see Demo #1).'''


path = ImagingPath()
path.label = "Demo #2: Two lenses, infinite diameters"
path.append(Space(d=10))
path.append(Lens(f=5))
path.append(Space(d=20))
path.append(Lens(f=5))
path.append(Space(d=10))
path.display()
github DCC-Lab / RayTracing / examples / argsExamples / example6.py View on Github external
'''
    Demo #6 - Simple microscope system, only principal rays
    The aperture stop (AS) is at the entrance of the objective lens, and the tube lens, in this particular microscope, is
    the field stop (FS) and limits the field of view. Because the field stop exists, we can use limitObjectToFieldOfView=True
    when displaying, which will set the objectHeight to the field of view. We can also require that only the principal rays are drawn: chief ray
    marginal ray (or axial ray).
'''


path = ImagingPath()
path.label = "Demo #6: Simple microscope system, only principal rays"
path.append(Space(d=4))
path.append(Lens(f=4, diameter=0.8, label='Obj'))
path.append(Space(d=4 + 18))
path.append(Lens(f=18, diameter=5.0, label='Tube Lens'))
path.append(Space(d=18))
path.display()
github DCC-Lab / RayTracing / examples / argsExamples / example1.py View on Github external
from raytracing import ImagingPath, Space, Lens

'''Demo #1 - An object at z=0 (front edge) is used. It is shown in blue. The image (or any intermediate images) are shown in red.\n\
This will use the default objectHeight and fanAngle but they can be changed with:
path.objectHeight = 1.0
path.fanAngle = 0.5
path.fanNumber = 5
path.rayNumber = 3'''


path = ImagingPath()
path.label = "Demo #1: lens f = 5cm, infinite diameter"
path.append(Space(d=10))
path.append(Lens(f=5))
path.append(Space(d=10))
path.display()
github DCC-Lab / RayTracing / examples / argsExamples / example7.py View on Github external
from raytracing import ImagingPath, Space, Lens, Aperture, DielectricSlab

'''
    Demo #7 - Focussing through a dielectric slab
'''


path = ImagingPath()
path.label = "Demo #7: Focussing through a dielectric slab"
path.append(Space(d=10))
path.append(Lens(f=5))
path.append(Space(d=3))
path.append(DielectricSlab(n=1.5, thickness=4))
path.append(Space(d=10))
path.display()
github DCC-Lab / RayTracing / examples / argsExamples / example8.py View on Github external
from raytracing import ImagingPath, Space, Lens, Aperture


'''
    Demo #8 - Virtual image at -2f with object at f/2
'''


path = ImagingPath()
path.label = "Demo #8: Virtual image at -2f with object at f/2"
path.append(Space(d=2.5))
path.append(Lens(f=5))
path.append(Space(d=10))
path.display()

raytracing

Simple optical ray tracing library to validate the design of an optical system (lenses positions and sizes, focal lengths, aperture and field stops). Support for Monte Carlo raytracing to estimate transmission efficiency and powers, limited but functional Zemax file loader for lenses, several material dispersion curves included for chromatic aberrations all coming from http://refractiveindex.info

MIT
Latest version published 3 months ago

Package Health Score

64 / 100
Full package analysis