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

SCM Repository

[diderot] Diff of /tests/lamont-tests/boids.diderot
ViewVC logotype

Diff of /tests/lamont-tests/boids.diderot

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4640, Tue Sep 27 20:54:47 2016 UTC revision 5034, Tue Jul 11 23:24:17 2017 UTC
# Line 1  Line 1 
1  #version 2  #version 2
2    
3  real[] initVelocities = load_sequence("velocities.nrrd");  real[] initVelocities = load_sequence("data/velocities.nrrd");
4  real[] initPosns = load_sequence("posns.nrrd");  real[] initPosns = load_sequence("data/posns.nrrd");
5  int numBoids = 100;  int numBoids = 100;
6  input real boidRadius = 5;  input real boidRadius = 5;
7  input real queryRadius = 50;  input real queryRadius = 50;
# Line 11  Line 11 
11  real boundsFactor = 10.0;  real boundsFactor = 10.0;
12  input int width = 800;  input int width = 800;
13  input int height = 600;  input int height = 600;
14  int NORTH = 0;  const int NORTH = 0;
15  int SOUTH  = 1;  const int SOUTH  = 1;
16  int WEST = 2;  const int WEST = 2;
17  int EAST =  3;  const int EAST =  3;
18  int steps = 0;  int steps = 0;
19    
20  strand Boid(int i,real vx, real vy, real px, real py) {  strand Boid(int i,real vx, real vy, real px, real py) {
# Line 22  Line 22 
22      vec2 vel = [vx,vy];      vec2 vel = [vx,vy];
23      int id = i;      int id = i;
24      output vec4 boidInfo = [pos[0],pos[1],vel[0],vel[1]];      output vec4 boidInfo = [pos[0],pos[1],vel[0],vel[1]];
25    
26      //output real value = 0.0;      //output real value = 0.0;
27      update {      update {
   
28          vec2 cohereVec = [0.0,0.0];          vec2 cohereVec = [0.0,0.0];
29          vec2 alignVec = [0.0,0.0];          vec2 alignVec = [0.0,0.0];
30              vec2 seperateVec = [0.0,0.0];              vec2 seperateVec = [0.0,0.0];
# Line 85  Line 85 
85              cohereVec = [0.0,0.0];              cohereVec = [0.0,0.0];
86          }          }
87    
   
88          vec2 acceleration = cohereVec + alignVec + seperateVec;          vec2 acceleration = cohereVec + alignVec + seperateVec;
89    
90              vel += acceleration;              vel += acceleration;
# Line 95  Line 94 
94              vel *= MAX_SPEED;              vel *= MAX_SPEED;
95              }              }
96    
   
97          pos += vel;          pos += vel;
98    
   
99          //Wrapping Code, if a boid goes outside the window          //Wrapping Code, if a boid goes outside the window
100          real posX = wrapDimensions[EAST] if pos[0] < wrapDimensions[WEST]          real posX = wrapDimensions[EAST] if pos[0] < wrapDimensions[WEST]
101                                           else wrapDimensions[WEST] if pos[0] > wrapDimensions[EAST]                                           else wrapDimensions[WEST] if pos[0] > wrapDimensions[EAST]
# Line 110  Line 107 
107    
108          pos = [posX,posY];          pos = [posX,posY];
109    
   
   
   
110           boidInfo = [pos[0],pos[1], vel[0], vel[1]];           boidInfo = [pos[0],pos[1], vel[0], vel[1]];
111    
112    
# Line 121  Line 115 
115              stabilize;              stabilize;
116          }          }
117    
118     }      } // update
 }  
119    
 create_collection {  
   Boid(i, initVelocities{i*2}, initVelocities{i*2+1}, initPosns{i*2}, initPosns{i*2+1})  
   | i in 0 .. numBoids-1  
120  }  }
121    
122  update {  update {
123    steps += 1;    steps += 1;
124  }  }
125    
126    create_collection {
127        Boid(i, initVelocities[i*2], initVelocities[i*2+1], initPosns[i*2], initPosns[i*2+1])
128      | i in 0 .. numBoids-1
129    }

Legend:
Removed from v.4640  
changed lines
  Added in v.5034

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