int numCells=50; int maxCells=100; ArrayList cells= new ArrayList(); float avgRadius; PImage img; void setup(){ size(450,450); background(255); smooth(); avgRadius=0.4f*sqrt(0.66*width*1.2f*height/(PI*numCells)); cell c = new cell(); for(int i=0;i1.0f)?0.0f:0.5f*(1.0f-1.0f/ratio)*(cj.centerX-ci.centerX); dy=(ratio>1.0f)?0.0f:0.5f*(1.0f-1.0f/ratio)*(cj.centerY-ci.centerY); ci.centerX+=dx; ci.centerY+=dy; cj.centerX-=dx; cj.centerY-=dy; } ci.centerY-=.5f*avgRadius/ci.radius; if(!ci.intersect){ //cells[i].centerX+=(cells[i].centerX1.1f*height) ci.centerX-=1.2f*width; //if(ci.centerY>height) ci.centerY=height; float x3=ci.centerX; float y3=ci.centerY; float r=ci.radius; float a= sq(x2-x1)+sq(y2-y1); float b=2*((x2-x1)*(x1-x3)+(y2-y1)*(y1-y3)); float c=x3*x3+y3*y3+x1*x1+y1*y1-2*(x3*x1+y3*y1)-r*r; float u=-0.5f*b/a; if (((b*b-4*a*c)>0.0f)&&(u>=0.0f)&&(u<=1.0f)) ci.radius=1.0f; } }