Home | Java |     Share This Page

A virtual lens design workshop.

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

Current Version: 3.3 (11-25-2013)

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

The Applet

Sorry — OpticalRayTracer once functioned perfectly from within a Web page, but it seems Java applets can no longer be trusted. Here's an image of OpticalRayTracer in operation. You need to download OpticalRayTracer and run it as an application (details below).

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. It uses optical principles and a virtual optical bench to predict the behavior of many kinds of ordinary and exotic lens types. OpticalRayTracer includes an advanced, easy-to-use interface that allows the user to rearrange the optical configuration by simply dragging lenses around using the mouse.

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

Educators take note: OpticalRayTracer has significant educational potential in the teaching of basic optical principles, and it 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 2011, 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).
  • OpticalRayTracer includes a user-oriented help file with substantial technical depth (click help above).
  • Click here for a more thorough technical discussion of the methods used in OpticalRayTracer.
  • Click here for the OpticalRayTracer AppData file.

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 Netbeans.


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 can only function becuase it makes some assumptions about the modeled optical system, including the idea that the progression of intersection events flows from left to right (no light rays bouncing back toward the left) and no cases 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's a limited number of lens types and curvatures that the program can model.

Based on the above, please do not submit program bug reports based on pathological lens designs. Thank you.


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
  • 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