According to http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=1210.0
dipoles was defined as dipoles[nd][2]

[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]
The above code will produce error message because you try to access dipoles[0][ i ] (where i might be larger than 1).
The above code did not make sense.

You should try to understand the code instead of did it by "trial and error".


The dipoles was used to simulate the magnet (it consists of magnetic dipole at different x (same y).
The needles which show direction of magnetic field are draw with VectorField2D (which defined by xField and yField)
And it was calculated with computeField () -- call getBComputeField(x,y); to set xField and yField.

May I know what you really want to do?