@physletName|OpticsApplet
@code|optics.OpticsApplet.class
@archive|Optics4_.jar,STools4.jar
@appletSize|400|300
@embedParam|b|showControls|false|show controls:
@embedParam|i|PixPerUnit|100|The pixels per unit along the x axis:
addObject|arrID
#FFDA92
>>> tt >>>
Insert a new arrow with three principle rays. The arrow head is at coordinates (x,y).
Note: These arrows have to be located on the left hand side of lenses etc.
>>> tt >>>
Add arrow
s|name|source|HIDDEN
$
.|d|x|0.3|x:
.|d|y|0.5|y:
addObject|pntID
#FFDA92
>>> tt >>>
Insert a new point source with a fan of rays starting at coordinates (x,y). If you want to display n rays set the slope increment to 1/(n-1)
>>> tt >>>
Add point
s|name|source|HIDDEN
$
.|f|flag|point|HIDDEN
.|d|x|0.6|x:
.|d|y|0.2|y:
.|d|inc||number of rays, enter 1/n-1:
addObject|bmID
#FFDA92
>>> tt >>>
Insert a new beam of parallel rays, starting at (x,y). For an inclination angle alpha enter slope tan(alpha)
>>> tt >>>
Add beam
s|name|source|HIDDEN
$
.|f|flag|infinite|HIDDEN
.|d|x|1.0|x:
.|d|y|0.5|y:
.|i|s||beam size in pixels:
.|d|slope||slope, enter tan(alpha):
addObject|lensID
#FFDA92
>>> tt >>>
Insert a new lens with focal length f at position x.
The graphics are only symbolic: The calculation takes place at the middle line according to the Gaussian matrix formalism.
To make the foci visible make the lens resizable and tell the students to click at it.
>>> tt >>>
Add lens
s|name|lens|HIDDEN
$
.|d|x|2.0|x:
.|d|f|1|focal length:
addObject|mirID
#FFDA92
>>> tt >>>
Insert a new mirror with focal length f at position x.
The graphics are only symbolic: The calculation takes place at the middle line according to the Gaussian matrix formalism. You can choose another algorithm that features spherical aberrations.
>>> tt >>>
Add mirror
s|name|mirror|HIDDEN
$
.|d|x|3|x:
.|d|f|1|focal length:
.|f|flag|;spherical|choose \"spherical\" to show aberrations:
addObject|aperID
#FFDA92
>>> tt >>>
Insert a new aperture that restricts the propagation of the light rays at position x
>>> tt >>>
Add aperture
s|name|aperture|HIDDEN
$
.|d|x|1.0|x:
.|d|opening|0.2|Opening (as fraction 0-1):
addObject|screenID
#FFDA92
>>> tt >>>
Insert a new screen that stops the propagation of light rays at position x
>>> tt >>>
Add screen
s|name|screen|HIDDEN
$
.|d|x|1.0|x:
addObject|idxChgID
#FFDA92
>>> tt >>>
Insert a vertical split into two regions with different index of refraction.
dn specifies the change of the index of refraction from the left to the right at position x)
Choose algorithm \"dielectric\" for a refraction according to Snell's law or
algorithm \"refraction\" for a small angle approximation.
The separation line of the regions can be curved with radius r.
>>> tt >>>
Add index
s|flag|dielectric;refraction|algorithm:
$
.|d|x|2.5|x:
.|d|dn|0.4|index changes by dn:
.|d|r||curvature r:
addObject|mtrxID
#FFDA92
>>> tt >>>
Insert a new customised optical element by specifying its transformation matrix.
Express the height and the angle of an outgoing ray as a function of the height h and angle a of the incoming ray.
For example:
height=\"h+0.2\"
angle=\"a\"
will shift any beam by 0.2 units
>>> tt >>>
Add matrix
s|name|matrix|HIDDEN
$
.|d|x|1.0|x:
.|s|height||. Enter functions of height h and angle a of the incoming ray:
-> outgoing ray: height:
.|s|angle||angle:
addObject|shpID
#FFDA92
>>> tt >>>
Geometric shapes without physical interaction.
Note: Shapes are invisibly black. You can use their ID to change their color with an appropriate command (see list).
>>> tt >>>
Add shape
s|flag|rectangle;box;circle;shell|shape:
$
.|d|x|1.0|x:
.|d|y|0.5|y:
.|i|w||width:
.|i|h||heigth:
.|i|r||radius:
.|i|s||border (n/a):
addObject|txtID
#FFDA92
>>> tt >>>
Insert a new text string at coordinates (x,y)
Use \"Follow this\" to make this text follow an object if you drag it
A function of the object's parameter can be printed after the static text.
>>> tt >>>
Add text
s|name|text|HIDDEN
$
.|d|x|1.0|At position x:
.|d|y|-0.5|y:
.|s|text|your text|
display text:
.|s|calc||and/or calculate this function:
addObject|imgID
#FFDA92
>>> tt >>>
Insert a new image (gif/jpg/png) with upper left corner at (x,y)Specify the path to the image file relative to the directory with the jar-archives (e.g. \"classes\")
For instance, if there's a directory \"images\" in directory \"classes\" the path should read \"images/xy.gif\".
If images and classes were subdirectories on the same level, it is: \"../images/xy.gif\"
Use \"Display offset\" to shift the image display.
>>> tt >>>
Add image
s|name|image|HIDDEN
$
.|d|x|3.0|At position x:
.|d|y|0.5|y:
.|s|file|smile.gif|display image:
clearAll|
#FF707D
>>> tt >>>
Clear all elements from bench during runtime. Use this for example if you work with different set-ups.
Since addObject always creates new objects on top of each other, you can delete all objects before inserting new ones.
>>> tt >>>
Clear all
n|||Remove all objects adding new ones (during runtime only, see (i))
deleteObject|
#FF707D
>>> tt >>>
Delete a single object during runtime - for instance if a student presses a button.
THIS IS NOT MEANT for during your work with this scriptor: Right now, you can simply delete script lines below and click \"Update\"!
>>> tt >>>
Delete object
o|id||Delete this object during runtime (see (i)):
setDragable|
#FFFF99
>>> tt >>>
Make a single object dragable with the mouse. Enter as ID the variable that precedes the addObject command which created the object in question.
>>> tt >>>
Dragable this
o|id||This object:
b|drag|true|will be dragable:
setResizable|
#FFFF99
>>> tt >>>
Make a single object resizable with the mouse. For example, a resizable lens will display its focal length
Note: The students will first have to click on the object! Then e.g. two spots appear for the foci that can be dragged with the mouse to change the focal length.
>>> tt >>>
Resizable this
o|id||This object:
b|isResizable|true|will be resizable:
setRGB|
#FFFF99
>>> tt >>>
Set the red, green, and blue color values for a single object.
Color values must be in the range 0..255.
Use color tables of other software to determine these values or guess the additive light mixing:
For instance, yellow = red + green, so try (255,255,0)
brown is a dark red, thus (100,0,0) may work.
>>> tt >>>
Color this
o|id||Paint this object:
i|r|255|with intensities 0..255 for red:
i|g|255|green:
i|b|0|blue:
setVisibility|
#FFFF99
>>> tt >>>
Show or hide a single object. Set visibility to \"false\" to hide an object.
>>> tt >>>
Visible this
o|id||This object:
b|show|false|will be visible:
setDisplayOffset|
#FFFF99
>>> tt >>>
Draw a given object shifted in respect to its (x,y)-position.
While x and y are measured in units, the offset xoff and yoff are in pixels.
>>> tt >>>
Draw with offset this
o|id||This object:
i|xOff|10|will be drawn higher by:
i|yOff|10|pixels and/or shifted to the right by:
setAnimationSlave|
#FFFF99
>>> tt >>>
Make one object follow another object while it is dragged.
>>> tt >>>
Follow this
o|masterid||This object:
o|slaveid||will follow this object:
addObject|cstrID
#FFFF70
>>> tt >>>
Specify a region to restrict the range in which an object can be dragged with the mouse. This constrain will be named with an ID like \"cstr1\". You will have to use this ID in a subsequent setContraint() command (\"Constrain this\") to apply the restriction to a given object.
>>> tt >>>
Define Constraint
s|name|constraint|HIDDEN
$
.|d|xmin||xmin:
.|d|xmax||xmax:
.|d|ymin||ymin:
.|d|ymax||ymax:
setConstraint|
#FFFF70
>>> tt >>>
Restrict the range in which an object can be dragged with the mouse. First, use the \"Set constrain\" to specify the region.
>>> tt >>>
Constrain this
o|id||This object:
o|constraintid||is restricted by this constraint (as defined below):
setDrag|
#CCFFCC
>>> tt >>>
ALL objects that are created after this command, will be dragable with the mouse, if set to \"true\".
>>> tt >>>
Next dragable
b|d|true|All elements added after will be dragable:
setPropertyDrag|
#CCFFCC
>>> tt >>>
ALL objects that are created after this command, will be resizable with the mouse, if set to \"true\".
Note: The students will first have to click on an object! For example, when they click on a lens, two spots appear for the foci. These can be dragged with the mouse to change the focal length.
>>> tt >>>
Next resizable
b|pd|true|All elements created after will be dragable:
setInfo|
#CCFFCC
>>> tt >>>
ALL objects that are created after this command will show information on screen including focal lengths and positions, if set to \"true\".
Note: This only works for objects that are set \"resizable\" before!
>>> tt >>>
Next show info
b|i|true|All elements added after show their position, focal length etc.
setElementSize|
#CCFFCC
>>> tt >>>
ALL objects that are created after this command will be inserted in the specified height (Possible values are 0...1, size = 1 will set the height of all new elements equal to the height of the applet.)
>>> tt >>>
Next new size
d|s|0.7|The size of all objects shall be this fraction of the applet's height:
setElementRGB|
#CCFFCC
>>> tt >>>
ALL optical elements that are created after this command will have the colour specified by the values 0...255 for red, green, and blue color.
Use color tables of other software or guess the additive light mixing:
For instance, yellow = red + green, so try (255,255,0)
brown is a dark red, thus (100,0,0) may work.
>>> tt >>>
Next new color
i|r|255|Lenses and mirrors are displayed in colors (0..255) - red:
i|g|255|green:
i|b|0|blue:
setDirection|
#CCFFCC
>>> tt >>>
ALL optical light sources that are created after this command will emit rays to the specified direction 1 (to the right) or -1 (to the left)
This is NOT possible for arrow objects.
>>> tt >>>
Next beam direction
i|d|-1|All sources added after emit in this direction (to the right 1/ left -1):
setRayRGB|
#CCFFCC
>>> tt >>>
ALL optical light sources that are created after this command will have the colour specified by the values 0...255 for red, green, and blue color.
Use color tables of other software or guess the additive light mixing:
For instance, yellow = red + green, so try (255,255,0)
brown is a dark red, thus (100,0,0) may work.
>>> tt >>>
Next beam color
i|r|255|Intensities 0..255 for color components - red:
i|g|255|green:
i|b|0|blue:
getFocalLength|f
#E9D3FF
>>> tt >>>
Get the element's focal length
The result - stored in a variable - can be used in other JavaScript commands.
>>> tt >>>
get focal length
o|id||Create a variable containing the focal length of this object:
getIndex|n
#E9D3FF
>>> tt >>>
Get the element's index of refraction
The result - stored in a variable - can be used in other JavaScript commands.
>>> tt >>>
get index n
o|id||Create a variable containing the index of refraction of this object:
getXPos|x
#E9D3FF
>>> tt >>>
Get the element's x position.
The result - stored in a variable - can be used in other JavaScript commands.
>>> tt >>>
get x position
o|id||Create a variable containing the x position of this object:
getYPos|y
#E9D3FF
>>> tt >>>
Get the element's y position.
The result - stored in a variable - can be used in other JavaScript commands.
>>> tt >>>
get y position
o|id||Create a variable containing the y position of this object:"
addObject|benchID
#FFFFFF
>>> tt >>>
Move the optic elements and the rays to the foreground after having inserted other graphics.
>>> tt >>>
Bench foreground
s|name|bench|HIDDEN
$
.|f|foo| |HIDDEN
setPixPerUnit|
#FFFFFF
>>> tt >>>
Set the number of pixels on the screen per physical unit.
The units are displayed in the left lower corner.
>>> tt >>>
Pixel per Unit
i|ppu|100|a unit of length corresponds to this many pixels:
setAutoRefresh|
#FFFFFF
>>> tt >>>
Repaint every time the system parameters are changed (if set to true). Set this to "false" if you do not want to make changes visible during the execution of a given script function.
>>> tt >>>
setAutoRefresh
b|ar|true|Applet shall be repainted after every change of system parameters: