Reflection AddObject Method

The reflection applet models wave reflection at boundary layers for both E&M and quantum mechanics.  Layers are added left to right and represent either a dielectric film in EM mode or a region of potential energy in QM mode.  Reflection allows the creation of layers and geometric shapes using the addObject method:

addObject(String name, String attributes)

Objects usually, but not always, have an on-screen representation.  The first argument is the name of the object to be added, and the second is a comma-delimited list of parameters.  A layer can be added using any of the following JavaScript statement:

document.physletname.addObject("layer", "w=1,n=2");
document.physletname.addObject("film", "w=1,n=2");.
document.physletname.addObject("medium", "w=1,n=2");.

The parameters are the width of the layer and the index of refraction (or potential energy) of the layer.  A circle can be added using the following JavaScript statement:

document.physletname.addObject("circle", "x=0,y=-1.0,r=10");.

The addObject method is very forgiving since not all parameters need to be specified.  Default values are overridden only if the parameter appears in the list.  Incorrect and unsupported parameters do not affect the applet and are ignored.

The table below lists the name and the associated parameters for version 4 of the BField Physlet.   Consult the online documentation for information about other Physlets.  OpticsBench, for example, supports the addObject method for lenses, mirrors, and light sources.

Name  Attributes
arrow

Arrows are often animation slaves of other objects.  They can represent almost any vector since the h and v components can be functions of the variables.

x- double position of the base in world units
y- double position of the base in world units.
h- string horizontal component
v- string vertical component
s -int size of arrowhead

box

A hollow rectangle.

 

x- double position of the base in world units
y- double position of the base in world units.
h- int height in pixels
w- int width in pixels

caption

Text.

x- double position of the base in world units
y- double position of the base in world units.
txt- string text

circle

A filled circle.

x- double position of the base in world units
y- double position of the base in world units.
r- int radius in pixels

layer
film
medium

An change in potential energy or index

n- double index of refraction or potential energy
w- double width of layer in world units

rectangle

A filled rectangle.

x- double position of the base in world units
y- double position of the base in world units.
h- int height in pixels
w- int width in pixels

text

A text message with an optional calculation.

 

x- double position of the base in world units
y- double position of the base in world units.
txt- string message
calc- string an analytic function that is appended to the message.

Text objects are often slaved to other objects. If a text object is slaved to an object, it takes on the properties of that object.

Use the setFormat method described to change the decimal format used to output the calculation.