The Koch snowflake is a fractal shape. At level 0, the shape isan equilateral triangle. At level 1, each line segment is splitinto four equal parts, producing an equilateral bump in the middleof each segment. Figure 7-15 shows these shapes at levels 0, 1, and2.
At the top level, the script uses afunction drawFractalLine to draw three fractal lines.Each line is specified by a given distance, direction (angle), andlevel:
The function drawFractalLine is recursive.
Write a script that draws the Koch snowflake.
Define a function main that will draw a Koch snowflakewith the following parameters when the program is run:
The Koch snowflake is a fractal shape. At level 0, the shape is an equilateral triangle. At level 1, each line segment i
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
The Koch snowflake is a fractal shape. At level 0, the shape is an equilateral triangle. At level 1, each line segment i
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!