Posted On: Monday, August 21, 2017 at 2:43 PM Last updated: Wednesday, August 23, 2017 at 5:47 AM

plotftree <- function(x, y, a, d, c) {

x2=y2=0; d2r=pi/180.0; a1 <- a*d2r; d1=0;

if(d<=0) {return()}

if(d>0)

{ d1=d*10.0;

x2=x+cos(a1)*d1;

y2=y+sin(a1)*d1;

segments(x*c, y*c, x2*c, y2*c, col='pink', lwd=2);

plotftree(x2,y2,a-20,d-1,c);

plotftree(x2,y2,a+20,d-1,c);

}

}

pFractalTree <- function(ord, c=1, xsh=0, fn="", ttl="") {

m=640;

plot(NA, xlim=c(0,m), ylim=c(-m,0), xlab="", ylab="", main=ttl);

plot(NA, xlim=c(0,m), ylim=c(0,m), xlab="", ylab="", main=ttl);

plotftree(m/2+xsh,100,90,ord,c);

}

pFractalTree(9);

pFractalTree(12,0.6,220);