Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] View of /branches/lamont/test/implicit-surface/unit-circle.diderot
ViewVC logotype

View of /branches/lamont/test/implicit-surface/unit-circle.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2132 - (download) (annotate)
Fri Feb 8 22:06:12 2013 UTC (7 years, 1 month ago) by lamonts
File size: 1125 byte(s)
Working to particles
// unit-circle
//
// Demo of distributing particles on the unit circle 
//
int numOfParticles = 1000; 


strand Particle (int i) {
    output vec2 pos = [0.0,0.0];

    real isoval = 1; 
    int steps = 0;

    update {
        real energy = 0.0;
        real force = 0.0; 
        real raduis =0.01; 

        for(Particle neighbor in sphere(raidus) { 
            real d = distance (pos,neighbor.pos);             
            if(d > 0) { 
                if(d >= 0 && d <= 1) {
                   force += -4.0 * ((1 - d)^3);     
                   energy += ((1 - d)^4); 
                }                    
            }
        }
        
    

        vec2 grad = ∇F(pos);
        if (|grad| == 0.0) {    // can't compute step if |∇F|, so have to bail
	    die;
        }
        vec2 norm = normalize(grad);
        vec2 delta = -((F(pos) - isoval)/|grad|)*norm;  // Newton-Raphson step
        if (|delta| < epsilon) {    // we've converged if step is small enough
	    stabilize;
        }
        pos += stepScale * delta;
        steps += 1;
    }
}
initially {Particle(i) | i in 0 .. numOfParticles-1 };


root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0