fi<-seq(from=0,to=2*pi,by=0.01); plot(sin(fi)-1,cos(fi)+pi,type="l",xlim=c(-2,2),col="blue",lwd=3,xlab="x",ylab="y",main="Pole koła"); lines(x=-pi,y=0,type="p",lwd=2) y<-rep(0,seed); x<-seq(from=0,to=2,length=seed); lines(x=c(0,0),y=c(0,5),lwd=3); lines(x=c(-3,3),y=c(h,h)); count=0; seed<-1000; h<-0; draw<-function(h) { fi<-seq(from=0,to=2*pi,by=0.01); plot(sin(fi)-1,cos(fi)+pi,type="l",xlim=c(-2,2),col="blue",lwd=3,xlab="x",ylab="y",main="Pole koła"); lines(x=-pi,y=0,type="p",lwd=2) y<-rep(0,seed); x<-seq(from=0,to=2,length=seed); lines(x=c(0,0),y=c(0,5),lwd=3); lines(x=c(-3,3),y=c(h,h)); count=0; for(i in 1:seed) { a<-2*runif(1)-2; b<-2*runif(1)+pi-1; Sys.sleep(0.01); color1<-"green"; color2<-"red"; if((a+1)^2+(b-pi)^2<1) { count=count+1; lines(x=a,y=b,type="p",col=color1); t=pi; } else { lines(x=a,y=b,type="p",col=color2); } if(i>1) { y[i]=(count/i)*4} else { y[1]=4; } lines(x,y,type="l",col="blue"); } return (y[length(y)]); } draw(pi);