SlideShare uma empresa Scribd logo
1 de 59
VA3520

Evolutionary Graphics
Class 03: Recursion
Thinking Recursively
Money example

If you want to collect $1,000 from your BU
classmates, and each of the student can only

afford to give you $10, how would you do?
Method 1

The first method is a traditional thinking mode.
You can approach every student you meet and

ask him/her to donate $10.
Iterative approach

We call this – iterative approach. It is similar to a
loop in computer programming. You continue to

ask students for $10 until you reach the target of
$1,000.
Iterative approach

while (money collected < $1,000) {
meet next student;
ask for $10 donation;

if (ok)
add to the money collected;
}
Other approach

The iterative approach is straight forward and
effective. We can ask if there are any better

approaches to this problem.
Recursive approach

It is not very efficient if I need to ask 100 students
to collect the $1,000.
Consider the case: I just ask 10 students to
collect money for me. Each of them has to collect

$100 by whatever means.
Recursive approach

Then the 10 students will concurrently go out to
ask 10 or more students to collect $10 each from

them.
Recursive approach

$1000

$100

$100

$10

$10

...

$100

$10

$100

...

$10
Divide and conquer

Divide and conquer
1. Decompose the original problem into simpler
instances of the same problem.
2. The simpler problems must become so simple that

they can be solved without further division.
3. Combine the smaller solutions to produce a solution
to the original problem.
Piet Mondrian
Blank canvas
Problem statement

We want to divide a rectangle into a square and
a smaller rectangle. Continue to divide the

smaller rectangle until it is too small to be visible
on screen.
First division
The process

Note that, the second division will be the same
as the first one, except the rectangle rotates by

90 degrees counter-clockwise.
Second division
Third division
Forth division
Fifth division
The process

Note that, the second division will be the same
as the first one, except the rectangle rotates by

90 degrees counter-clockwise.
Fibonacci numbers

We go back to the study of the Fibonacci
numbers. Remember,
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, …

If we denote, f(1) = 1, f(2) = 1, f(3) = 2, f(4) =
3, f(5) = 5, …, how can we write down a general
formula for f(n)?
Fibonacci numbers

It is not easy for us to write down a formula like,

f(n) = (n + ?) / ???
It is much more easy for us to

write, however, with this format.
What is the relation among: f(n), f(n-1), f(n-2)?
Recursive definition

It is obviously we can write down,

f(n) = f(n-1) + f(n-2)
Initial conditions

In order to find out any f(n) by the following
formula,
f(n) = f(n-1) + f(n-2)

We must have two initial conditions. That is
f(1) = 1
f(2) = 1
Golden section in practice
Golden section in CFA

There are multiple ways in Context Free Art to
draw the Golden Section. We compare the

iterative and the recursive ways.
Iterative golden section

startshape Golden
shape Golden {

drawRectangle []
}
shape drawRectangle {
SQUARE [s 1.61803399 1]
}
Iterative golden section
Iterative golden section

startshape Golden
shape Golden {

rectangle []
}
shape rectangle {
drawRectangle [a -0.8]
}
shape drawRectangle {
SQUARE [s 1.61803399 1]

}
Iterative golden section
Iterative golden section

startshape Golden
shape Golden {

loop 2 [s 0.61803399 r -90 x 0.5] rectangle []
}
shape rectangle {
drawRectangle [a -0.8]
}
shape drawRectangle {
SQUARE [s 1.61803399 1]

}
Iterative golden section
Iterative golden section

startshape Golden
shape Golden {

loop 10 [s 0.61803399 r -90 x 0.5] rectangle []
}
shape rectangle {
drawRectangle [a -0.8]
}
shape drawRectangle {
SQUARE [s 1.61803399 1]

}
Iterative golden section
Recursive golden section

startshape Golden
shape Golden {

rectangle []
}
shape rectangle {
drawRectangle [a -0.8]
}
shape drawRectangle {
SQUARE [s 1.61803399 1]

}
Recursive golden section
Recursive definition

shape rectangle {
drawRectangle [a -0.8]
rectangle [?]

}

Note that we enter into a difficult situation. The
rule rectangle refers back to itself. It seems to go
into an infinite loop again and again when we
have to execute the rectangle definition.
Recursive definition

shape rectangle {
drawRectangle [a -0.8]
rectangle [?]

}

In order to let the Context Free Art stop, we have
to make sure that each time the rectangle is
drawn, it has to be smaller and smaller until it is
invisible on screen. Alternately, we have to add
another definition for rectangle to stop referring
itself.
Recursive definition

shape rectangle {
drawRectangle [a -0.8]
rectangle [s 0.61803399 r -90 x 0.5]

}

Let’s try out this.
Recursive definition

startshape Golden
shape Golden {

rectangle []
}
shape rectangle {
drawRectangle [a -0.8]
rectangle [s 0.61803399 r -90 x 0.5]
}
shape drawRectangle {

SQUARE [s 1.61803399 1]
}
Recursive golden section
Recursive example

startshapeMyShape
shape MyShape {

Shape1 []
}
shape Shape1 {
CIRCLE [sat 1 b 1]
}
Recursive example
Recursive example

startshapeMyShape
shape MyShape {

Shape1 []
MyShape [x 1 s 0.99]
}
shape Shape1 {
CIRCLE [sat 1 b 1]
}
Recursive example
Recursive example

startshapeMyShape
rule MyShape {

Shape1 []
MyShape [x 1 r 51 s 0.99]
}
shape Shape1 {
CIRCLE [sat 1 b 1]
}
Recursive example
Recursive example

startshapeMyShape
shape MyShape {

Shape1 []
MyShape [x 1 r 51 s 0.99 h 51]
}
shape Shape1 {
CIRCLE [sat 1 b 1]
}
Recursive example
Spiral example
Spiral example

startshapeMyShape
CF::Background = [b -1]
shape MyShape {
Shape1 []
}
shape Shape1 {
Shape1 [s .95 x 2 r 12 b .5 hue 10 sat 1]
Block []
}

shape Block {
CIRCLE []
}
Spiral example

startshapeMyShape
CF::Background = [b -1]
shape MyShape {
loop 4 [r 90] Shape1 []
}
shape Shape1 {
Shape1 [s .95 x 2 r 12 b .5 hue 10 sat 1]
Block []
}

shape Block {
CIRCLE []
}
Spiral example
Spiral example

startshapeMyShape
CF::Background = [b -1]
shape MyShape {
loop 2 [r 180] Shape1 []
}
shape Shape1 {
Shape1 [s 0.95 x 2 r 12 b 0.5 hue 10 sat 1]
Block []
}

shape Block {
CIRCLE []
MyShape [s 0.25]
}
Spiral example
Spiral example

startshapeMyShape
CF::Background = [b -1]
shape MyShape {
loop 2 [r 180] Shape1 [x -2 flip 45]
}
shape Shape1 {
Shape1 [s 0.95 x 2 r 12 b 0.5 hue 10 sat 1]
Block []
}

shape Block {
CIRCLE []
MyShape [s 0.25 flip 45]
}
Spiral example
More example

Mais conteúdo relacionado

Semelhante a Evolutionary Graphics - Class 03 2014

Sem-2_Roundings concept. Details..details description about
Sem-2_Roundings concept. Details..details description aboutSem-2_Roundings concept. Details..details description about
Sem-2_Roundings concept. Details..details description about
Mukul Maity
 
Practice questions and tips in business mathematics
Practice questions and tips in business mathematicsPractice questions and tips in business mathematics
Practice questions and tips in business mathematics
Dr. Trilok Kumar Jain
 
Practice questions and tips in business mathematics
Practice questions and tips in business mathematicsPractice questions and tips in business mathematics
Practice questions and tips in business mathematics
Dr. Trilok Kumar Jain
 
Circles(1)
Circles(1)Circles(1)
Circles(1)
harlie90
 
Surface Area_Volume of Solid Figures.ppt
Surface Area_Volume of Solid Figures.pptSurface Area_Volume of Solid Figures.ppt
Surface Area_Volume of Solid Figures.ppt
LuisSalenga1
 

Semelhante a Evolutionary Graphics - Class 03 2014 (20)

Management Aptitude Test 18 Nov Ii
Management Aptitude Test 18 Nov IiManagement Aptitude Test 18 Nov Ii
Management Aptitude Test 18 Nov Ii
 
Management Aptitude Test 18 Nov
Management Aptitude Test 18 NovManagement Aptitude Test 18 Nov
Management Aptitude Test 18 Nov
 
Sem-2_Roundings concept. Details..details description about
Sem-2_Roundings concept. Details..details description aboutSem-2_Roundings concept. Details..details description about
Sem-2_Roundings concept. Details..details description about
 
Math tricks
Math tricksMath tricks
Math tricks
 
Practice questions and tips in business mathematics
Practice questions and tips in business mathematicsPractice questions and tips in business mathematics
Practice questions and tips in business mathematics
 
Practice questions and tips in business mathematics
Practice questions and tips in business mathematicsPractice questions and tips in business mathematics
Practice questions and tips in business mathematics
 
FS Maths Leve 2 - March 06, 2023 (Rounding and estimating, BIDMAS)1
FS Maths Leve 2 - March 06, 2023 (Rounding and estimating, BIDMAS)1FS Maths Leve 2 - March 06, 2023 (Rounding and estimating, BIDMAS)1
FS Maths Leve 2 - March 06, 2023 (Rounding and estimating, BIDMAS)1
 
Circles(1)
Circles(1)Circles(1)
Circles(1)
 
Maths T5 W2
Maths T5 W2Maths T5 W2
Maths T5 W2
 
Square
SquareSquare
Square
 
Dino's DEV Project
Dino's DEV ProjectDino's DEV Project
Dino's DEV Project
 
Dino's DEV Project
Dino's DEV ProjectDino's DEV Project
Dino's DEV Project
 
Vedic maths 2
Vedic maths 2Vedic maths 2
Vedic maths 2
 
FS Maths Level 2 - April 8, 2023 (Angles, Circles, 2D shapes area and perimet...
FS Maths Level 2 - April 8, 2023 (Angles, Circles, 2D shapes area and perimet...FS Maths Level 2 - April 8, 2023 (Angles, Circles, 2D shapes area and perimet...
FS Maths Level 2 - April 8, 2023 (Angles, Circles, 2D shapes area and perimet...
 
FS Maths Level 2 – May 13, 2023 (Angles, Circles, 2D shapes (area and perimet...
FS Maths Level 2 – May 13, 2023 (Angles, Circles, 2D shapes (area and perimet...FS Maths Level 2 – May 13, 2023 (Angles, Circles, 2D shapes (area and perimet...
FS Maths Level 2 – May 13, 2023 (Angles, Circles, 2D shapes (area and perimet...
 
FS Maths Level 2 - April 8, 2023 (Angles, Circles, 2D shapes area and perimet...
FS Maths Level 2 - April 8, 2023 (Angles, Circles, 2D shapes area and perimet...FS Maths Level 2 - April 8, 2023 (Angles, Circles, 2D shapes area and perimet...
FS Maths Level 2 - April 8, 2023 (Angles, Circles, 2D shapes area and perimet...
 
Surface Area_Volume of Solid Figures.ppt
Surface Area_Volume of Solid Figures.pptSurface Area_Volume of Solid Figures.ppt
Surface Area_Volume of Solid Figures.ppt
 
Nossi ch 2
Nossi ch 2Nossi ch 2
Nossi ch 2
 
midterm10_sol.pdf
midterm10_sol.pdfmidterm10_sol.pdf
midterm10_sol.pdf
 
Unit-1 Basic Concept of Algorithm.pptx
Unit-1 Basic Concept of Algorithm.pptxUnit-1 Basic Concept of Algorithm.pptx
Unit-1 Basic Concept of Algorithm.pptx
 

Mais de Bryan Chung

Mais de Bryan Chung (20)

Be a Hong Kong Patriot, Part 3, The Red Scout
Be a Hong Kong Patriot, Part 3, The Red ScoutBe a Hong Kong Patriot, Part 3, The Red Scout
Be a Hong Kong Patriot, Part 3, The Red Scout
 
Fiction and Film
Fiction and FilmFiction and Film
Fiction and Film
 
MAVA Information Seminar 2019
MAVA Information Seminar 2019MAVA Information Seminar 2019
MAVA Information Seminar 2019
 
MAVA Studio Project Introduction 2018
MAVA Studio Project Introduction 2018MAVA Studio Project Introduction 2018
MAVA Studio Project Introduction 2018
 
MAVA Orientation 2018
MAVA Orientation 2018MAVA Orientation 2018
MAVA Orientation 2018
 
Class 11 - Social impacts of videogames
Class 11 - Social impacts of videogamesClass 11 - Social impacts of videogames
Class 11 - Social impacts of videogames
 
Class 10 - Simulation games
Class 10 - Simulation gamesClass 10 - Simulation games
Class 10 - Simulation games
 
Class 12 - Videogames technology in art
Class 12 - Videogames technology in artClass 12 - Videogames technology in art
Class 12 - Videogames technology in art
 
Glass 09 - Online game and virtual environment
Glass 09 - Online game and virtual environmentGlass 09 - Online game and virtual environment
Glass 09 - Online game and virtual environment
 
Class 07 - Game and space
Class 07 - Game and spaceClass 07 - Game and space
Class 07 - Game and space
 
Class 06 - Game and narrative
Class 06 - Game and narrativeClass 06 - Game and narrative
Class 06 - Game and narrative
 
Class 02 - Interactivity, games and arts
Class 02 - Interactivity, games and artsClass 02 - Interactivity, games and arts
Class 02 - Interactivity, games and arts
 
Class 01 - Introduction to Videogames and Arts
Class 01 - Introduction to Videogames and ArtsClass 01 - Introduction to Videogames and Arts
Class 01 - Introduction to Videogames and Arts
 
Digital Art ToolKit
Digital Art ToolKitDigital Art ToolKit
Digital Art ToolKit
 
Digital Image Workshop
Digital Image WorkshopDigital Image Workshop
Digital Image Workshop
 
Class 03 - Formal Elements of Game/Play
Class 03 - Formal Elements of Game/PlayClass 03 - Formal Elements of Game/Play
Class 03 - Formal Elements of Game/Play
 
Class 05 - Art Game and Game Art
Class 05 - Art Game and Game ArtClass 05 - Art Game and Game Art
Class 05 - Art Game and Game Art
 
Augmented Reality and Visual Arts
Augmented Reality and Visual ArtsAugmented Reality and Visual Arts
Augmented Reality and Visual Arts
 
Movement in Space Project Launch Seminar
Movement in Space Project Launch SeminarMovement in Space Project Launch Seminar
Movement in Space Project Launch Seminar
 
Design for Hypermedia - Class 08 (2015B)
Design for Hypermedia - Class 08 (2015B)Design for Hypermedia - Class 08 (2015B)
Design for Hypermedia - Class 08 (2015B)
 

Último

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 

Último (20)

ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 

Evolutionary Graphics - Class 03 2014