• Draw a straight line if depth is zero; otherwise draw four smaller Koch Curves.
Koch Curve
Start with a line.
Line Segment Transformation
(x1,y1)
(x2,y2)
(x3,y3)
(x4,y4)
(x5,y5)
(x1,y1)
(x5,y5)
Segment Calculations
Calculating the Projection
ll
x = ½l
y = √3/2l
m2 + (½ l)2 = l2
m2 + ¼ l2 = l2
√m2 = √¾ l2
m = √3/2l * 1/3 = √3l/61/3 length of each iteration
Other Geometric Shapes?
Koch Snowflake
Start with a triangle.
Triangles Need 3 Calls to drawFractal()
Call the method drawFractal() for each side of the triangle. You need to establish variables for the x,y coordinates for the line on each side of the base triangle.
What aspects can you change?
Aspects
• Ratio Expression
• Shape of the Triangle
• Shape of the Base
– Square, Pentagon, Trapazoid
• Tessellations
• Color
Ratio Change to Projection
How does the projection change when you change the ratio?
Change Ratio through Expressions
Change Base to Koch Square
Start with a square.
Calculates the Tip of the Projection
How does the projection change when you change the ratio?
Square Needs 4 Calls to drawFractal()
How do we get curves that look like landmasses?
24
Fractals in Nature
Coastlines
25
Fractals in Nature
Coastlines
26
Fractals in Nature
Coastlines
27
Fractals in Nature
Coastlines
28
Fractals in Nature
Coastlines
29
Fractals in Nature
Coastlines
30
Fractals in Nature
Coastlines
Use the Random Class
Add Randomness to the Ration
Generates a random number between 3 and 10 for the denominator of the ratio.
3 Calls to the Method drawFractal()
6 Recursive Calls Approximates Landmass
Examples for Inspiration
Koch Snowflake Tessellations
You can tessellate Koch snowflakes to create pattern on a canvas.