Koch Curve or Koch Snowflake:

Koch curve: The Koch curve or Koch snowflake is a mathematical curve, and it is one of the earliest fractal curves which was described. Its basis came from the Swedish mathematician Helge von Koch. Here, we will learn how to write the code for it in python for data science.

The progression for the area of snowflakes converges to 8/5 times the area of the triangle. The progression of the snowflake’s perimeter is infinity. The snowflake consists of a finite area that is bounded by an infinitely long line.

Construction:

Step 1:

First, we need to draw an equilateral triangle. It is good if the sides are divisible by 3 because of the nature of fractal.

Koch Curve or Koch Snowflake code in Python for Data Science - PST

Step 2:

Now we will divide each side into three equal parts.

Step 3:

Now we need to draw an equilateral triangle from the intersection of the three divided parts on each side.

Koch Curve or Koch Snowflake code in Python for Data Science - PST

Step 4:

Now we will divide the outer parts created into three parts as we have done before.

Step 5:

Now draw an equilateral triangle in each of the middle parts.

Koch Curve or Koch Snowflake code in Python for Data Science - PST

Representing in Lindenmayer system:

We can write the Koch curve by the following rewrite system.

Alphabet: F

Constants: +, ?

Axiom: F

Production rules: F ? F+F-F+F

In the above illustration, F represents draw forward, – represents turn right 60 degrees and + represents turn left 60 degrees.

Creating a Koch curve:

Koch Curve or Koch Snowflake code in Python for Data Science - PST

For the creation of a full snowflake with Koch curve, we will repeat the same step three times.

So, to learn more about it in python for data science, you can check this and this as well.

Leave a Reply

Your email address will not be published. Required fields are marked *