Fandom

Scratchpad

The Koch Snowflake

216,178pages on
this wiki
Add New Page
Discuss this page0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Welcome to the The Koch Snowflake mini wiki at Scratchpad!

You can use the box below to create new pages for this mini-wiki. Make sure you type [[Category:The Koch Snowflake]] on the page before you save it to make it part of the The Koch Snowflake wiki (preload can be enabled to automate this task, by clicking this link and saving that page. Afterwards, you may need to purge this page, if you still see this message).


The Koch Snowflake is a fractal design described by Niels Fabian Helge von Koch, a Swedish mathematician, in the early twentieth century. As shown in the image below, the first iteration of the Koch Snowflake is an equilateral triangle.

Von Koch curve

The Koch Snowflake


As iterations progress through the Koch Snowflake, each segment in the triangle becomes a collection of four segments, each one-third the length of the segment that is being redrawn, with a 120° angle between the first and second segments, a 60° angle between the second and third segments, and a 120° angle between the third and fourth segments.

The Koch Snowflake and Recursion

The Koch Snowflake is an excellent visual example of recursion. If the segments that make up the Koch Snowflake are quantified in terms of their "pointiness," the first iteration of the snowflake would contain three segments that each have zero pointiness. In the second iteration, each side is a segment with one pointiness. As each one-pointiness segment is composed of four zero-pointiness segments, the recursion is evident. A five pointiness segment, for example, would be composed of four four-pointiness segments, each of which is composed of four three-pointiness segments, etc.. A reasonable base case in a recursive function designed to draw the Koch Snowflake, then, would be "if the pointiness equals zero, then just draw a regular line segment."

Drawing the Koch Snowflake with Java

The following Java code could draw the Koch Snowflake by calling drawSnowflake in some context. (Assume that there exist methods move, turnLeft and turnRight that are capable of drawing a line segment of a given length, turning left a given number of degrees, and turning right a given number of degrees, respectively.)

public void drawSnowflake(int pointiness, int sideLength) {

for (int j = 0; j < 3; j++) {
drawSegment(pointiness, sideLength);
turnRight(120);
}

}

public void drawSegment(int pointiness, int length) {

if (pointiness <= 0) move(length);
else {
drawSegment(pointiness - 1, length / 3);
turnLeft(60);
drawSegment(pointiness - 1, length / 3);
turnRight(120);
drawSegment(pointiness - 1, length / 3);
turnLeft(60);
drawSegment(pointiness - 1, length / 3);
}

}

External Links

Also on Fandom

Random wikia