Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
33
Task/Fractal-tree/PARI-GP/fractal-tree.parigp
Normal file
33
Task/Fractal-tree/PARI-GP/fractal-tree.parigp
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
\\ Fractal tree (w/recursion)
|
||||
\\ 4/10/16 aev
|
||||
plotline(x1,y1,x2,y2)={plotmove(0, x1,y1);plotrline(0,x2-x1,y2-y1);}
|
||||
|
||||
plottree(x,y,a,d)={
|
||||
my(x2,y2,d2r=Pi/180.0,a1=a*d2r,d1);
|
||||
if(d<=0, return(););
|
||||
if(d>0, d1=d*10.0;
|
||||
x2=x+cos(a1)*d1;
|
||||
y2=y+sin(a1)*d1;
|
||||
plotline(x,y,x2,y2);
|
||||
plottree(x2,y2,a-20,d-1);
|
||||
plottree(x2,y2,a+20,d-1),
|
||||
return();
|
||||
);
|
||||
}
|
||||
|
||||
FractalTree(depth,size)={
|
||||
my(dx=1,dy=0,ttlb="Fractal Tree, depth ",ttl=Str(ttlb,depth));
|
||||
print1(" *** ",ttl); print(", size ",size);
|
||||
plotinit(0);
|
||||
plotcolor(0,6); \\green
|
||||
plotscale(0, -size,size, 0,size);
|
||||
plotmove(0, 0,0);
|
||||
plottree(0,0,90,depth);
|
||||
plotdraw([0,size,size]);
|
||||
}
|
||||
|
||||
{\\ Executing:
|
||||
FractalTree(9,500); \\FracTree1.png
|
||||
FractalTree(12,1100); \\FracTree2.png
|
||||
FractalTree(15,1500); \\FracTree3.png
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue