Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
34
Task/Pythagoras-tree/PARI-GP/pythagoras-tree.parigp
Normal file
34
Task/Pythagoras-tree/PARI-GP/pythagoras-tree.parigp
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
\\ Pythagoras Tree (w/recursion)
|
||||
\\ 4/11/16 aev
|
||||
plotline(x1,y1,x2,y2)={plotmove(0, x1,y1);plotrline(0,x2-x1,y2-y1);}
|
||||
|
||||
pythtree(ax,ay,bx,by,d=0)={
|
||||
my(dx,dy,x3,y3,x4,y4,x5,y5);
|
||||
if(d>10, return());
|
||||
dx=bx-ax; dy=ay-by;
|
||||
x3=bx-dy; y3=by-dx;
|
||||
x4=ax-dy; y4=ay-dx;
|
||||
x5=x4+(dx-dy)\2; y5=y4-(dx+dy)\2;
|
||||
plotline(ax,ay,bx,by);
|
||||
plotline(bx,by,x3,y3);
|
||||
plotline(x3,y3,x4,y4);
|
||||
plotline(x4,y4,ax,ay);
|
||||
pythtree(x4,y4,x5,y5,d+1);
|
||||
pythtree(x5,y5,x3,y3,d+1);
|
||||
}
|
||||
|
||||
PythagorTree(x1,y1,x2,y2,depth=9,size)={
|
||||
my(dx=1,dy=0,ttlb="Pythagoras Tree, depth ",ttl=Str(ttlb,depth));
|
||||
print1(" *** ",ttl); print(", size ",size);
|
||||
print(" *** Start: ",x1,",",y1,",",x2,",",y2);
|
||||
plotinit(0);
|
||||
plotcolor(0,6); \\green
|
||||
plotscale(0, -size,size, size,0 );
|
||||
plotmove(0, 0,0);
|
||||
pythtree(x1,y1, x2,y2);
|
||||
plotdraw([0,size,size]);
|
||||
}
|
||||
|
||||
{\\ Executing:
|
||||
PythagorTree(275,500,375,500,9,640); \\PythTree1.png
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue