//pattern 2 float p=PI; //ratio by which random distances are determined float xtf; //carrier for flipper float ytf; //carrier for flipper float o; //for calculating tan-1 float ao; //trig at xya float bo; //trig at xyb float a; //for calculating tan-1 float aa; //trig at xya float ba; //trig at xyb float theta; //for trigonometry float aTheta; //anchor angle at xya float bTheta; //anchor angle at xyb float L; //for trigonometry (hypotenuse) float aL; //xya to xyc float bL; //xyb to xyd float nL; //random new hypotenuse int choice; //random choice int q; //random child index float xta; //carrier variable float yta; //carrier variable float xtb; //carrier variable float ytb; //carrier variable float xtc; //carrier variable float ytc; //carrier variable float xtd; //carrier variable float ytd; //carrier variable // child co-ord table float [] xva=new float[150+int(random(50))]; //float [] xva=new float[3]; float [] yva=new float[xva.length]; float [] xvb=new float[xva.length]; float [] yvb=new float[xva.length]; float [] xvc=new float[xva.length]; float [] yvc=new float[xva.length]; float [] xvd=new float[xva.length]; float [] yvd=new float[xva.length]; int [] flag=new int[xva.length]; //line or curve (0 or 1) void setup (){ size (500,300); background (255); ellipseMode(CENTER_DIAMETER); smooth(); xva[0]=200; yva[0]=200; xvb[0]=300; yvb[0]=100; xvc[0]=200; yvc[0]=100; xvd[0]=300; yvd[0]=200; flag[0]=1; //xvc[0]=200; //yvc[0]=200; //xvd[0]=300; //yvd[0]=100; } void loop () { noStroke(); fill(255); rect(0,0,width,height); //graph paper for 500x300 //stroke(220); //for(int j=0; j<505; j+=5) { // line (j,0,j,500); // if (j<305){ // line (0,j,500,j); // } //} //stroke (180); //line (250,0,250,500); //line (0,150,500,150); //child co-ord creator for (int i=1; iTWO_PI){ theta-=TWO_PI; } if (bTheta>TWO_PI){ bTheta-=TWO_PI; } xtb=xta+(cos(theta)*nL); xtd=xtb+(cos(bTheta)*bL); ytb=yta+(sin(theta)*nL); ytd=ytb+(sin(bTheta)*bL); } void rotation() { float nTheta=(theta-(TWO_PI/p))+(random((TWO_PI/p)*2)); if (theta<0){ theta+=TWO_PI; } else if (theta>TWO_PI){ theta-=TWO_PI; } aTheta+=(nTheta-theta); bTheta+=(nTheta-theta); if (aTheta<0){ aTheta+=TWO_PI; } else if (aTheta>TWO_PI){ aTheta-=TWO_PI; } if (bTheta<0){ bTheta+=TWO_PI; } else if (bTheta>TWO_PI){ bTheta-=TWO_PI; } xtc=(xta+(cos(aTheta)*aL)); ytc=(yta+(sin(aTheta)*aL)); xtb=(xta+(cos(nTheta)*nL)); ytb=(yta+(sin(nTheta)*nL)); xtd=(xtb+(cos(bTheta)*bL)); ytd=(ytb+(sin(bTheta)*bL)); } //Button boolean overRect(int x, int y, int width, int height) { if (mouseX >= x && mouseX <= x+width && mouseY >= y && mouseY <= y+height) { return true; } else { return false; } } void trig(){ a=(xtb-xta); o=(ytb-yta); theta=atan2(a,o); L=sqrt(sq(abs(a))+sq(abs(o))); nL=(L-(L/p))+random((L/p)*2); }