// Throwing_in_SpaceColony_1.0
float A = 0 ; float R = 150 ; float RV = 0.01 ; float LR = 10 ;
float X[] = new float[100] ; float Y[] = new float[100] ;
float NX[] = new float[100] ; float NY[] = new float[100] ;
float VX[] = new float[100] ; float VY[] = new float[100] ;
float SX = 0 ; float SY = 0 ; float GX = 0 ; float GY = 0 ;
byte EXT[] = new byte[100] ;
float KVX = 0 ; float KVY = 0 ; float NKVX = 0 ; float NKVY = 0 ;
float L = 0 ;
int I = 0 ; int II = 0 ; int N = 0 ;
void setup(){
size(700,500) ;
background(200,200,200) ;
} // setup()
void draw(){
background(200,200,200) ;
strokeWeight(1) ; stroke(150,150,150) ; noFill() ;
for ( I = 0 ; I <= 9 ; I++ ){
for ( II = 0 ; II <= 9 ; II++ ){
line(175+(30*(I-4.5)*cos(A))-(R*sin(A)),175+(30*(I-4.5)*sin(A))+(R*cos(A)),175+(30*(I-4.5)*cos(A))+(R*sin(A)),175+(30*(I-4.5)*sin(A))-(R*cos(A))) ;
line(175+(30*(I-4.5)*cos(A+(PI/2)))-(R*sin(A+(PI/2))),175+(30*(I-4.5)*sin(A+(PI/2)))+(R*cos(A+(PI/2))),175+(30*(I-4.5)*cos(A+(PI/2)))+(R*sin(A+(PI/2))),175+(30*(I-4.5)*sin(A+(PI/2)))-(R*cos(A+(PI/2)))) ;
line(525+(30*(I-4.5)),175-R,525+(30*(I-4.5)),175+R) ;
line(525+R,175+(30*(I-4.5)),525-R,175+(30*(I-4.5))) ;
}
}
strokeWeight(2) ; stroke(0,0,0) ;
ellipse(175,175,R*2,R*2) ;
ellipse(525,175,R*2,R*2) ;
SX = (R-LR)*cos(-A) ; SY = (R-LR)*sin(-A) ;
GX = (R-10)*cos(-A+PI) ; GY = (R-10)*sin(-A+PI) ;
fill(100,100,255) ;
ellipse(525+SX,175+SY,10,10) ;
ellipse(175+R-LR,175,10,10) ;
fill(255,0,0) ;
ellipse(525+GX,175+GY,10,10) ;
ellipse(175-R+10,175,10,10) ;
if ( mouseX > 0 && mouseX < 350 && mouseY > 0 && mouseY < 400 ){
KVX = (mouseX-(175+R-LR))/1.5 ; KVY = (mouseY-(175))/1.5 ;
}else{
KVX = 0 ; KVY = 0 ;
}
L = sqrt((KVX*KVX)+(KVY*KVY)) ;
if ( L > 200 ){ KVX = KVX * 200/L ; KVY = KVY * 200/L ; }
strokeWeight(1) ;
line(175+R-LR,175,175+R-LR+KVX,175+KVY) ;
NKVX = (KVX*cos(-A)) - (KVY*sin(-A)) ;
NKVY = (KVX*sin(-A)) + (KVY*cos(-A)) ;
line(525+SX,175+SY,525+SX+NKVX,175+SY+NKVY) ;
noStroke() ;
for ( I = 99 ; I > 0 ; I-- ){
if ( EXT[I] == 1 ){
X[I] = X[I-1] ;
Y[I] = Y[I-1] ;
NX[I] = NX[I-1] ;
NY[I] = NY[I-1] ;
fill(255,255,255,(100-I)*255/100) ;
ellipse(X[I]+525,Y[I]+175,10,10) ;
ellipse(NX[I]+175,NY[I]+175,10,10) ;
L = sqrt((X[I]*X[I])+(Y[I]*Y[I])) ;
if ( L > R ){ EXT[I] = 0 ; }
}
}
strokeWeight(2) ; stroke(0,0,0) ; fill(255,255,255,255) ;
if ( EXT[0] == 1 ){
X[0] = X[0] + VX[0] ;
Y[0] = Y[0] + VY[0] ;
NX[0] = (X[0]*cos(A))-(Y[0]*sin(A)) ;
NY[0] = (X[0]*sin(A))+(Y[0]*cos(A)) ;
ellipse(X[0]+525,Y[0]+175,10,10) ;
ellipse(NX[0]+175,NY[0]+175,10,10) ;
L = sqrt((X[0]*X[0])+(Y[0]*Y[0])) ;
if ( L > R ){ EXT[0] = 0 ; }
}
A = A + RV ;
noFill() ;
rect(50,420,80,50) ;
rect(150,420,80,50) ;
rect(250,420,80,50) ;
rect(350,420,80,50) ;
strokeWeight(4) ;
line(90,430,90,460) ; line(75,445,105,445) ;
line(175,445,205,445) ;
line(275,445,305,445) ; line(275,445,290,430) ; line(275,445,290,460) ;
line(375,445,405,445) ; line(405,445,390,430) ; line(405,445,390,460) ;
} // draw()
void mousePressed(){
if ( mouseY < 400 ){
for ( I = 0 ; I <= 99 ; I++ ){
EXT[I] = 1 ;
VX[I] = ((R-LR)*RV)*sin(-A) ;
VY[I] = -((R-LR)*RV)*cos(-A) ;
VX[I] = VX[I]+(NKVX/20) ;
VY[I] = VY[I]+(NKVY/20) ;
X[I] = SX ; Y[I] = SY ;
NX[I] = (X[I]*cos(A))-(Y[I]*sin(A)) ;
NY[I] = (X[I]*sin(A))+(Y[I]*cos(A)) ;
}
}
if ( mouseX > 50 && mouseX < 130 && mouseY > 420 && mouseY < 470 ){ RV = RV + 0.005 ; }
if ( mouseX > 150 && mouseX < 230 && mouseY > 420 && mouseY < 470 ){ RV = RV - 0.005 ; }
if ( mouseX > 250 && mouseX < 330 && mouseY > 420 && mouseY < 470 ){ LR = LR + 5 ; }
if ( mouseX > 350 && mouseX < 430 && mouseY > 420 && mouseY < 470 ){ LR = LR - 5 ; }
if ( LR < 0 ){ LR = 0 ; }
if ( LR > 2*R ){ LR = 2*R ; }
} // mousePressed()