Brownian Motion

Init

Setting Particle Properties

Each particle has position, velocity, mass and size properties. These properties can be set by calling the applet's public methods after the particles have been created.  The red particle has 40x the mass of the blue particles.


Script Example

<script language="JavaScript">

function brownian(){
    document.Molecular.setAutoRefresh(false); 
    document.Molecular.setDefault();
    document.Molecular.setShowControls(false);
    document.Molecular.setPeriodicH(false);
    document.Molecular.setPeriodicV(false);
    document.Molecular.createParticles(20);
    for(i=0;i<20;i++){
       document.Molecular.setParticlePos(i,-10+20*Math.random(),-10+20*Math.random());
       document.Molecular.setParticleVel(i,-5+10*Math.random(),-5+10*Math.random());
    }
    document.Molecular.setParticlePos(0,0,0);
    document.Molecular.setParticleVel(0,0,0);
    document.Molecular.setParticleMass(0,40);
    document.Molecular.setParticleRGB(0,255,0,0);
    document.Molecular.setParticleSize(0,3.0);
    document.Molecular.setAutoRefresh(true); 
    document.Molecular.forward();
}
</script>