Poisson AddObject Method

Poisson allows the creation of conductors and charge densities using the addObject method:

addObject(String name, String attributes)

The obejcts 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 circle can now be added to either applet using the following JavaScript statement:

id = 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 the Poisson 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

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

charge or
chargedensity

 

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

Choose either circle, ring, or box selectors.  A rectangle will be drawn if no selector is specified.
circle  a circular conductor.
r- int the radius of the circle

box  a hollow rectangular conductor.
s- int the thickness of the box walls in pixels

ring  a hollow circular conductor.
r- int the radius of the circle
s- int the thickness of the box walls in pixels

Example: addObject("conductor","box, x=1, y=2, w=20, h=50, s=4");

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

conductor

x- double x position of the center in world units
y- double y position of the center in world units.
v- double the voltage
w- int the width of the object in pixels
h- int the height of the object in pixels

Choose either circle, ring, or box selectors.  A rectangle will be drawn if no selector is specified.
circle  a circular conductor.
r- int the radius of the circle

box  a circular conductor.
s- int the thickness of the box walls in pixels

ring  a circular conductor.
r- int
the radius of the circle
s- int
the thickness of the box walls in pixels

Example: addObject("conductor","box, x=1, y=2, w=20, h=50, s=4");

constraint

A constraint on dragged objects.

xmin- double minimum x
xmax- double maximum x
ymin- double minimum y
ymax- double maximum y

dielectric

x- double x position of the center in world units
y- double y position of the center in world units.
v- double the voltage
w- int the width of the object in pixels
h- int the height of the object in pixels

Choose either circle, ring, or box selectors.  A rectangle will be drawn if no selector is specified.
circle  a circular conductor.
r- int the radius of the circle

box  a circular conductor.
s- int the thickness of the box walls in pixels

ring  a circular conductor.
r- int
the radius of the circle
s- int
the thickness of the box walls in pixels

Example: addObject("dielectric","box, x=1, y=2, w=20, h=50, s=4");

connectorline
A straight line connecting two objects.

id1- int first object identifier.
id2- int
second object identifier.

See also: addConnectorSpring(int,int) in the online documentation.  This method is easier to use if the ids are stored as integers.

contours

The contour plot.

No parameters.  A place-holder that determines the z-order for the contour plot.  The contour plot will be drawn first unless it is explicitly added using the addObject method.

cursor

A circle with crosshairs

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

field

The vector field plot.

No parameters. A place-holder that determines the z-order for the vector field plot.  The vector field plot will be drawn first unless it is explicitly added using the addObject method.

function

f- string the analytic function, f(x)
var- string
the independent variable, x
n- int
the number of points used during the evaluation
xmin- double the first value of x to evaluate
xmax- double the last value of x to evaluate

image

A gif image.

x- double position of the base in world units
y- double position of the base in world units.
file- string image file relative to code base

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

shell

A hollow circle.

x- double position of the base in world units
y- double position of the base in world units.
r- int radius 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.

testcharge

A test charge with a force arrow.

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