CODING FORM_FALL 2011_FINAL_DALE STRONGAGENT ALGORITHM

Boundary for next
attractor
Boundary for next
attractor
Boundary forfirst attractor

Point Matrix 1

Attractor 1

Point Matrix 3

Point Matrix 2

Point Matrix 2

Point Matrix 1

Point Matrix 1

t = 0
Agent Definitiont = 1
Update Method

Agent checks
for closest
attractor andorients next
vector in 3d
space towards
its direction.

Interact Methodt = 2
Update Method

AGENT GEOMETRY

next dir
pt2
pt1z

pt1z
pt2yxyz

pt1
pt1x
pt1y
Points for Agent set-up

import processing.opengl.*;import igeo.*;void setup(){size(640,640,IG.GL);
IG.duration(30);

PROCESSING CODE

pt2x

for(int i=0; i < 3; i++){new MyAttractor(IRand.pt(10, 0, 20, 60, 30, 30));}//agents in a matrix
for(int i=0; i < 10; i++){for(int j=0; j < 10; j++){new MyLineAgent(new IVec(j*10, i*3,10*tan(i+j)),
new IVec(0,0,i),(i+j)*.5).
clr(j*.08,i*.1,i*.1);}}}
static class MyAttractor extends IAgent{
IVec pos;
IPoint point;
MyAttractor(IVec p){
pos = p;point = new IPoint(pos).clr(1.0,0,0);}void update(){// random walkpos.add(IRandom.pt(0,-15,-30,5,15,30));}}
static class MyLineAgent extends IAgent{
double size1;

Line connects initialpoint to second point ingrowth sequence

Surface Geometry createdbetween points

Additional Lines
drawn between points

IVec pos, dir,att;
MyLineAgent(IVec p, IVec d, double sz){ //add double sz
pos = p;dir = d;size1 = sz;
att = null;}
void interact(ArrayList < IDynamics > agents){//searching the closest attractor
MyAttractor closestAttractor=null;
double minDist=-1;
for(int i=0; i < agents.size(); i++){if(agents.get(i) instanceof MyAttractor){
MyAttractor attractor = (MyAttractor)agents.get(i);double dist = attractor.pos.dist(pos);//first attractor to check
if(minDist < 0){closestAttractor = attractor;
minDist = dist;}//if less than minimum, it’s new minimum
else if(dist < minDist){
closestAttractor = attractor;
minDist = dist;}}}//in case no attractor found, if-condition is used
if(closestAttractor!=null){IVec diff = closestAttractor.pos.diff(pos);diff.len(dir.len());
dir = diff;

All Lines are reflectedacross Y axis

att = closestAttractor.pos.dup();}

IVec[] ptList3 = new IVec[2];ptList3[0] = pt1y;
ptList3[1] = pt1;}
void update(){IVec[] ptList4 = new IVec[2];ptList4[0] = pt1y;
ptList4[1] = pt2y;

ILayer layer1 = IG.layer(“line1”);
ILayer layer2 = IG.layer(“line2”);
ILayer layer3 = IG.layer(“line3”);
ILayer layer4 = IG.layer(“line4”);
ILayer layer5 = IG.layer(“line5”);
ILayer layer6 = IG.layer(“line6”);

IVec[] ptList5 = new IVec[2];ptList5[0] = pt1x;
ptList5[1] = pt2x;//create curves
ICurve crv1 = new ICurve(ptList1,1,false).clr(this.clr())
ICurve crv2 = new ICurve(ptList2,1,false).clr(this.clr())
ICurve crv3 = new ICurve(ptList3,1,false).clr(this.clr())
ICurve crv4 = new ICurve(ptList4,1,false).clr(this.clr())
ICurve crv5 = new ICurve(ptList5,1,false).clr(this.clr())//set-up geometry
IVec pt1 = pos.dup();
IVec pt2 = pos.dup().add(dir);
IVec pt2y = pt2.dup().add(0,size1,0);
IVec pt2x = pt2.dup().add(size1,0,0);//mirror curves
crv1.cp().ref(new IVec(0,10,0));crv2.cp().ref(new IVec(0,10,0));crv3.cp().ref(new IVec(0,10,0));crv4.cp().ref(new IVec(0,10,0));crv5.cp().ref(new IVec(0,10,0));crv6.cp().ref(new IVec(0,10,0));

IVec pt1z = pos.dup().add(0,0,size1);
IVec pt1y = pos.dup().add(0,size1,0);
IVec pt1x = pos.dup().add(size1,0,0);//Set-up Curves
IVec[] ptList1 = new IVec[2];ptList1[0] = pt2;
ptList1[1] = pt1;
IVec[] ptList2 = new IVec[2];ptList2[0] = pt1x;
ptList2[1] = pt1;//Create srf
new ISurface(ptx,pty,ptz).clr(this.clr());
pos.add(dir);}}