Duke CPS 006 - Using Recursion in Graphics

Unformatted text preview:

Using Recursion in GraphicsSerpinsky GasketSlide 3Rendering a Serpinsky GasketSerpinsky DemoClasswork/LabCompSci 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?