
Turtles and Fractals Ron Goldman Department of Computer Science Rice University Fractals Sierpinski Triangle Fractal Swiss Flag Koch Snowflake C-Curve Basic Turtle Programs POLY (Length, Angle) Repeat Forever FORWARD (Length) TURN (Angle) SPIRAL (Length, Angle, Scalefactor) Repeat Forever FORWARD (Length) TURN (Angle) RESIZE (Scalefactor) Propositions POLY Proposition The vertices generated by the POLY program lie on a circle. SPIRAL Proposition The vertices generated by the SPIRAL program lie on a spiral. Examples of POLY Procedures Angle = π / 5 Angle = 3π / 7 Angle = π 2 / 2 € € € Proof of POLY Proposition F A • G α β A L • L E α R •α R € x = R L R •C α D • ΔCDE ≅ ΔCEF (SSS) A + β +α = A +α +α ⇒ β = α ΔCEF ≅ ΔCFG (SAS) ∴ x = R € Looping Lemmas Circle Looping Lemma Any procedure that is a repetition of the same collection of FORWARD and TURN commands has the structure of POLY(Length, Angle), where Angle = Total Turning within the Loop Length = Total Distance traveled within the Loop That is, the two programs have the same boundedness, closing, and symmetry. In particular, if Angle ≠ 2πk for some integer k, then all the vertices generated by the same FORWARD command inside the loop lie on a common circle. € Looping Lemmas (continued) Spiral Looping Lemma Any procedure that is a repetition of the same collection of FORWARD, TURN, and RESIZE commands has the structure of SPIRAL(Length, Angle, Scalefactor), where Angle = Total Turning within the Loop Length = Total Distance traveled within the Loop Scalefactor = Total Scaling within the Loop That is, the two programs have the same boundedness and symmetry. In particular, if Angle ≠ 2πk for some integer k, and Scalefactor ≠ ±1, then all the vertices generated by the same FORWARD command inside the loop lie on a common spiral. € € Looping Program and Polygon Procedure • Looping Pr ogram Polygon Procedure • • Looping Pr ogram Sample Looping Program WALK Repeat Forever FORWARD 1 TURN π / 3 FORWARD 1/ 4 TURN / 4 € π FORWARD 1/ 3 € TURN / 2 € −π FORWARD 3/5 € TURN /6 € π € € Looping Curve More Sample Looping Program PolySpiral Repeat 20 Spin[2π /20 Scale[1.01 Poly[5, 2 /5] € π ]]] StarSpiral € Repeat 20 Spin[2π /20 Scale[1.1 Poly[5, 4 /5] € π ]]] € Looping Spirals PolySpiral StarSpiral Recursion Problem: How can we generate more interesting shapes from turtle programs? Solution: Recursion Fractals: Recursion made visible. Motivation for Fractals Representing Natural Objects • Snowflakes, Mountains, Trees K Drawing Interesting Pictures Exploring Novel Mathematics Performing Data Compression Fractal Curves and Turtle Programs Fractal Curves • Fractal curves usually cannot be represented by simple analytic expressions. • Fractal curves are generally defined by -- Recursive Procedures -- Iterated Transformations -- Infinite Series Turtle Programs • Recursion is used to express self-similarity. • Coordinates are irrelevant to shape. • Turtle programs are easily translated into fractal programs. Examples • Fractal Gaskets • Bump Fractals • Other Self-Similar Fractals Sierpinski Gasket Sierpinski Gasket Main Idea • Make a smaller Sierpinski gasket at one of the corners. • Then move to another corner and make another small Sierpinski gasket. • Then move to another corner and make another small Sierpinski gasket. • Then return the turtle to its initial position and heading. Recursive Turtle Program Sierpinski(Level) If Level = 0, Draw a Triangle Else Repeat 3 Times RESIZE 1/2 Sierpinski(Level–1) RESIZE 2 MOVE 1 TURN 2π /3 € More Fractal Gaskets Pentagonal Gasket Fractal Swiss Flag Rectangular Gasket Koch Curve Koch Bump Koch Curve Koch Curve Basic Idea • Make a smaller Koch curve along the first edge of the bump. • Then move to the next edge and make another small Koch curve. • Then move to the next edge and make another small Koch curve. • Then move to the next edge and make another small Koch curve. Simpler Approach • Replace each straight line on the bump by a Koch curve. • Replace each FORWARD command by a recursive call. Koch Curve Koch Bump Koch(Level) If Level = 0, FORWARD 1 Else RESIZE 1/3 → RESIZE 1/3 FORWARD 1 → Koch(Level-1) TURN 60 → TURN 60 FORWARD 1 → Koch(Level-1) TURN −120 → TURN −120 FORWARD 1 → Koch(Level-1) TURN 60 → TURN 60 FORWARD 1 → Koch(Level-1) RESIZE 3 → RESIZE 3 Universal Bump–Fractal Program Bump Bump_Fractal(Level) If Level = 0, FORWARD 1 Else TURN A1 TURN A1 RESIZE S1 → RESIZE S1 FORWARD 1 → Bump_Fractal(Level −1) TURN A2 → TURN A2 €R ESIZE S2 → €R ESIZE S2 FORWARD 1 → Bum€p_F ractal(Level −1) € € € M € M FORWARD 1 → Bump_Fractal(Level −1) € RESIZE Sn+1 → RESIZE Sn+1 TURN An+1 → TURN An+1 € € € € € Typical Bump Assumptions 1. Turtle Final Orientation = Turtle Initial Orientation • Total Turning = 0 n+1 • ∑ Ak = 0 k=1 2. Turtle Returns to Initial Line € • Total Y–Distance = 0 n k • ∑ SkSin ∑ Aj = 0 k=1 j=1 3. Turtle Travels Distance=Size Along Initial Line € • Total X–Distance = Size n k • ∑ SkCos ∑ Aj =1 k=1 j=1 € C–Curve C-Bump C-Curve C–Curve Bump C(Level) If Level = 0, FORWARD 1 Else TURN 45 → TURN 45 2 2 RESIZE → RESIZE 2 2 FORWARD 1 → C(Level −1) TURN −90 → TURN −90 € € FORWARD 1 → C(Level −1) TURN 45 →€ TURN 45 RESIZE 2 → RESIZE 2 € € € More Bumps on Bumps Additional Examples • Rectangular Bumps • Pentagonal Bumps • Space Filling Curves Additional Extensions • Scales and Angles can be selected randomly. • Each FORWARD command can be replaced by a different FRACTAL program. • Fractal programs can be connected with TURN and FORWARD transitions. More Self-Similar Fractals Fractal Hangman Fractal Bush Fractal Tree More Self-Similar Fractals Fractal Star Fractal Flower Fractal Leaf.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages29 Page
-
File Size-