Optometrika

Version 2.3.2.0 (382 KB) by Yury
Optometrika MATLAB library implements analytical and iterative ray tracing approximation to optical image formation using Snell’s and Fresne
11.3K Downloads
Updated 18 Jan 2022

OPTOMETRIKA
Developer: Yury Petrov

Optometrika library implements analytical and iterative ray tracing approximation to optical image formation using Snell’s and Fresnel’s laws of refraction and reflection.
Currently, the library implements refractive and reflective general surfaces, aspheric (conic) surfaces with astigmatism, Fresnel surfaces, cones and cylinders (elliptic too), planes, circular and ring-shaped apertures, rectangular flat screens, spheroidal screens, and a realistic model of the human eye with accommodating lens and spheroidal retina. See example*.m files for examples of ray tracing in general (user-defined shape) lenses, aspheric lenses, Fresnel lenses, prisms, mirrors, and human eye.

The library traces refracted rays, including intensity loss at the refractive surface. Reflected rays are currently traced for mirrors and also for a single total internal reflexion or double refraction, if it happens. Note that the Bench class object is not a real physical bench, it is only an ordered array of optical elements, and it is your responsibility to arrange optical objects in the right order. In particular, if you need to trace rays passing through the same object multiple times, you have to add the object multiple times to the bench array in the order the object is encountered by the rays. For example, double refraction/reflection for cylindrical and conical surfaces can be calculated by adding the surface twice to the bench.

The library is very compact and fast. It was written using Matlab classes and is fully vectorized. It takes about 2 seconds to trace 100,000 rays through an external lens and the human eye (8 optical surfaces) on a 3 GHz Intel Core i7 desktop. Fresnel lens tracing is somewhat slower due to looping through the Fresnel cones describing the lens surface. Tracing through user-defined (general) surfaces is significantly slower due to iterative search of ray intersections with the surface.

Thank you for downloading Optometrika, enjoy it!

————————————————————
List of examples:

example1.m: tests the basic functionality of the Optometrika library
example2.m: demonstrates the Optometrika's optical model of the human eye
example3.m: demonstrates accommodation of the human eye by minimizing the retinal image
example4.m: tests a ring lens with the cosine surface profile defined in coslens.m
example5.m: tests planar mirrors
example6.m: tests planar and parabolic mirrors (a Newtonian refractor telescope)
example7.m: tests a Fresnel lens
example8.m: tests a lens with polynomial aspheric terms
example9.m: tests cone mirrors
example10.m: tests cylinder and cone surfaces with double refraction
example11.m: demonstrates ray tracing for rays originating inside the human eye
example12.m: draws a lens and determines its front surface, back surface, and total height. Makes an animated gif of the lens and an engineering drawing of the lens.
example13.m: tests refraction through the lens edge and backward rays refraction (sub-aperture Maksutov-Cassegrain telescope)
example14.m: tests refraction through a lens with astigmatism (different vertical and horizontal radii of curvature)
example15.m: simulates a hexagonal array of spherical micro lenses
example16.m: demonstrates STL export of various lenses

Cite As

Yury (2024). Optometrika (https://github.com/caiuspetronius/Optometrika), GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2018b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired by: hist2

Inspired: asphere parameters

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Versions that use the GitHub default branch cannot be downloaded

Version Published Release Notes
2.3.2.0

Fixed a bug in Aperture.m incorrectly displaying rectangular aperture orientation on the bench

2.3.1.0

Fixed a bug preventing displaying a point image on a screen

2.3.0.0

Bug fixing

2.2.0.0

Fixed incorrect surface normals calculation for surfaces with polynomial terms, added inner diameter (a hole) to the Plane surface , extended export_stl() to Plane surfaces.

2.1.0.0

Fixed a bug affecting backward propagating rays interacting with hyperbolic surfaces.

2.0.0.0

Maintained as a GitHub repository now.

1.31.0.0

Changed export_stl() function to work correctly with the stlwrite() function bulid into Matlab 2018b.

1.30.0.0

Updated the export_stl() function to export GeneralLens class surfaces.

1.29.0.0

Added export_stl() function for lens surface export in STL format. See example16.
Various bug fixes

1.28.0.0

Various bug fixes

1.27.0.0

Added several new materials
Fixed several bugs, including the one preventing the library working on pre-2016 Matlab versions

1.26.0.0

Added STL and DXF export of a lens's 3D shape and 2D profile respectively to the draw_lens_engineering() function. Install stlwrite() and DXFLib to use this functionality.

1.25.0.0

Minor bug fixes.

1.24.0.0

Added engineering drawing of Fresnel lenses to draw_lens_engineering(). See example7 for an example.
Fixed a bug in Fresnel surface rotation.

1.23.0.0

Added rectangular apertures. See example4.
Fixed various bugs in the FresnelLens implementation

1.22.0.0

Implemented astigmatic lens surfaces: use a 2x1 vector for the radius of curvature (see example14).
Implemented elliptical cone/cylinder surfaces: use a 2x1 vector for the cone/cylinder diameter (see example10).
Various bug fixes

1.21.0.0

Implemented ray tracing for backward-propagating rays (example13)
Various bug fixes

1.20.0.0

Bug fixes

1.19.0.0

Added flange option to the draw_lens_engineering() function.

1.18.0.0

Various bug fixes.

1.17.0.0

Added draw_lens_engineering() function to automatically generate engineering drawing for lens manufacturers. Currently only lenses without holes are implemented. See example12 for a demo.

1.16.0.0

Example12 illustrates the use of lens_dims() function to draw a lens (full surface) and calculate its sags and volume.
Various bug fixes.

1.15.0.0

For a new way to display rays, see example11.
Added density information for many materials in refrindx.m. Use lens_dims() function to get lens volume.
Example11 demonstrates tracing from inside the human eye.
Various bug fixes.

1.14.0.0

Total internal reflection enabled. Various bug fixes related to multiple refraction/reflexion.

1.13.0.0

Added cylindrical surfaces, including double refraction on such surfaces (example 10). Fixed some bugs.

1.12.0.0

Added a cone-shaped surface ConeLens()
Added ring-aperture option for all surfaces except the FresnelLens.
Rays missing optical elements are not discarded any more but traced to the next element.
General bug fixes

1.11.0.0

Added AsphericLens class describing strongly aspheric surfaces (conic + even polynomial terms, example8).
Added a fast focal_point() function looking for the bundle's focal point without iterations (example1).

1.10.0.0

Added a Fresnel lens implementation. Added operations on a bench, such as bench rotation, element prepending and removal.

1.9.0.0

Replaced the missing Bench.m file.

1.8.0.0

Various bug fixes and improvements. Spheroidal screens are implemented now by the Retina object.

1.7.0.0

Some bug fixes and improvements, added spheroidal screens implemented by the Retina class.

1.6.0.0

Added basic documentation to the classes.

1.5.0.0

Added: (i) appending ray bundles to an existing bundle, (ii) mirror elements (general, conic, planar). To specify a surface as a mirror use 'mirror' glass specifier (see example5.m and example6.m).

1.4.0.0

Small bug fixes.

1.3.0.0

Added tracing through general (user-defined) surfaces (see example4.m).

1.2.0.0

Fixed a bug affecting ray tracing through strongly hyperbolic surfaces.

1.1.0.0

Fixed a bug which affected ray tracing through extremely hyperbolic surfaces.

1.0.0.0

To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.