// unfolding sequences of triangles in kn //the blue is a band //the white sometimes //crystal or flower int num = int(random(5,17)); int piso, techo, pizq, pdere; int veladura = 50; float elasticidad = 0.1; float friccion = 0.1; float t = 0; Pelota[] pelotas = new Pelota[num]; Pelota[] pelotas2 = new Pelota[num]; void setup() { size(400,400); background(255,20,30); framerate(24); smooth(); ellipseMode(CENTER_RADIUS); piso = 15*height/16; techo = height/16; pdere = 15*width/16; pizq = width/16; for ( int i=0; i 0 ){ float dD = d; float theta = atan2(y-Y,x-X); if(((vX>velx)&&(vY>vely))||(R>radio)){ velx += -dD*cos(theta)*M/(masa+M); vely += -dD*sin(theta)*M/(masa+M); } else{ //velx += dD*cos(theta)*M/(masa+M)/2; //vely += dD*sin(theta)*M/(masa+M)/2; velx = velx; //vely = vely; } } } for ( int i=0; i 0 ){ float dD = d; float theta = atan2(y-Y,x-X); if(((vX>velx)&&(vY>vely))||(R>radio)){ velx += dD*cos(theta)*M/(masa+M); vely += dD*sin(theta)*M/(masa+M); } else{ //velx += dD*cos(theta)*M/(masa+M)/2; //vely += dD*sin(theta)*M/(masa+M)/2; velx = velx; //vely = vely; } } } } /****** rebote en redondo (todavia no)******/ void rebote(){ //if( sq(x)+sq(y) > width/2 ) if ( y + vely + radio > piso ){ // el piso la orilla es igual a width y = piso - radio; velx *= friccion; vely *= -elasticidad; } if ( y + vely - radio < techo ){ // el techo en la orilla es igual a cero y = techo + radio; velx *= friccion; vely *= -elasticidad; } if ( x + velx + radio > pdere ){ x = pdere - radio; velx *= -elasticidad; vely *= friccion; } if ( x + velx - radio < pizq ){ x = pizq + radio; velx *= -elasticidad; vely *= friccion; } } /***** rebote viejo *****/ /* void rebote(){ if ( y + vely + radio > piso ){ // el piso la orilla es igual a width y = piso - radio; velx *= friccion; vely *= -elasticidad; } if ( y + vely - radio < techo ){ // el techo en la orilla es igual a cero y = techo + radio; velx *= friccion; vely *= -elasticidad; } if ( x + velx + radio > width ){ x = width - radio; velx *= -elasticidad; vely *= friccion; } if ( x + velx - radio < 0 ){ x = radio; velx *= -elasticidad; vely *= friccion; } }*/ void choque(){ for ( int i=0; i 0 ){ float dD = radio + R - d; float theta = atan2(deltay,deltax); velx += -dD*cos(theta)*M/(masa+M); vely += -dD*sin(theta)*M/(masa+M); velx *= elasticidad; vely *= elasticidad; } } for ( int i=0; i 0 ){ float dD = radio + R - d; float theta = atan2(deltay,deltax); velx += -dD*cos(theta)*M/(masa+M); vely += -dD*sin(theta)*M/(masa+M); velx *= elasticidad; vely *= elasticidad; } } } void desplazamiento(){ x += velx; y += vely; } void spin(){ } void display(){ stroke(0); if (c<0.75f) fill(0,100); else if (c>=0.45f) fill(255,255,255,200); } }