Home | Java |     Share This Page
  OpticalRayTracer

A completely rewritten virtual lens/mirror design workshop

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

Current Version: 6.1 (10.22.2014)

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

The Applet

OpticalRayTracer once functioned perfectly from within a Web page (and on this page), but it seems Java 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

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 2014, 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 a 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 a more in-depth technical discussion of the methods used in OpticalRayTracer.
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.

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

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
  • 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 |     Share This Page