summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/examples/PythagoreanTree.asy
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/utils/asymptote/examples/PythagoreanTree.asy')
-rw-r--r--Build/source/utils/asymptote/examples/PythagoreanTree.asy20
1 files changed, 20 insertions, 0 deletions
diff --git a/Build/source/utils/asymptote/examples/PythagoreanTree.asy b/Build/source/utils/asymptote/examples/PythagoreanTree.asy
new file mode 100644
index 00000000000..8ea66650bf3
--- /dev/null
+++ b/Build/source/utils/asymptote/examples/PythagoreanTree.asy
@@ -0,0 +1,20 @@
+size(250);
+
+real a=3;
+real b=4;
+real c=hypot(a,b);
+
+transform ta=shift(c,c)*rotate(-aCos(a/c))*scale(a/c)*shift(-c);
+transform tb=shift(0,c)*rotate(aCos(b/c))*scale(b/c);
+
+picture Pythagorean(int n) {
+ picture pic;
+ fill(pic,scale(c)*unitsquare,1/(n+1)*green+n/(n+1)*brown);
+ if(n == 0) return pic;
+ picture branch=Pythagorean(--n);
+ add(pic,ta*branch);
+ add(pic,tb*branch);
+ return pic;
+}
+
+add(Pythagorean(12));