java tree fractals

27
Tree Fractals The Walker School APCSA 1

Upload: tcooper66

Post on 15-Jul-2015

203 views

Category:

Education


5 download

TRANSCRIPT

Page 1: Java tree fractals

Tree Fractals

The Walker School

APCSA

1

Page 2: Java tree fractals

2

What is a Fractal?

• Geometric object

• Self-similar across scale

• The exhibit roughness

• Recursive definition

Page 3: Java tree fractals

3

Fractal Geometry

• Infinite + finite

• Simple becomes complex

Page 4: Java tree fractals

Where do we find fractals in nature?

Page 5: Java tree fractals

Everywhere!

Page 6: Java tree fractals

Tree Fractals

6

Page 7: Java tree fractals

7

1 + 2(1/2) + 4(1/4) + 8(1/8) + ... = ∞

Length: 1

Length: 0.5

Infinite length in a finite area!

Page 8: Java tree fractals

8

Simple process

Complex result

Page 9: Java tree fractals

9

Recursive Definition

• Define something in terms of itself

• Tree: a trunk with two subtrees at the top

Page 10: Java tree fractals

10

Designing recursion requires...

Assumption(Leap of Faith)

Page 11: Java tree fractals

Pseudocode Algorithm

• Draw the trunk

• Draw the two subtrees

• Go back to the base of the trunk

11

Page 12: Java tree fractals

Pseudocode Algorithm

• Draw the trunk

• Draw the two subtrees

• Go back to the base of the trunk

12

Page 13: Java tree fractals

Java Code

• A method that calls itself

• How to stop from going forever?

13

Page 14: Java tree fractals

Java Code

• Base case

• Recursion “bottoms out”

• Must use arguments to manage this

14

Page 15: Java tree fractals

Better Pseudocode

• To draw a tree of depth n and trunk size x:

–if depth is 1:

•Draw a trunk of length x

–else:

•Draw a trunk of length x

•Draw two trees of depth (n-1) and trunk size (x/2)

–Go back to the base of the trunk

15

Page 16: Java tree fractals

Basic Tree

16

Page 17: Java tree fractals

Unit Circle

0

-90

90

180

X

Y sinθ = y/1 = y

cosθ = x/1 = x

(x,y)(x,y)

Page 18: Java tree fractals

Recursive Method

Method Call

Page 19: Java tree fractals

Angles and Length

19

Page 20: Java tree fractals

Colors

20

Page 21: Java tree fractals

Forests

21

Page 22: Java tree fractals

What else?

22

Page 23: Java tree fractals

Examples for Inspiration

23

Page 24: Java tree fractals

Golden Ratio Tree Fractal

https://www.behance.net/gallery/720515/Worlds-Largest-Fractal-Vectors

Page 25: Java tree fractals

Pythagorean Tree

https://www.behance.net/gallery/720515/Worlds-Largest-Fractal-Vectors

Page 26: Java tree fractals

Fractal Branching Tree

https://www.behance.net/gallery/720515/Worlds-Largest-Fractal-Vectors

Page 27: Java tree fractals

Contact

If you want the Java code for some of the basic trees you can contact me at:

Thomas Cooper

The Walker School

Marietta, GA 30062

Website: http://www.thewalkerschool.org

Email: [email protected]