Programming Snazzy Fractals - PowerPoint PPT Presentation

1 / 35
About This Presentation
Title:

Programming Snazzy Fractals

Description:

Programming. Snazzy Fractals. Roshanak Roshandel Adair Dingle. Department ... What is a Fractal? ... Fractals are objects that look the same regardless of the magnification. The ... – PowerPoint PPT presentation

Number of Views:132
Avg rating:3.0/5.0
Slides: 36
Provided by: informatio125
Category:

less

Transcript and Presenter's Notes

Title: Programming Snazzy Fractals


1
Programming Snazzy Fractals
  • Roshanak Roshandel Adair Dingle
  • Department of Computer Science
  • and Software Engineering
  • Seattle University

2
Euclidean Geometry
  • Triangles
  • Circles
  • Squares
  • Rectangles
  • Trapezoids
  • Pentagons
  • Hexagons
  • Octagons
  • Cylinders

3
Can we describe nature using Euclidean Geometry?
  • Tree using cylinders??
  • Mountains using triangles??
  • Clouds using circles??
  • Leaves??
  • Rocks??

4
Well
  • We can describe man made structures using
    Euclidean geometry
  • But nature is full of rough edges and non uniform
    shapes
  • Geometry of irregular shapes, non-smooth edges,
    infinite details, and infinite length

5
(No Transcript)
6
(No Transcript)
7
(No Transcript)
8
(No Transcript)
9
(No Transcript)
10
(No Transcript)
11
(No Transcript)
12
(No Transcript)
13
(No Transcript)
14
What is a Fractal?
  • Geometric figures just like circles and
    rectangles, but they also have some special
    properties
  • Structural self-similarity
  • All over nature
  • Flowers, trees, mountains, stalagmite, snow
    flakes,
  • Fractals are objects that look the same
    regardless of the magnification

15
(No Transcript)
16
The Sierpinski Triangle
  • Step 1 Draw an equilateral triangle with sides
    of 2 triangle lengths each. Connect the
    midpoints of each side.

How many shaded triangles?
How many equilateral triangles do you now have?
17
Step 2
  • Draw another equilateral triangle with sides of 4
    triangle lengths each.
  • Connect the midpoints of the sides and shade the
    triangle in the center as before.

How many shaded triangles now?
18
Step 3
How many shaded triangle now?
19
Step 4
How many shaded triangles Now? What if we keep
going?
20
The Koch Snowflake
First step
After 2 steps
21
After 3 steps
22
After n steps
23
The Koch snowflake is six of these put together
to form . . .
. . . a snowflake.
24
Notice that the perimeter of the Koch snowflake
is infinite . . .
. . . but that the area it bounds is finite
(sure enough, it is contained in the white
square).
25
Do you see a pattern?
  • We have to do something over and over and over
    again
  • Its hard!
  • Its tedious!
  • Can we get help?

26
What can computers do?
  • Computers are really good at
  • following instructions
  • processing data you provide (names, numbers,
    etc.)
  • making decisions according to rules you specify
  • repeating, repeating, repeating and repeating
  • Lets look at some examples from Python
    Programming Language

27
1) following instructions
  • Load the software (the Python interpreter) that
    will obey your commands!
  • Type 'python
  • You will see the interpreter's prompt gtgtgt
  • This prompt tells you that the interpreter is
    waiting for another command.

28
Try the Following
  • gtgtgt print "hello"
  • gtgtgt print "name" use your name
  • gtgtgt myName "name"
  • gtgtgt print "hello " myName

29
2) Processing Data You Provide
  • Let's use the Python interpreter as a calculator
    to see how it processes numbers.
  • gtgtgt38 4
  • gtgtgt23428973 345/3

30
Calculations.
  • gtgtgt x int(raw_input('Please enter an integer
    '))
  • gtgtgt y int(raw_input('Please enter an integer
    '))
  • gtgtgt x y
  • gtgtgt x y

31
3) making decisions according to rules you specify
  • gtgtgt myWord raw_input('Please input a word')
  • gtgtgt if (myWord is myName)
  • ... print "Hello, oh great master " myName
  • ... else
  • ... print myWord " is not recognized by my
    instructions"

32
4) Repeating Repeating Repeating
  • gtgtgt for i in range(1, 10)
  • ... print myName
  • gtgtgt for i in range(1, 10)
  • ... for j in range(1,5)
  • ... print myName,
  • ... print " is great!"

33
Loops
  • gtgtgt for i in range(1, 10)
  • ... print myName " is
  • ... for j in range(1,5)
  • ... print "great, ",
  • ... print "great!"

34
Function
  • Do we have to type everything all the time? Can
    we store some instructions to be used later on?
  • gtgtgt def WordCompare(someWord)
  • ... if (someWord is myName)
  • ... print "Hello, oh great master " myName
  • ... else
  • ... print someWord " is not recognized by my
    instructions"

35
Now lets do some fractal programming!
36
Resources
  • Download Python Interpreter
  • http//www.python.org
  • For this presentation go to
  • http//fac-staff.seattleu.edu/roshanak/fractals
  • Questions? Send us an email
  • roshanak_at_seattleu.edu
  • dingle_at_seattleu.edu
Write a Comment
User Comments (0)
About PowerShow.com