In EJS :
1. You need to provide X[],Y[] for shapeSet. How do you related X[],Y[] to dipole[][]???
i.e. The [u]Pos X[/u] and [u]Pos Y[/u] should be an one-dimension array like X[20] or Y[20] (a double array)
[/quote]
In this simulation http://www.compadre.org/osp/items/detail.cfm?ID=9414 , i am making sense of the variables by trial and error, testing and drawing objects to test what each codes are doing.
i have remix it here http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=1210.0
from my experience tinkering with the codes, dipoles is an array [nd][2] where nd is integer = 20, i am not sure why but there is no X[] and Y[] to draw the dipoles but by testing out, i keyed in dipoles in the ArrowSet Position[] as "dipoles" and it drew the position of the dipoles, without X[]and Y[].

And in the following loop you have: i+=2 so half of the index for dipoles[0][i] were not defined.
[/quote]
strangely when i change it to i+=1, no more B field drawn?, it is using the empty dipoles to create the magnetic field?
i change to i+= 4, then it draw B field again

[code]
double dy=1.0/(nd-1);    //set up dipoles under bar magnet
for(int i=0; i < n d; i+=2) {
dipoles[0][ i ]=-0.5+i*dy;
}
[/code]
By the way what is the meaning of dipoles[][]?
[/quote]
dipoles[][] is the array to "positions of dipoles" so by changing values, i come to understand that dipoles[X][Y] is the way the array is made.

Why the dimension is dipoles[20][20]? instead of dipoles[20][2]?

[/quote]
oh, i changed it to test out whether i need [20][20] because i thought i need the [X][Y] the Y to be 20 because i was trying to draw (positions of dipoles) vertically up.
original is dipoles[20][2] = so it drawn

0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 which is a [X][Y]=[20][2]

so i thought to draw (positions of dipoles)
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0  i need [X][Y]=[2][20]

but since the codes need to work for all cases, i just make it [X][Y]=[20][20] thinking it will not adverse affect the calculation of Custom Functions.

i attached my xml for ease of discussion and so that you can see everything.
Thanks!