Next page : The onset of Chaos. Bouncing balls.

Sometimes in the early 80th I worked at a place where I had access to a rather simple line plotter. Using that I created a family of fractals that I could plot with a higher resolution than what I could do on the computers I had access to at that time.

The program to plot the graphs was written in Pascal. I have just rewritten it using JavaScript. The result can be seen here:

As you can see if you try it, it starts with the famous C-curve, though slightly modified. The colours comes from the fact that the procedure modifies the colour every time a point is overwritten.

**The algorithm**

We will have a look at the algorithm used to get the curve. It is a recursive algorithm, starting at level 0. At that level we would just get a vertical line.

It start at the lower end and moves upward. At the next level it will add a “knee”. This is done at every new level. Each straight line will be replaced by a “knee”.

In our case we will always start the first knee by changing the direction doing a quarter turn anticlockwise.

It is at level two things can begin do change. We may turn in the left or in the right direction. This is set by the rules, set by hex values. The bits of a hex vale will be used as follows:

- Rule A: The leftmost bit gives tells us in what direction the first segment will turn, if the turn to make the segment was to the left. A one means turn anti-clockwise and a zero means turn clockwise.
- Rule B: The next bit is for when we started to right. Since we started with a left turn at level 1, we will use rule A to decide the direction of the first “knee”.
- Rule C and D (the next two bits) does the same for the second (upper) knee.

If rule A and C states that we should turn to the left we get the first of the two level 2 figures.

If the rule A says turn to the left, but rule C says turn to the right we get the second variant.

So, to put it all together, if each hex number consists of the bits ABCD:

- A: A rule for how to turn the first “knee” if the “parent” did turn left.
- B: A rule for how to turn the first “knee” if the “parent” did turn right.
- C: A rule for how to turn the second “knee” if the “parent” did turn left.
- D: A rule for how to turn the second “knee” if the “parent” did turn right.

If we don’t want an infinite set of rules, we can reuse older rules. What we do is to decide an order for the figure. The order and the level, are used to determine what rules to use. If the order is say 3, then we will cyclically reuse the rules for the tree first levels. We calculate that what rule to use as one plus level mod order. Hence the name mod-curves.

The colours are taken from a table of colours, and the index is increased by one each time a pixel is set.

**The settling**

- You can set the rules in hex, and the corresponding bits are shown in the row below where you enter the rules.
- You can change the depth using a slider. You normally set this to maximum 16.
- You can change the order using a slider.
- If the order < the length of the rules then the order is automatically set to the length (in hex numbers) of the rules when you change the rules.
- A blank space is counted as 0 if you set the order higher than the number of rules.

**Some special curves**

Some rules worth mentioning.

- 0 => the C-curve.
- A=> the Dragon curve.
- 9=> this is my absolute favourite. I call it the Crab curve (of obvious reasons when you select it). I have not seen this before I made it in the early 80th.
- F0 => A surface fulling triangle.
- F05AFDE70=> A beautiful pattern with “islands”.

So, explore and enjoy (^^,).

Up a level : Fractals and ChaosNext page : The onset of Chaos. Bouncing balls.Last modified: