This is a GUI application where the user enters a system consisting of lenses, mirrors and light sources and the program calculates and shows how each ray goes through the system.
Program supports ideal and circle lens, flat and ideal curved mirror and a light blocker.
As a light source, you can use a single ray, a beam of parallel rays or a point source, which shoots rays in all directions.
- Download the program from releases and unzip it.
- Make sure you have
Java
installed - Start the program by either double clicking on
OpticsSimulator-1.0-SNAPSHOT.jar
or callingjava -jar OpticsSimulator-1.0-SNAPSHOT.jar
if using CLI.
You open a dropdown by hovering your mouse over it. After that, you choose the requested action by moving your mouse to the relevant button and pressing the left mouse button.
You press a button by hovering your mouse over it and pressing the left mouse button.
You move a slider by:
- Either hovering over the "slider button", pressing the left mouse button, moving the "slider button" to requested position and releasing the left mouse button.
- Or hovering over the position you want the slider to be at and pressing the left mouse button.
All of the UI elements are located at the top of the screen. There are four dropdowns (File
, Light Sources
, Mirrors
and Lens
), three buttons (Blocker
, Move
and Delete
) and one or two sliders (Ray density slider
and Refractive index
or Focus distance
slider).
Each of the dropdowns contains several buttons:
File
-Reset
button (remove everything that has been created, resets zoom and screen position and sets action toMove
)Light sources
-Ray
,Beam
andPoint source
(setAction
to creatingRay
/Beam
/Point source
)Mirrors
-Flat
andIdeal curved
(setAction
to creating aFlat
/Ideal curved
mirror)Lens
-Circle
andIdeal
(setAction
to creating aCircle
/Ideal
lens)
Buttons:
Blocker
- setsAction
to creating aBlocker
(used to block light rays)Move
- setsAction
toMove
(used to move the view)Delete
- setsAction
toDelete
(used to delete specific objects)
Sliders:
Ray density slider
- controls the density of rays coming out fromBeam
andPoint source
light sources. Moving to the right increases density.Refractive index
/Focus distance
slider - control the refractive index or focus distance of the active object (will be shown only if the active object has these settings)
Current action is shown in the label right under File
dropdown (Action: <current-action>
).
For all of the following actions aside from Delete
, you need to hover your mouse in some free space (not on UI or the red circles).
Ray
,Beam
,Flat
,Ideal curved
,Circle
,Ideal
,Blocker
: location of these objects is specified by two points - to create this object, hover your mouse over the place on screen where you want the first point to be, then press the left mouse button and drag you mouse to the second location where you release it.Point source
: location of point source is specified by one point only - to create the point source, hover your mouse over the place on screen where you want it to be and press the left mouse button.Move
: move the view by pressing the left mouse button, moving your mouse and releasing.Delete
: delete some object by hovering your mouse over one of its red circles and pressing the left mouse button.
You can use both of the following controls in any Action
state aside from Delete
.
- Moving the objects: move a point of a certain object by hovering your mouse over one of its red circles, pressing the left mouse button, moving it to a new location and releasing the left mouse button.
- Changing refractive index/focus distance of an object: select an object by clicking on one of its points (red circles). If the object has additional settings (refractive index or focus distance), new slider will be created for these settings (as shown on picture below). You can set the new value using the slider. The current value is shown under the slider with a label
Value:
There is also zoom
- hover your mouse over the location on the screen where you want to zoom and use mouse wheel to zoom in or out.
Image is showing a state, with Beam
and Point source
as lights sources. Rays from the Beam
go through a Circle
(which is also an active object as you can see from the Refractive index
slider). Rays from the Point source
are partially blocked by a Blocker
. Current action is to create a Blocker
.
Program (OpticsSimulator-1.0-SNAPSHOT.jar
) requires a Processing 3 library to be provided in path lib/core-3.3.7.jar
relative to the program as this path is hardcoded in the .jar
manifest. A copy of this library is provided.
Two Circle glass objects should not overlap, otherwise the resulting simulation won't be correct!
- Processing 3 - the graphical library used in this project
- line-line intersection
- line-circle intersection
- ideal lens equation
- Snell's law
Toto je zápočtový program vytvořený Jakubem Medkem během letního semestru 2018/19 I. ročníku IOI MFF UK pro předmět Programování II (NPRG031).