how to simulate flow of particles in a wire?

i analyze the method used here
http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=912.0

say for the loop wire
[code]if(x2[j] else if(x2[j]>a-D*i)x2[j]-=D;[/code]

is used to trick the human eyes by telling when to disappear n appear a distance + or -D away.

i actually ran into some bug.
the codes works when the variables "lengthx" is 1.5 which is the same as your "D". perfect synchronization, the particles disappear n appear together of the visual effect of particle flow is achieved.

but when i create a slider, and move it,
the particles, dynamically re position but the spacing is funny, not equal.

the resultant new effect is not realistic enough to "trick" to human eye.

any tips for me to explore? my source is attached :)


/htdocs/ntnujava/ejsuser/14019/users/sgeducation/lookang/ACgenerator02_pkg/ACgenerator02.propertiesFull screen applet or Problem viewing java?Add http://www.phy.ntnu.edu.tw/ to exception site list
Press the Alt key and the left mouse button to drag the applet off the browser and onto the desktop. This work is licensed under a Creative Commons Attribution 2.5 Taiwan License
Download EJS jar file(1709.5kB):double click downloaded file to run it. (1 times by 1 users) , Download EJS source (1 times by 1 users) View EJS source