Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Sierpinski curve square
# Construção da curva que preenche o tapete Sierpinski. it <- function(z){ # Iteração base p=matrix(0,2,12);u=(z[,2]-z[,1])/3;t=pi/2 v=matrix(c(cos(t),sin(t),-sin(t),cos(t)),2,2)%*%u p[,1]=z[,1]; p[,2]=p[,1]+u; p[,3]=p[,2]+v; p[,4]=p[,3]+u; p[,5]=p[,4]-v; p[,6]=p[,5]-v; p[,7]=p[,6]-u; p[,8]=p[,7]+v; p[,9]=p[,8]+v; p[,10]=p[,9]+u; p[,11]=p[,10]-v; p[,12]=z[,2];p} Sierpinski<-function(x,y,m){ # Replicação da iteração base. z=matrix(c(x,y),2,2) for ( i in 1:m){ q=matrix(0,2,12*length(z[1,])-12) for (j in 1:(length(z[1,])-1)){ q[,(12*j-11):(12*j)]=it(z[,j:(j+1)]);} z=q};z } # --- Teste ----------------------------------- sinal=1 x=c(0,0) y=c(1,1) z=matrix(c(x,y),2,2) z=it(z);z plot(z[1,],z[2,],'l') z=Sierpinski(x,y,4); plot(z[1,],z[2,],'l',col="red",axes=FALSE) w=matrix(c(0,0,1,0,1,1,0,1),2,8);points(w[1,],w[2,],'l')
run
|
edit
|
history
|
help
0
Mathematical operations
histograms for survey stats and fats
Simple Examples in ggplot2
19-08-2020-GaussSeidelSistema-menos-calc
Gab1A
19-08-2020-JacobiSistemaEuler
Zama Mohammed Fahad
US births
%95 Confidence Interval
My R Code Practice