📜 ⬆️ ⬇️

Dragon curves and bug

dragon curves
There is a remarkable and literally fascinating family of fractal curves - dragon curves. Who is not familiar with them the principle of their construction is the easiest to explain with a strip of paper. So, take a strip of paper and fold it several times in half, and then unfold it so that right angles are formed between the bend angles. As a result, we get the curve of the dragon. Since the thickness of the folded strip doubles each time, and the length of an individual link is halved, we cannot get long curves in this naive way.
Fortunately, long curves are easily drawn in another way, or rather in a variety of ways. In particular, on the Web you can find a recursive program that generates a dragon curve by completing the legs of the original curve segments, like hypotenuses. But I decided to entrust this business to the bug. Since the curve of the dragon consists of a series of turns "left" and "right", the bug should only be able to take a step in front and turn. The main thing I wanted to see was the interlacing of the dragon curves. Yes! These curves are combined with each other in different and interesting positions, which seems incredible for such complex and intricate curves.

So, I was faced with the task of getting the “name” of a dragon - a string coding sequence of turns. I will describe here the simplest and most obvious way. Since the curve is obtained by folding the strips of paper, the curves drawn from the last fold point should coincide when rotated 90 degrees. In other words, having reached the end of the curve, the bug should turn 90 and repeat its path in the reverse order, as if it were returning to the starting point. This is not the only way to get the desired sequence of turns. If you're interested, you can think about how to get this sequence based on the above described recursive creation of a dragon curve by constructing the legs.
By the way, the “fold” points at which the dragon's curve is doubled lie on a logarithmic spiral, and the curve makes a complete turn around itself in eight doublings.
So we have a "little turtle" and there is a "name of a dragon." It's time to look at the "mating" of dragons.

There are two dragon curves intertwined here: pastebin.me/e8440d992354f3e16479ca6f2a006c5c

And here there is a merging of four curves at once: pastebin.me/e8440d992354f3e16479ca6f2a004bf4
')
I do not know how anyone, but the plexus of 4 curves fascinates me.

That's all. I hope at least someone it was interesting and informative. Of course, I didn’t actually say anything about these wonderful curves, but the Internet will help you.

Shl. I would be grateful for comments from people professionally programming in Javascript comments in lichku about my code. I am self-taught, so I did not follow the rules of registration.

Source: https://habr.com/ru/post/138881/


All Articles