# Script: Pythagoras tree

## Script

#===================== # Define auxiliar tool #===================== A =(0, 0) B = (4, 0) base = Polygon(A, B, 4) E = Midpoint(C, D) arc = Semicircle(D, C) F = Point(arc) α = Angle(C, E, F) C' = Rotate(C, α, E) C'_1 = Rotate(C, α, E) pointsBase = {D, C', C'_1, C} ShowExtra = false SetConditionToShowObject(A, ShowExtra) SetConditionToShowObject(B, ShowExtra) #SetConditionToShowObject(base, ShowExtra) SetConditionToShowObject(C, ShowExtra) SetConditionToShowObject(D, ShowExtra) SetConditionToShowObject(E, ShowExtra) SetConditionToShowObject(arc, ShowExtra) #SetConditionToShowObject(F, ShowExtra) SetConditionToShowObject(α, ShowExtra) SetConditionToShowObject(C', ShowExtra) SetConditionToShowObject(C'_1, ShowExtra) SetConditionToShowObject(pointsBase, ShowExtra) # In this case I defined the tool as: # BasePoints( , , ) #===================== # Construction begins #===================== N = 7 M = Slider(1, N, 1, 1, 160, false, true, false, false) SetValue(M, N) Lm = Sequence(1, M) LN = Sequence(1, N) Sname = Zip("S" + Text(n), n, LN) Execute(Zip(name " = Sequence(k, k, 1, 2^("+(n+1)+"), 2)", name, Sname, n, LN )) LK = Remove(LN, {1}) Tname = Zip("T" + Text(n), n, LK) Execute(Zip(name " = Sequence(k, k, 1, 2^("+(n+1)+"), 4)", name, Tname, n, LK )) #===================== # Points #===================== Execute( Join( {"points1 = BasePoints(A, B, α)"}, Zip( "points"+(n+1)+" = Join(Zip(BasePoints(Element(points"+(n)+", k), Element(points"+(n)+", k + 1), α), k, S"+n+")) ", n, LN) ) ) SetVisibleInView(points8, 1, false) #===================== # Squares #===================== Execute(Zip( "squares"+n+" = Zip(Polygon(Element(points"+n+", k), Element(points"+n+", k + 1), 4), k, S"+n+")", n, LN)) #===================== # Triangles #===================== triangles1 = Polygon(points1) Execute( Zip( "triangles"+(n)+" = Zip(Polygon(Element(points"+(n)+", k), Element(points"+(n)+", k + 1), Element(points"+(n)+", k + 3)), k, T"+(n)+")", n, LK) ) #========================= # Settings. Let's make it pretty :-) #========================= SetVisibleInView(Sname, 1, false) SetVisibleInView(Tname, 1, false) Execute(Zip("SetVisibleInView(S"+k+", 1, false)", k, LN)) Execute(Zip("SetVisibleInView(T"+k+", 1, false)", k, LK)) Execute(Zip("SetConditionToShowObject(points"+k+", "+k+"<=M)", k, LN)) Execute(Zip("SetConditionToShowObject(squares"+k+", "+k+"<=M)", k, LN)) Execute(Zip("SetConditionToShowObject(triangles"+k+", "+k+"<=M)", k, LN)) #==================================================== # Maybe there is an easier way to do this. # What do you think Thijs? # See this thread for details #====================================================