boolean released=true; node root; int nodeSize=5; int nodeDistance=30; int totalNodes=0; int maxNodes=1600; int curveCounter=0; int maxNodeLength=0; float angMul=0; int bg=0; int distance=0; int childChance=0; int nextChance=0; position nodePos[]; void setup() { size(800,600); smooth(); ellipseMode(CENTER_DIAMETER); maxNodeLength=int(random(500)); angMul=random(.1,1); nodeSize=int(random(0,2)); totalNodes=0; curveCounter=0; bg=int(random(60)); distance=int(random(500,2500)); childChance=int(random(20,50)); nextChance=int(random(20,50)); root=new node(new vector(random(width),random(height),random(360),nodeDistance)); constructNode(root); nodePos=new position[totalNodes+1]; addNodes(root); drawComp(); } void constructNode(node n) { if(random(100)>50) angMul+=.01; else angMul-=.01; if(random(100)>50) maxNodeLength+=random(5); else maxNodeLength-=random(5); /* if(random(100)>50) childChance+=1; else childChance-=1; if(random(100)>50) nextChance+=1; else nextChance-=1; */ nodeDistance=int(random(2,100)); if(totalNodes>maxNodes) return; float ang=0; if(random(100)>childChance) ang=random(-70*angMul,-50*angMul); else ang=random(50*angMul,70*angMul); if(random(100)>nextChance) { totalNodes++; n.next=new node(new vector(n.direction.p,n.direction.a+ang,nodeDistance)); constructNode(n.next); } if(random(100)>20) { totalNodes++; n.child=new node(new vector(n.direction.endPoint(),n.direction.a+ang,nodeDistance)); constructNode(n.child); } } void loop() { if(mousePressed&&released) { released=false; setup(); drawComp(); } } void drawComp() { background(bg); push(); translate(0,0,-1*distance); stroke(0); strokeWeight(.5); beginShape(LINE_STRIP); for(int i=0;i0) // { if(s.y>testY) return 1; else return -1; /* } else { if(s.y>testY) return -1; else return 1; }*/ } } position displace(position p,float angle,float magnitude) //displaces a position by an angle and a magnitude, then returns it { position newP=new position(p); float ra=radians(angle); newP.x+=(cos(ra)*magnitude); newP.y-=(sin(ra)*magnitude); return newP; } float getHeading(position p1,position p2) //gets the absolute heading between one position and another relative to the first { if(p1.x==p2.x&&p1.y==p2.y) return 0; float xd=p2.x-p1.x; float yd=p2.y-p1.y; float angle=float(Math.atan(yd/xd)); // angle=degrees(angle); angle=angle*conversionArc; if(xd>0&&yd<0) { angle=-1*angle; println(1); } else if(xd<0&&yd<0) angle=180-angle; else if(xd<0&&yd>0) angle=180-angle; else if(xd<0&&yd==0) angle=180; else if(xd==0&&yd<0) angle=90; else angle=360-angle; return angle; } float dist(position p1,position p2) { return dist(p1.x,p1.y,p2.x,p2.y); } float normalizeHeading(float ang) //normalizes a heading between 0 and 360 { while(ang > 360)ang -= 360; while(ang < 0)ang += 360; return ang; } void drawVector(vector v) //draws a vector in white { colorMode(RGB,255,255,255); stroke(255); noFill(); ellipseMode(CENTER_DIAMETER); ellipse(v.p.x,v.p.y,5,5); position e=v.endPoint(); line(v.p.x,v.p.y,e.x,e.y); } void drawVector(vector v,float s) //draws a vector with a longer line for representation in white { colorMode(RGB,255,255,255); stroke(255); noFill(); ellipseMode(CENTER_DIAMETER); ellipse(v.p.x,v.p.y,5,5); vector temp=new vector(v); temp.m*=s; position e=temp.endPoint(); line(temp.p.x,temp.p.y,e.x,e.y); } void drawVector(vector v,int r,int g,int b,float s) //draws a vector with a longer line for representation in white { colorMode(RGB,255,255,255); stroke(r,g,b); noFill(); ellipseMode(CENTER_DIAMETER); ellipse(v.p.x,v.p.y,5,5); vector temp=new vector(v); temp.m*=s; position e=temp.endPoint(); line(temp.p.x,temp.p.y,e.x,e.y); } void drawVector(vector v,int r,int g,int b) //draws a vector in RGB { colorMode(RGB,255,255,255); stroke(r,g,b); noFill(); ellipseMode(CENTER_DIAMETER); ellipse(v.p.x,v.p.y,5,5); position e=v.endPoint(); line(v.p.x,v.p.y,e.x,e.y); }