1 / 6

Using Recursion in Graphics

Using Recursion in Graphics. Recursion can be a powerful tool Closely related to Fractals Self-similarity Keep zooming in: still looks the same Can produce very interesting figures with very little input Serpinsky Gasket is just a lot of triangles Define recursively. Serpinsky Gasket.

jamesjberry
Download Presentation

Using Recursion in Graphics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Using Recursion in Graphics • Recursion can be a powerful tool • Closely related to Fractals • Self-similarity • Keep zooming in: still looks the same • Can produce very interesting figures with very little input • Serpinsky Gasket is just a lot of triangles • Define recursively

  2. Serpinsky Gasket • Start with triangle • Then put (1/2 size) triangles within triangle

  3. Serpinsky Gasket • Continue process with ¼ sized triangles, etc • Insight: use Serpinsky Gaskets instead of triangles

  4. Rendering a Serpinsky Gasket • Mathematically, Gasket is defined for invinitely small triangle. • Goes on forever • Zoom in as far as you like: always the same picture • In drawing a Serpinsky Gasket what are the issues? • Time to draw • What can you see • How do we handle this potentially infinite recursion? • What to use as the base case? • ???

  5. Serpinsky Demo • In code directory • Using Applet • Run Serpinsky.html • Note feature to slow down drawing • Get betters sense of how recursive calls work • Also see how incredibly fast computer is… • Review recursive features • What is done in the base case? • What would figure be like if we drew nothing except • In the base case?

  6. Classwork/Lab • Will be doing two different figures recursively • Target • Circle Art • For each, will use 2 approaches • One Object: Draw Recursively • Our drawing technique will use recursion • Object Creates Other Object Recursively • Each object will create “clone” objects using new • Each of smaller size and in different positions • Will invoke the paint methods of these clones

More Related