Java-based Hologram Formula Calculator
This project consists of a Java-based hologram formula calculator,
using the grating equation (sine-theta equation) and the 1/R equation.
The following list of variables can be selected for recalculation
based on the rest of the variables. Adjusting any value in the
display, except the ones being recalculated, will cause the
beams to change based on the new settings. Changes in the dependent
variable in the equation will be ignored and readjusted when the
"recalculate" button is clicked.
The left hand (blue) window shows the construction phase of
building a hologram.
Here, you can position the object beam and the reference
beam, as well as change the reference beam's wavelength. The
right hand (red) window shows the playback phase. Here, you
can position the illumnation beam and the virtual image
beam, as well as change the illumnation beam's wavelength. The
two equations used to calculate the values are:
- Reference beam position
- Object beam position
- Illumination beam position
- Virtual image position
The display will automatically update when a recalculation is
performed by pressing the "recalculate" button. Enhancements since the
demo include the removal of the restriction on theta for all beams -
any beam can now exist at any angle - and the addition of beam labels
on the display, identifying each beam and giving its x and y
coordinates in screen space. For angles, the x axis is 0, negative is
above the x axis, and positive is below the x axis. For R's, positive
is in the initial quadrant of the angle, negative in the diagonally
opposite. Clicking on the "reset" button will reset the values to
- Netscape may not draw the display correctly the first time - clicking
the "recalculate" or "reset" button should fix this.
- I'm not sure how to adjust the fonts based on applet size, so in a
smaller window, you might not see the entire label for each box. It
works correctly on larger displays.
- This version is currently under development. I'm working on adding
drag 'n' drop of the beams, so please don't click in the windows that
display the beams - it doesn't work yet. Doing so will cause the
display to change erratically, but not the values in the boxes. If you
inadvertently do this, hitting "recalculate" will fix it.
- Two panes: I chose to display the construction and playback
scenarios in different panes to emphasize that they are two separate
phases. While the ideal situation would be to give the user a choice
(isn't it always?), it would have added another complexity to an
already difficult task.
- R/Theta vs. X/Z: I personally find the R/Theta system more
intuitive for thinking about beams. Additionally, there is already a
lot of information at the bottom, and adding another set of boxes
would have made it more cluttered. I preferred to leave as much of the
screen as possible for the actual drawings. However, each beam does
have a label which displays its screen coordinates, and when I
implement the drag and drop, it will use those coordinates.
- Java vs. X (the variable, not the window system): I chose
to do this project in Java for many reasons. It gave me a chance to
learn a new language, which I'm always happy to do (it's been a
productive semester - I learned Perl too!). It also makes the project
easily accessible to others, as it's the only web-based programming
language around. I'm a bit (okay, a lot) of an exhibitionist when it
comes to my work, so this was a natural choice. The object oriented
nature of Java lends itself well to this sort of problem solving,
though I defeated the purpose MANY times in my blundering through. It
could have been much more concise, and next time, it will be.
- Text-based vs. drag 'n' drop: There are two reasons why I
left out the drag 'n' drop aspect. 1) It was too hard. I started to do
it, couldn't get it to work, and ditched it. 2) In addition to
capturing the events necessary to get it to work, it would involve a
lot of conversion between integers (which the graphics aspect uses)
and doubles (which the calculator itself uses). Since I didn't
implement the whole thing in the right way, doing this conversion
would be difficult. When I finally do get around to it, it will
involve restructuring the whole thing so that the methods contained in
the objects themselves will take care of the math problems.
I'm very happy with the way this project turned out. As a newcomer to
OOP, Event-driven UI's, and Java itself, I'm pleased with the results.
If I were to start again, I probably would have designed it
differently, given what I now know about Java. However, it works.
Enhancements that I will eventually get to are futher error checking,
drag 'n' drop of the beams themselves, a more customizable UI, and
more dimensions. If nothing
else, it's certainly made it easier to visualize the effects of
changing the variables in a holo-system.
* Click here for 640
x 480 displays.
* Click here for 800
x 600 displays.
* Click here for 1024
x 768 displays.
* Click here for source code.
Send mail to Adam