Duke CPS 006 - Using Recursion in Graphics

Unformatted text preview:

CompSci 629.1Using 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 recursivelyCompSci 629.2Serpinsky Gasketÿ Start with triangleÿ Then put (1/2 size) triangles within triangleCompSci 629.3Serpinsky Gasketÿ Continue process with ¼ sized triangles, etcÿ Insight: use Serpinsky Gaskets instead of trianglesCompSci 629.4Rendering 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? ???CompSci 629.5Serpinsky 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?CompSci 629.6Classwork/Labÿ Will be doing two different figures recursively Target Circle Artÿ For each, will use 2 approaches1. One Object: Draw Recursively Our drawing technique will use recursion2. 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


View Full Document

Duke CPS 006 - Using Recursion in Graphics

Download Using Recursion in Graphics
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Using Recursion in Graphics and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Using Recursion in Graphics 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?