Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Sierpinski curve
# Construção da curva que preenche Sierpinski. it <- function(z,sinal){ # Iteração base p=matrix(0,2,4);u=z[,2]-z[,1];t=sinal*(pi/3) p[,1]=z[,1];p[,2]=p[,1]+matrix(c(cos(t),sin(t),-sin(t),cos(t)),2,2)%*%(u/2) p[,3]=p[,2]+u/2 p[,4]=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,3*length(z[1,])-2) for (j in 1:(length(z[1,])-1)){ q[,(3*j-2):(3*j+1)]=it(z[,j:(j+1)],sinal);sinal=-sinal} z=q};z } # --- Teste ----------------------------------- sinal=1 x=c(0,1) y=c(1,2) z=matrix(c(x,y),2,2) plot(x,y,'l') # Teste z=it(z,sinal);z plot(z[1,],z[2,],'l',col="yellow") z=Sierpinski(x,y,2) plot(z[1,],z[2,],'l',col="blue") z=Sierpinski(x,y,3) plot(z[1,],z[2,],'l',col="green") z=Sierpinski(x,y,8) plot(z[1,],z[2,],'l',col="red")
run
|
edit
|
history
|
help
0
Tournois Mount & Blade
4
Leap Year Finder
Polynomial Regression with Interaction
BTBsung
,k
Inter-11-03-21
Regra-trapezio
lab1
Plot Graph By Adjacency Matrix