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 2138 - (download) (annotate)
Thu Feb 14 20:49:22 2013 UTC (6 years, 8 months ago) by lamonts
File size: 1211 byte(s)
Work for today
// unit-circle
//
// Demo of distributing particles on the unit circle 
//
real{} initPosns = load("../../data/implicit-surface/circlePosns.nrrd");
int numOfParticles = 100;
input real r = 0.2;  // particle radius 
input real d = 0.1;  // desired difference of radius (d < r && d > 0)
input real R = 0.9;  // neighbor radius 
input real h;  // integration stepsize scaling ∇E update lenght 
input int maxi = 1000; // maximum number of steps in the program 

strand Particle (real posx, real posy) {
    vec2 pos = [posx,posy];
    real isoval = 1; 
    int steps = 0;
    output vec2 outPos  = pos; 
    update {
        real energy = 0.0;
        real force = 0.0; 

        foreach(Particle neighbor in sphere(R)){ 
            real d = dist (pos,neighbor.pos);             
            if(d >= 0 && d <= 1) {
                   force += -4.0 * ((1 - d)^3);     
                   energy += ((1 - d)^4); 
             }
        }
        printf("f : ", force, "\n"); 
        pos *= force; 
        pos = pos / |pos|; 
        outPos = pos; 
        steps+=1; 
        if(steps >= maxi) 
            stabilize; 
    }
}
initially {Particle(initPosns{i*2},initPosns{i*2+1}) | i in 0 .. numOfParticles-1 };


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