// UdK Computational design // Marius Watz 2003 // http://www.evolutionzone.com/udk/ // // UDK02_02_direction // // Avoid behavior. float x,y,x2,y2,xD,yD,radius; float dist,angle; void setup() { size(400,400); x=random(width); y=random(height); x2=random(width); y2=random(height); x2=200; y2=200; ellipseMode(CENTER_DIAMETER); } void loop() { background(200,200,200); xD=x2-x; yD=y2-y; radius=150; dist=sqrt(xD*xD+yD*yD); angle=degrees(atan2(yD,xD)); x=x+random(-10,10); y=y+random(-10,10); if(x<0) x=width; else if(x>width) x=0; if(y<0) y=height; else if(y>height) y=0; // Check to see if dist-(radius of green sphere) is less than radius // If so, avoid by moving some distance in the opposite direction. if((dist-5)