Digital Representation / BMEEPAGA205

Fractals

Background

Koch snowflake

Fractals do not have a generally accepted mathematical definition — we can always find something that can be considered a fractal based on its properties, but is irrevelent (e.g. self-similarity is true in case of straight lines also), or something that would be worth discussing, though it does not fulfil the definition. The construction of the abstract, deterministic fractals discussed here obviously differs a lot from the stochastic fractals imitating natural forms, yet there is a sense of principle similarity. The lack of a clear definition does not mean that the studying of fractals would not raise interesting problems.

The shape in the illustration is the Koch snowflake, one of the first and perhaps the best-known fractals that can be generated recursively based on clear substitution rules.

The initial shape (initiator) is a regular polygon, and the replacement rule (generator) is to divide the sides of the polygon into thirds, then replace the middle third of each side with two other sides of a smaller regular triangle. As we repeat this substitution recursively, the sum of the side lengths (the circumference of the polygon) increases 4/3 times in each step – that is, in principle (after an infinite number of iterations) it becomes infinite. Meanwhile, its area is obviously finite, since it never leaves the area of the circumscribed circle.

A possible solution: DOWNLOAD

An established formal language for describing fractals is the L-system (after Arisztid Lindenmayer), whose grammatical rules have to be applied iteratively. Due to the self-similarity resulting from this recursive process fractal-like forms are easy to describe this way. If each symbol is associated with exactly one output, then the system is deterministic, if there are more possible outputs (and each one is selected with a certain probability during each iteration) then the system is stochastic.

The Koch snowflake can be described in a simple way as an L-system using a single variable (f) and two constants (+, ). The f (forward) draws a section, + means turning left (120°), means turning right (60°). The starting regular triangle can be written in the form f+f+f, and the substitution rule in the form f 🡢 f-f+f-f (which can be easily implemented with the SUBSTITUTE() function). The first iteration looks like this: f–f+f–f+f–f+f–f+f–f+f–f. Unfortunately, the next iteration is not really suitable for human consumption: f–f+f–f–f–f+f–f+f–f+f–f–f–f+f–f+f–f+f–f–f–f+f–f+f–f+f–f–f–f+f–f+f–f+f–f–f–f+f–f+f–f+f–f–f–f+f–f. Another inconvenient feature of this system is that it uses relative angles, i.e. it specifies the direction of the next segment compared to the direction of the previous segment — therefore we recommend using a new system.

Parameters

 • Identifiers

A possible solution is to represent the fractal as a sequence of numbers in a given positional numeral system.

The number of fractional digits corresponds to the iteration steps of the fractal, and the difference between the adjacent elements of the series is always the smallest number that can be described with the given number of digits. Thus, in step 0, the sequence contains only whole numbers, from zero to the number of sides of the starting polygon, minus one (in the case of a triangle, 0-1-2), but each new iteration step adds a new position for fractional digits.

The radix or base of the number representing the fractal corresponds to the multiplication number of the segments created during the iteration steps. In case of the Koch snowflake the iteration replaces every segment by four shorter segments, hence, it can be represented in a quaternary (radix 4) system (which uses digits from 0 through 3).

Hence, all segments of a given it iteration of a fractal can be denoted by pgn·itnit elements of a sequence in a radix itn numeral system. In the case of the Koch snowflake, the 1st iteration (all 3 sides divided into 4 segments) can be described by 3×41=12 quaternary numbers:
0.0, 0.1, 0.2, 0.3, 1.0, 1.1, 1.2, 1.3, 2.0, 2.1, 2.2, 2.3

Numerical parameters
 • Lengths

The overall size of the fractal does not change during the iteration, the circumference only increases due to the more accurate measurement, i.e. because of the the shorter ruler.

Length parameters
 • Directions

Of course, the above numbers only form the logical framework, they do not in themselves decide the direction of the segments

Direction parameters

In order to represent the fractal, the coordinates of each section must be calculated. A simple solution to this is to follow the path of the line starting from the starting point – since all sections have equal length, it is sufficient to know the direction of the segment starting from the current point. The recursive solution outlined above is suitable for this.

Unfortunately, the program cannot calculate in a base-4 number system, so we have to generate the series of numbers.

Identifiers

The above formula may not be trivial — it's worth thinking about what it does in which row and column.

Strommer decimal anti-snowflake

It is easy to come up with a rule where the number of segments (itn) resulting from the iterative steps is ten — meaning that the identifiers will be in the decimal number system (pgn= 4).

Since you have to use the usual decimal number system here, it might be easier to understand the formula.

However, we are not interested in the identifier itself, but rather the angle that can be calculated based on its digits.

Directions

Coordinates

The previous _d array denotes the directions corresponding to the each iteration step — they just need to be added together.

Segment directions

The resulting array gives the (absolute) direction of each edge.

In order to create a diagram, we need the coordinates of each point.

Vertex coordinates
Cesàro snowflake
Depicting the fractal