+ All Categories
Home > Documents > Programming)) Snazzy)Fractals)) - Seattle...

Programming)) Snazzy)Fractals)) - Seattle...

Date post: 28-Jun-2020
Category:
Upload: others
View: 12 times
Download: 0 times
Share this document with a friend
32
Programming Snazzy Fractals Roshanak Roshandell Department of Computer Science and So<ware Engineering Sea$le University Seattle Expanding Your Horizons
Transcript
Page 1: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))

Programming    Snazzy  Fractals    

Roshanak  Roshandell    

Department  of  Computer  Science    and  So<ware  Engineering  

 Sea$le  University  

Seattle Expanding Your Horizons

Page 2: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))

Euclidean  Geometry  

n  Triangles  n  Circles  n  Squares  n  Rectangles  n  Trapezoids  n  Pentagons  n Hexagons  n Octagons  n  Cylinders  

Page 3: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))

Can  We  Describe  Nature  Using  Euclidean  Geometry?    

n  Tree    n  cylinders  

n Mountains  n  triangles  

n  Clouds  n  circles  

n  Leaves  n  Rocks    

Page 4: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))

Well…  

n We  can  describe  man  made  structures  using  Euclidean  geometry  

n  But  nature  is  full  of  rough  edges  and  non  uniform  shapes  

n Geometry  of  irregular  shapes,  non-­‐smooth  edges,  infinite  details,  and  infinite  length  

n  Fractal  geometry  is  the  formula  of  nature!  

Page 5: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))
Page 6: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))
Page 7: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))

Let’s  Watch!  

n  Fractal  Zoom  –  Mandelbrot  n AnimaWon  n AnimaWon  n  Flying  in  Fractal  Mountain  

Page 8: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))
Page 9: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))
Page 10: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))
Page 11: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))
Page 12: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))
Page 13: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))

What  is  a  Fractal?  

n Geometric  figures  just  like  circles  and  rectangles,  but  they  also  have  some  special  properWes  

n  Structural  self-­‐similarity    n  All  over  nature  

n  Flowers,  trees,  mountains,  stalagmite,  snow  flakes,  …  

n  Fractals  are  objects  that  look  the  same  regardless  of  the  magnificaWon  

Page 14: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))

Why  Should  You  Care  about  Fractals?  

n  Fractal  Landscape  n Movies  (e.g.,  Star  Trek)  n  Computer  Graphics  n  Computer  and  video  games  

n Medicine  n  Fractal  art  and  music  n Where  can  you  find  fractals?  

n  Bacteria  cultures  n  Galaxies  n  Your  own  body!  

Page 15: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))

The  Koch  Snowflake  

43

Length =

1Length =

2

43

Length =⎛ ⎞⎜ ⎟⎝ ⎠

First step

After 2 steps

Page 16: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))

A<er  3  Steps  

Page 17: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))

A<er  n  Steps  

43

n

Length =⎛ ⎞⎜ ⎟⎝ ⎠

Page 18: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))

Well,  The  Snowflake  

n  Koch  Snowflake  is  6  of  these  put  together  

Page 19: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))

Did  You  NoWce….    

n  The  perimeter  of  the  Koch  snowflake  is  infinite  ...  n  but  that  the  area  it  bounds  is  finite    (sure  enough,  it  is  contained  in  the  white  square).  

Page 20: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))

Do  You  See  a  Paaern?  

n We  have  to  do  something  over  and  over  and  over  again  n  It’s  hard!  n  It’s  tedious!  

n  Can  we  get  help?  

Page 21: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))

What  Can  Computers  Do?  

n  Computers  are  really  good  at:  1.  Following  instrucWons  2.  Processing  data  you  provide  (names,  numbers,  etc.)    3.  Making  decisions  according  to  rules  you  specify  4.  RepeaWng,  repeaWng,  repeaWng  and  repeaWng    

n  Let’s  look  at  some  examples  from  Python  Programming  Language  

Page 22: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))

1)  Following  InstrucWons  

n  Load  the  so<ware  (the  Python  interpreter)  that  will  obey  your  commands!  

n  Find  the  shortcut  to  Python  on  your  desktops.  n  You  will  see  the  interpreter's  prompt:  >>>    

This  prompt  tells  you  that  the  interpreter  is  waiWng  for  another  command.  

Page 23: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))

Try  the  Following  

>>> print "hello” >>> print "Emily"

>>> theName = "Emily”

>>> print "hello " + theName

Page 24: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))

2)  Processing  Data  You  Provide  

n  Let's  use  the  Python  interpreter  as  a  calculator  to  see  how  it  processes  numbers.  

>>> 3*8 + 4 >>> 2342*8973 + 345/3

Page 25: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))

CalculaWons….  

>>> x = int(raw_input(‘Enter number: ')) >>> 56 >>> y = int(raw_input(‘Enter number: ')) >>> 12 >>> x * y >>> x + y

Page 26: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))

3)  Making  Decisions  According  to  Rules  You  Specify  

>>> theWord = raw_input(‘Enter a word:') >>> if (theWord is theName): ... print “Hello Master " + theName ... else: ... print “ Who are you?"

Tab

Page 27: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))

4)  RepeaWng,  RepeaWng  and  RepeaWng  

>>> for i in range(1, 100): ... print theName >>> for i in range(1, 10): ... for j in range(1,5): ... print theName, ... print " is great!"

1 Tab 2 Tabs

Page 28: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))

Advanced  Loops  

>>> for i in range(1, 10): ... print theName + " is " ... for j in range(1,5): ... print “cool, ", ... print “cool!"

Page 29: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))

FuncWon  

n  Do  we  have  to  type  everything  all  the  Wme?  Can  we  store  some  instrucWons  to  be  used  later  on?  

n  >>> def WordCompare(someWord): ... if (someWord is myName): ... print "Hello, oh great master " +myName

n  ... else: n  ... print someWord + " is not recognized"

Page 30: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))

Now  Let’s  do  Some  Fractal  Programming!  

Page 31: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))

Resources  

n Download  Python  Interpreter:  n  hap://www.python.org  

n For  this  presentaWon  go  to:  n  hap://fac-­‐staff.seaaleu.edu/roshanak/fractals  

n QuesWons?  Send  me  an  email:  n  [email protected]  

Page 32: Programming)) Snazzy)Fractals)) - Seattle Universityfac-staff.seattleu.edu/roshanak/web/fractals/Fractals.pdf · Programming)) Snazzy)Fractals)) Roshanak)Roshandell)) Departmentof)Computer)Science))

THANK  You!  

Hope  you  had  an  awesome  Wme!  J  


Recommended