Home | Java | OpticalRayTracer |     Share This Page

A completely rewritten virtual lens/mirror design workshop

Copyright © 2017, P. Lutus. All Rights Reserved.

Current Version: 9.6 (05.12.2017)

Overview | The Details | Documentation | Downloads | Notes | Version History

Reader Feedback and discussions

Overview

OpticalRayTracer is a powerful, Java-based virtual optical bench. It once functioned perfectly from within a Web page (and on this page) as a Java applet, but it seems applets can no longer be trusted. Here's an image of OpticalRayTracer in operation. Please download OpticalRayTracer and run it as an application (details below).

Click image for more views

Note: Be sure also to see the new Snell's Law Calculator, an online analysis tool.

The Details
  • What it is: A sophisticated, cross-platform virtual optical bench.
  • Written in: Java.
  • Works with: Windows, Linux, Macintosh, etc.

OpticalRayTracer is a free (GPL) cross-platform application that analyzes systems of lenses and mirrors. It uses optical principles and a virtual optical bench to predict the behavior of many kinds of ordinary and exotic lens types as well as flat and curved mirrors. OpticalRayTracer includes an advanced, easy-to-use interface that allows the user to rearrange the optical configuration by dragging objects around using the mouse.

OpticalRayTracer fully analyzes lens optical properties, incuding refraction and dispersion. The dispersion display uses color-coded light beams to simplify interpretation of the results.

Recent OpticalRayTracer versions allow the creation of mirrors, flat and curved. In modern optical designs, mirrors often produce better results than lenses, for example in astronomical instruments. Such instruments can be roughed out in OpticalRayTracer's virtual workbench.

Educators take note: OpticalRayTracer has significant educational potential in the teaching of basic optical principles, and has some entertaining and game-like behaviors to hold the student's attention.

OpticalRayTracer includes a detailed tutorial/help file to assist the user in getting started in this interesting activity, and this online documentation is also available.

OpticalRayTracer is © Copyright 2017, P. Lutus. All rights reserved.
OpticalRayTracer is released under the General Public License.
OpticalRayTracer is also Careware (http://arachnoid.com/careware),
unless this kind of idea makes you crazy, in which case OpticalRayTracer is free (e.g. GPL).
Documentation
  • OpticalRayTracer includes an extensive help file with technical details and some usage examples.
  • Click here to see a local copy of the OpticalRayTracer application's built-in help file.
  • Click here for an in-depth technical discussion of the methods used in OpticalRayTracer and the underlying mathematics.
  • Click here for an older technical discussion.
Downloads

OpticalRayTracer is a Java application, so it requires a Java runtime engine in order to run. Click this link to pick up your free Java runtime. And for several excellent reasons, be sure to install the most recent Java version available for your platform.

There are three download packages:

For the Windows download, install it as an ordinary application, but remember you need a free Java runtime engine, available here.

For the cross-platform Java JAR file, place the executable in any convenient location and run it with this invocation, usually placed in a shell script:

java -jar (path)/OpticalRayTracer.jar

For the source archive, licensed under the GPL, unpack it in the usual way and make sure you have an up-to-date copy of Eclipse.

Notes

Snap-To-Grid Feature

I've gotten a few bug reports submitted by users who couldn't set reliable non-integer X and Y position values. Typically, after they switched their attention to a different optical component, the lens they just positioned jumped to a new location they didn't intend. This is a function called "Snap-To-Grid" and it's a feature, not a bug. To control it, choose the "Configure" tab and change the value in the "Snap-To-Grid Value" entry.

An entry of zero disables the feature and allows the user to set any arbitrary X and Y position values, to any number of decimal places — this is most useful when entering numerical component positions rather than positioning a component using a pointing device. A smaller entry than the default of 0.5 snaps to a smaller increment.

Bug Reports

I've gotten any number of bug reports from users who entered a pathological lens description, saw something strange, then reported that a bug in OpticalRayTracer prevented a successful model — for example light rays were flying all over the place, with no connection to physical reality. My reply is that OpticalRayTracer has some limits to the degree to which it can model reality. There are many possible optical configurations where Snell's Law calculations overflow the dynamic range of an ‎IEEE 754 double-precision floating-point variable, which unfortunately is a relatively common occurrence. Consequently, and because of the complexity of the calculations performed by OpticalRayTracer, there is a limited number of lens types and curvatures the program can model.

Based on the above, please do not submit program bug reports simply based on a complex optical design. Thank you.

History

OpticalRayTracer was originally written in C++ for speed, but several things happened to force a reëvaluation and rewrite in Java. One is that Windows users couldn't use the program. Another is that I spent a fantastic amount of time dealing with inquiries that looked more or less like this:

I saw mention of this package in the context of debian, and tried building it on my Debian Etch system.
After installing some required dependencies, it suggested that all was ok to run make.
The result was as below. My understanding is that aclocal/automake/autoconf should not
be required for a 'tarball install' ? I did a clean configure, then ran aclocal,
then a make/make-install seemed to work fine. I think this means that aclocal needs
to be run before the tarball is released?

===============================
$ make
cd . && /bin/bash /home/neil/raytracer/admin/missing --run aclocal-1.6 
/home/neil/raytracer/admin/missing: line 46: aclocal-1.6: command not found
WARNING: `aclocal-1.6' is missing on your system.  You should only need it if
         you modified `acinclude.m4' or `configure.in'.  You might want
         to install the `Automake' and `Perl' packages.  Grab them from
         any GNU archive site.
            

This sort of exchange became more frequent as the years went by. Then Trolltech, the maintainers of the GUI package I had foolishly decided to use (Qt), unceremoniously abandoned and replaced it, without any effort to assure compatibility or interoperability between the old and new versions. Essentially Trolltech required that everyone stop whatever they were doing, sit down and write all their applications over again, in order to keep them operational.

Java has a number of drawbacks of its own, but it works on any platform, and its graphical interface (Swing) is relatively stable. Over time I find myself rewriting more applications in Java just because I don't have to deal with people's installation difficulties, which frees me to write new computer programs instead of struggling with the old ones.

Because of what OpticalRayTracer does, I was concerned that under Java it wouldn't be fast enough to deal with the computation workload. But this turns out not to be an issue, and the mature Java interface allowed me to add a number of things that were not practical in the earlier versions.

As is true of most of my recent programs, OpticalRayTracer remembers absolutely everything between uses, and the user can even copy to the clipboard a plain-text snapshot of the program's complete state for transmission to a friend or to archive for future reference.

This version of OpticalRayTracer is in every way superior to the old. It runs in more places, it is designed better, it completes some details that were left unfinished in the old version, and it has a much better way to import and export lens descriptions and program state.

Version History
  • 05.12.2017 Version 9.6. Updated the bundled help document to emphasize the presence of the program's right-click context menu that includes many important control functions.
  • 03.23.2017 Version 9.5. Fixed some cross-platform configuration file read/write issues (configurations can now be seamlessly transferred between platforms).
  • 11.18.2016 Version 9.4. Changed Windows launch procedure after discovering that Microsoft has abandoned support for Java.
  • 09.20.2016 Version 9.3. Fixed a serious bug that would freeze the application if the same number were entered for both "X Source Plane" and "X Beam Rotation Plane". Now, instead of freezing, the application rings a bell and waits for the human to sort it out.
  • 07.24.2015 Version 9.2. Fixed a subtle bug that prevented timely optical component updates after certain program parameters were changed, added a reset button that resets only program values, not optical components.
  • 05.16.2015 Version 9.1. By user request, added a simple command-line interface to support test automation methods.
  • 05.07.2015 Version 9.0. Trapped an on-axis overflow error condition in the planar curvature class.
  • 02.05.2015 Version 8.9. Changed the control layout, revised the help file for greater clarity, added a graphic image that shows how a lens is defined by overlapping spheres.
  • 02.05.2015 Version 8.8. Recoded the management of the planar curvature class, added element center thickness to the configuration class (meaning it's now included in clipboard data and the initialization file), edited the help file to reflect recent changes and to simplify the dispersion experiment.
  • 02.04.2015 Version 8.7. Added a display of element-center thickness, corrected an inconsistency in how element edge thickness was specified.
  • 01.31.2015 Version 8.6. Cleaned up on-axis solution code, solely to avoid ugly code, no change in behavior.
  • 01.26.2015 Version 8.5. Made further changes to address more on-axis edge cases.
  • 01.21.2015 Version 8.4. Coded a more efficient on-axis overflow method, tuned for each element class. Added "Common Problems" section to help file.
  • 01.20.2015 Version 8.3. Fixed a bug in the parabolic curvature class that created a non-physical on-axis deflection caused by floating-point overflow.
  • 12.12.2014 Version 8.2. Added a planar curvature class to avoid problems associated with using large spherical radii to imitate planar surfaces.
  • 11.12.2014 Version 8.1. Fixed a bug in the spherical lens model that failed to detect a small subset of ray-surface intersections, changed how minimum lens thickness is computed to prevent an optical problem, updated the help file content.
  • 11.11.2014 Version 8.0. Recoded much of the basic ray tracing engine to use vectors instead of scalars, with a big improvement in stability and accuracy. A number of difficult edge cases are solved by this change.
  • 11.11.2014 Version 7.9. Finally sorted out the Snell's Law lens refraction computation issues. OpticalRaytracer's refraction results are now as precise as entered lens data allow.
  • 11.07.2014 Version 7.8. Revised the Snell's Law code block to make displayed results more closely approximate exact Snell's Law computations. The Snell's Law computations are still approximate, but the outcomes are now closer to reality.
  • 11.06.2014 Version 7.7. Fixed a subtle error in how a certain kind of multiple lens refraction is tallied — how multiple transitions into and out of a single medium's acute surface are computed.
  • 11.04.2014 Version 7.6. Fixed a number of uncovered and reported bugs, made a few minor improvements, changed the lens surface detection method.
  • 11.03.2014 Version 7.5. Fixed a number of reported bugs having to do with edge cases in the behavior of lenses, refactored the control manager class for better comprehensibility.
  • 11.02.2014 Version 7.4. Added parabolic curvature to the supported lens/mirror curvature types, changed the user interface, cleaned up and refactored much of the code structure to address the much larger code base recently created.
  • 10.31.2014 Version 7.3. Recoded the spherical and hyperbolic generators for more shared structure and code, improved the Python/SymPy function generators to make future changes easier.
  • 10.30.2014 Version 7.2. Replaced the spherical model algorithm with one that's more efficient and that shares some mathematical and technical aspects in common with the hyperbolic model. Resolved a reported locale issue.
  • 10.29.2014 Version 7.1. Improved the algorithms responsible for managing surfaces to avoid some annoying and unphysical edge-case behaviors.
  • 10.28.2014 Version 7.0. Fixed a bug related to parabolic curves and mirrors, fixed another that prevented correct operation at user-entered angles that were multiples of 90 degrees, changed to a more robust hyperbolic generation scheme.
  • 10.28.2014 Version 6.9. Solved some technical issues with rotating reflecting surfaces, explored the approximate parabolic curve option accessible by very large number entries to the hyperbolic curvature control.
  • 10.27.2014 Version 6.8. Created a scheme to prevent the sides of lenses from crossing over, which can be very confusing as well as unphysical. Fixed a serious bug in how reflections were calculated.
  • 10.27.2014 Version 6.7. Fixed a bug that prevented creation of concave hyperbolic lenses.
  • 10.26.2014 Version 6.6. Refactored the hyperbolic model for greater accuracy and efficiency, added fields to data table, added the ability to copy individual table lines to system clipboard, cleaned up small bugs in other areas.
  • 10.24.2014 Version 6.5. Recoded the spectral dispersion algorithm to agree more closely with the underlying physics.
  • 10.24.2014 Version 6.4. Improved table formatting for both the internal and HTML exported tables, changed the table data format and layout.
  • 10.24.2014 Version 6.3. Replaced the HTML table display with one based on a Swing table component for much better update speed.
  • 10.23.2014 Version 6.2. Replaced intersection dots with arrows, which tell the user the direction the beam is heading. Reworked the dispersion computation to better reflect the underlying physics. Fixed a number of bugs that came up in testing.
  • 10.22.2014 Version 6.1. Fixed a regression/bug, introduced in recent major code changes, that prevented creation of concave lenses.
  • 10.22.2014 Version 6.0. Optimized a critical part of the hyperbolic model code, fixed a bug that affected treatment of a lens that's half spherical and half hyperbolic.
  • 10.21.2014 Version 5.9. Replaced the hyperbolic lens model with a much better one, easier to explain technically, and the hyperbolics can now be translated and rotated into any position. Refactored much of the code base for greater clarity and efficiency.
  • 10.18.2014 Version 5.8. Added a few more controls, arranged for a child help window to be cloneable/detachable from the main app window for more convenient interactive browsing.
  • 10.18.2014 Version 5.7. Implemented keyboard controls so users without pointing devices can use the program. Using a mouse or other pointing device is much easier, but using only a keyboard is now possible.
  • 10.17.2014 Version 5.6. Fixed two issues, one having to do with the location of lenses and mirrors created from the context menu, the other having to do with the behavior of the hyperbolic lens profile algorithm.
  • 10.17.2014 Version 5.5. Fixed a number of small bugs, changed how optical objects are named to assure that new and copied objects have an automatically assigned unique name.
  • 10.17.2014 Version 5.4. Changed the virtual space configuration to eliminate a barrier that no longer served a purpose, changed configuration controls, cleaned up some minor issues.
  • 10.16.2014 Version 5.3. Fixed some Windows-related and locale-related issues, added a tab that displays a table of ray trace data, solved a keyboard function problem, made a number of other improvements.
  • 10.16.2014 Version 5.2. Fixed an issue with the new proximity detector, added an input for surface epsilon to allow users to fine-tune the ray tracer's response for special applications, added surface normal angle to the ray data table and dialog.
  • 10.15.2014 Version 5.1. Replaced the lens proximity detector algorithm, responsible for deciding whether a light beam has intersected with a lens. The new method is much improved.
  • 10.14.2014 Version 5.0. Added absorbers (optical components that stop light rays) and a text naming feature for each optical component.
  • 10.14.2014 Version 4.9. Changed the dispersion beam alpha value to reflect that of the default tracing beam alpha, edited the help file, made a number of other small changes.
  • 10.13.2014 Version 4.8. Solved a cross-platform plain-text format compatibility issue that came up when trying to share lens descriptions between Linux and Windows.
  • 10.13.2014 Version 4.7. Restored a documentation example that shows how to correct chromatic aberration, and changed how the image-to-clipboard function works — the new version preserves the aspect ratio of the original display while keeping a uniform width.
  • 10.13.2014 Version 4.6. Enabled alpha (transparency) setting for system color selections, fixed an inconsistency in the undo/redo system.
  • 10.11.2014 Version 4.5. Replaced my original circle-line intersection algorithm with a faster, more efficient one.
  • 10.10.2014 Version 4.4. Fixed a bug in the ray generating algorithm that prevented generating just one ray and that sometimes failed to generate the specified number of rays.
  • 10.09.2014 Version 4.3. Added line information features. Users can export a CSV-formatted table of information about all generated lines to the system clipboard, and can get details about a particular line by double-clicking the display near the line of interest.
  • 10.09.2014 Version 4.2. Recoded the ray tracing logic to make lenses symmetrical, so that light can pass through in both directions.
  • 10.08.2014 Version 4.1. Fixed a bug that prevented correct mathematical handling of off-axis lenses in some circumstances.
  • 10.07.2014 Version 4.0. The version number jump results from a complete rewrite and change of development environment (i.e. from Netbeans to Eclipse). The new version has many new features and abilities — mirrors as well as lenses, off-axis light paths, improved import and export options, better user interface and controls, and many smaller improvements.
  • 11.25.2013 Version 3.3. Fixed a bug that would freeze the appplication if the source Y start and end values were equal.
  • 04.02.2011 Version 3.2. At the suggestion of a user, added an option to rotate light beams with respect to the X origin rather than the X target plane, increased the beam rotation rate of change when adjusted using the mouse wheel, fixed additional small bugs.
  • 03.29.2011 Version 3.1. Fixed a library issue caused by combining the application/applet versions of this program into one JAR file.
  • 02.27.2011 Version 3.0. Rewrote this program so it can be run as a Java applet as well as an application — there is now a "live" running copy of OpticalRayTracer at the top of this page.
  • 02.26.2011 Version 2.9. Fixed some small annoying bugs, updated help file.
  • 01.15.2010 Version 2.8. Fixed a bug that made lenses twice as thick as the user specified.
  • 10.23.2009 Version 2.7. Replaced string-based keyboard identifiers with keycodes for the benefit of non-English users.
  • 09.07.2009 Version 2.6. Fixed a clipboard copy/paste bug that affected only Windows users.
  • 04.11.2009 Version 2.5. Fixed a number of annoying small bugs that cropped up in connection with recent changes.
  • 04.10.2009 Version 2.4. Fixed a subtle bug that prevented correct tracing through very large lenses having slight curvature. For this particular activity users may want to delete the user configuration file located at (user directory)/.OpticalRayTracer/OpticalRayTracer.ini to permit lenses with thinner edges and/or centers.
  • 03.31.2009 Version 2.3. Fixed a bug brought on by the new locale-processing code.
  • 03.29.2009 Version 2.2. Recoded this application to make it locale-immune.
  • 03.20.2009 Version 2.1. Added some scaling options to the mouse/keyboard gesture recognizer.
  • 03.19.2009 Version 2.0. After years of dealing with essentially insoluble C++ installation issues, gave up and completely rewrote OpticalRayTracer in Java. The new version is better than the old in every way, and it is platform-portable.
  • 09.11.2008 Version 1.2. Updated source to allow compilation on 64-bit systems and with newer compilers.
  • 09.14.2006 Version 1.1. Updated source to conform to gcc 4.1 requirements.
  • 11.10.2004 Version 1.0. Initial public release.
 

Home | Java | OpticalRayTracer |     Share This Page