Colonize Space with Fractal Trees

A quick guide to fractals and the Space Colonization algorithm

Logan Yang
Level Up Coding
Published in
7 min readJul 31, 2020

--

My P5.js implementation

In this article, I’m going to code up some special kind of squiggly shapes that might not help us colonize the galaxy any time soon, but probably will bend your mind and make math fun again. The subject is called fractals.

What are Fractals?

Before answering this question, let’s first look at some examples. Consider the length of the coastline of Britain. How long do you think it is? After a bit Googling you may find:

11,073 miles according to the mapping authority for the United Kingdom

But it also mentions something called the Coastline Paradox. Apparently, answering this question is not as straightforward as we might think!

Wikipedia

In the picture, it shows that the length depends on the smallest unit you use to measure it. If you zoom in to a part of the coastline, you’ll see similar squiggly curves the same as the ones in the larger scale image. In theory, you could zoom in infinitely on it and still see those squiggly curves. This means if you have infinite resolution, the length will approach infinity as well. How counterintuitive is that?

Here’s another example. Say we have an equilateral triangle, and we do the following to each of the sides:

  1. Divide the side into 3 equal segments
  2. Draw a smaller equilateral triangle that uses the middle segment as its base and points outward
  3. Remove the base segment of the small triangle in step 2

Repeating this process again and again, we go from a triangle to something like a snowflake.

Wikipedia

This is called the Koch snowflake, or Koch curve, named after Swedish mathematician Helge von Koch after he introduced it in a 1904 paper. If we repeat the process forever, what is the perimeter of the Koch snowflake? It is…

--

--