TheDLA

Let's learn the basis of pattern formation by TheDLA!

by Daishin Ueyama

日本語版

Introduction

TheDLA is an app I have made and released for iPhone, iPad. With TheDLA, you can perform and observe DLA (Diffusion Limited Aggregation) Simulation which is famous as the basic model of pattern formation. With TheDLA, you can learn how random movement creates treelike shape we find in nature. Please click HERE or the banner below for downloading. To play, you would be required to have iOS devices, such as iPhone, iPad, and iPod touch.

Although I am not a professional app creator, I plan the app to be progressed so it would be more optimized and easier-to use. If you are interested in making an iPhone app, I recommend Stanford University's iTunes U. (Please access from HERE. ) With Professor Paul Hegarty's easy-to-follow instruction and demonstration, if you had the knowledge of C language and a reference book of Objective-C, you would be able to create an app as more and less same level as TheDLA by just taking this iTunes U's course. (Now they use Swift instead.)

Please note that no exposition about DLA is available here. For the details, please refer to masterpieces, such as Professor Mitsugu Matsushita's "Physics of Fractal (I)(II) by Mitsugu Matsushita, published by Shokabo (In Japanese)". Other good starting point for DLA is the description on the Wikipedia.

Introduction to Diffusion Limited Aggregation (DLA)

Please see the chart above. As you can see, on the left side of the chart, there is a fixed red particle called seed particle. Now, you place white particles away from the seed particle. White ones can move randomly, therefore, they are called free particles. Moving randomly means that, for example:

  • when you cast a dice and get 1, then move to the left,

  • if you get 2, move to the right,

  • if you get 3, move up,

  • if you get 4, move down,

  • if you get other numbers, must not move,

moving by such rules. This is called Random Walk.

Well, as this random walking particle moves freely on the flat surface, therefore, it is possible for it to be next to a seed particle. When free particle is next to a seed particle, it attaches to the seed particle and becomes a fixed particle itself. When the free particle attaches to the seed particle, you place another new free particle away from them. Please repeat this task.

You would see, the seed particles gradually grow like the figure in the center of the chart above. Now, could you imagine what sort of shape this seed particle would create?

First of all, please image it.

Start up of TheDLA

When TheDLA is installed, an icon which is showed in the picture image below left would be added to your iPhone's home screen. You can start TheDLA by tapping its icon. Please see the picture image below right, it is how TheDLA would start. TheDLA is a Universal app which operates with large screen of iPad as an advantage. Its display on iPad may slightly different, however, it require same operation.

Please see the start-up screen, where you would find a red dot in the center and a large number of yellow dots around it.

Red dot in the center is the seed particle, as mentioned earlier, and the yellow dots around are the free particles. For the original DLA, we added one free particle at one time, however, here in TheDLA, to speed up its process, 3000 particles are already randomly placed, away from the seed particle. These particles would move randomly and attach to the seed particle.

When you tap the triangle-shaped start button similar to a play button, which you can find at the bottom of the screen, DLA simulation starts.

As you are now aware, this button controls simulation's on-off action.

Please see the picture image below: it is how a simulation grows after a while. This is the so-called DLA Pattern. Is this as same as you had imaged earlier? If you re-tap the triangle-shaped start button, the simulation would be paused.

At the next chapter, let's see a nature of the particles which do Random Walk, and think why such tree branch-like form as above picture image would be created.

Random Walk breaks a form

As you assume, DLA's branches pattern is the result of free particles attached to a seed particle and expanded its shape as mentioned above. Let's see the nature of Random Walk by moving the branches pattern as the free particles' initial placement. When the branches pattern is formed, please pause the simulation, then 'double tap' the screen 'with 2 fingers'. (e.g., first, you make V sign with your index finger and middle finger, then tap the screen twice quickly with the fingers kept in the V sign shape) Now, the following menu would appear on the screen.

By using this menu, you would be able to clear the branches pattern you have created. If you select 'Clear', it would clear the pattern literally. We shall skip 'Blend' for a moment, then next, if you tap 'Diffuse', it should be more and less like below:

You may think it's just the same pattern with yellow color, but this is the result of conversion when all the particles were changed to free particles. Thus, if you start the simulation at this point, each free particle would Random Walk from the position as its initial placement. So, how it would be?

Please see the picture image above. That is the result. Its branches pattern instantly crumbled, and now all you can see is particles ranged almost evenly.

Isn't this what we expected, is it? As each particle moves randomly, even they were placed in a regular way at the beginning, the information of their initial form would be lost as time goes along, then the placement would be more and more discretely.

This is exactly as same process as how wind and rain would crumble a sand mound. As a proverb says, "It is no use crying over spilled milk."

For this time, we used the DLA pattern as free particles' initial placement, and now I would like to show you slightly more common form.

With TheDLA, you can position a seed particle by double tapping: Tap the screen twice with 1 finger. Moreover, you can place seed particles continuously by touching then wait for about 0.5 second before you slide your finger on the screen.

By this way, you can place seed particles while the simulation in on pause. For an example, please see the picture image below:

By the way, if you use TheDLA while it's connected to the Internet, you may see a banner of advertisement at the top as the picture image above shows.

Now, please double-tap the screen with 2 fingers as you did earlier, then select 'Diffuse'.

Let's see. If you start the simulation from this position… it's as same as the previous one. First, the outline of these Chinese character quickly blurred, so you can not recognize them as the character any longer. Then, for a while many particles would stay where the character were, therefore you may be able to trace the character somehow, but as some more time passes, you would not even see that.

In this way, by knowing the nature of Random Walk, it seems that Random Walk can break patterns, but can not create patterns. So, here is the question. Why such an attractive branches pattern was appeared in DLA?

The setting screen

To access to the setting screen, please tap the gear mark on the bottom right of the screen.

Please note that this setting screen is of version 1.14, therefore, if you are using other versions, your setting screen may slightly be different from this. Now, let's start. If you tap 'Reset' button which you would find on the top side of the screen, the particles would be reset to the initial state. If you tap 'Help', you would be able to check a brief description, too.

You may change Pen size by adjusting the slide bar on the lower side of the screen. I draw "Daishin", the two Chinese character earlier with the seed particles set to a certain size/ thickness. For a simulation speed, you can control it with 'Simulation speed' bar below the 'Pen size' one. The default speed is set as slow, so that you would be able to study how the form to be created. If you slide it to the rightmost, it would perform with the device's maximum speed. For the other switches, please refer to the below:

  • Rainbow switch: When it's switched off, branches pattern would be black and white.

  • DLA switch: it switches on and off displays of seed particles (DLA patterns).

  • Anim switch: When it's on, you can enjoy its time varying change of color.

  • Eyes, Nose, Mouth, and Hanage mode switch: Please referred to hereinafter.

Also, as explained in 'Help', with various way of tapping, you would be able to make most of control.

  • Double tap: Put fixed particles on the point. The size is changeable by 'Pen size' on setting screen.

  • Single tap: Remove some fixed particles, process patterns freely.

  • 2 fingers double tap: Remove all fixed particles from the field + etc.

  • 2 fingers pan: Pan the field.

  • Long pressed pan: Draw fixed particles like a pen.

  • Long pressed pan after a tap: Perform as an eraser.

Why branches pattern is formed!?

As we learned in chapter "Random Walk breaks a form", it seems strange that Random Walk can create such beautiful branches pattern. Can you imagine what mechanism is working?

Let's examine it with TheDLA!

First, you need to set the Simulation speed to the leftmost on setting screen, so you would be able to study particles' Random Walk without any hassle. Then, you should tap 'Reset' button to set particles back to their initial placement. (As it uses different random number sequence for each time, you always get different branches pattern.)

Now, by using pinch motion (touch the screen with two fingers, then spread them to opposite directions to make them apart), enlarge the image, so that you would be able to see around the seed particle. When the image is large enough, you can tap the simulation's start button.

You would see yellow free particles are moving randomly. Moreover, you can see how the free particles attache to seed particles. To our surprise, it won't be long before branches pattern would appear. Let's continue watching.

When the branches pattern grows big enough, use the pinch motion (touch the screen with two fingers, then narrow a gap between them), so that you would be able to see the whole picture. While your two fingers are attached to the screen, by sliding them up, down, left, or right, you can move the screen image, too.

The figure above is a such 'grown' branches' enlarged image. The complex patterns of branches have created a creek-like structure. The first thing you would notice must be that there are almost no yellow free particles inside the creek-like structure. Under such circumstances, no branches inside the creek-like structure would grow any longer. Furthermore, although it is almost a circle shape as a whole, you would be able to recognize quite a few yellow free particles at the edge of the circle.

If you stop the simulation and set off DLA on setting screen, you would realize that the range of free particles is complementary to the branches pattern. Also, at the same time you would be able to see that no free particles managed to get into inner side of the creek.

If you looked at TheDLA's simulation, you would see that free particles hardly ever went into inner side of the creek and attached to the branches there. As free particles move randomly, they attach to other branches before they reach to the inner side of the creek.

This is the shielding effect, the pattern of DLA's nature itself.

Although patterns grow gradually from one seed particle, the shielding effect which is caused by the grown branches themselves would make a situation, for those branches to be difficult to grow further, and branches started out late would have more difficulties to grow.

Because of such shielding effect occur at each small and large creeks, it creates complicated branches pattern.

Let's explore more!

Now, I expect you to understand more and less of its basis.

Please pay your attention to "P" button and "g" button on the bottom of the screen. "P" button is an on-off switch of drawing free particles. On the other hand, "g" button is an on-off switch of acceleration which is a built-in sensor of iPhone and a like. When you turn on "g" button, the acceleration sensor would be activated, so that the effect of gravity would be visible by particles movement. You would be able to see a change of particles' movement when you sway the device itself. Also, the completed pattern would show 'anisotropic aspect'.

"C" button which is on the setting button's left, is for changing color. By using it, you can choose another color, so that you can change the color of branches when you trace the branches. At the same time, it is "C" for clear, so you can erase the changed color. For example, arrange DLA to look like the Tricolor, the French flag…

When you click a camera mark on the bottom left, you can combine a photo with DLA pattern. DLA’s branch pattern looks very much like real tree branches, so I placed a DLA pattern in this picture of real trees. Can you find where I placed the DLA branches pattern?

You can save the picture images you made into camera roll via so-called share button next to the camera button. Also, you can post them to Twitter and/or Facebook. Note: From Ver.1.14, operation is differ between iOS6 and iOS5.

If you switch on 'Anim' on setting screen, color would be changed. While it's still in the Anim mode, when you try to save the image to camera roll, 8 picture images would be saved according to the color difference. Then if you convert them into Animated GIF file via other app (e.g., GifBoom, Gifture), you can utilize it as a moving image on Internet websites. Although the quality of picture image would slightly decline, it would still be useful in various ways. Please see the picture image below left: It’s made of picture images saved in camera roll with the setting of 'Rainbow'-off and 'Anim'-on. On the other hand, the picture image below right was made with both 'Rainbow' and 'Anim' on.

By the way, regarding its color change, it changes according to an order of attaching to seed particles cluster, and in a cyclic manner. As a movement of animation reflects it, in reality, you are actually watching which color was taken in, in what order. It may looks like just fun, but in fact, it is very scientific…

Play face with TheDLA!

When you combine TheDLA's branches pattern with someone's face, you can get quite an interesting effect. With iOS' face detection function, you can detect where eyes and nose in a picture taken. In TheDLA, 'Eyes', 'Nose' and 'Mouth' switch on the setting screen, 'Detect!' button inside the camera button are for that function.

When you set someone's photo as a background, then tap the 'Detect! 'button inside the camera button, according to its setting, seed particles would be automatically placed where his/her eyes and mouth are. For instance, we tend to use black lines to hide faces in group photographs, instead, we can tastefully hide their eyes with using TheDLA!

Well, as I didn't have an appropriate group photo, I used this instead. But, as you can see, the eyes were detected properly. FYI, you can convert this to Animated GIF as explained earlier if you wish.

Lastly

Towards the end, I might giggled a bit too much…

So, let's get back to the subject. With TheDLA, you would be able to know the principle of how random movement would create branches pattern we find in nature 'intuitively'. I developed this app to use for educational purpose, such as trial lessons at high schools, university classes for freshman/sophomore years. I would be honored if you would use the app for such use. Of course, I would appreciate if you would use it as some sort of joke app as well!

If you have a requirement such as functionality expansion, please do not hesitate to contact me. I would deal as much as I could. At the same time, please note that I am a weekend-only programmer as I have main profession during weekdays (and quite often, weekend, too…), so I may not be able to answer all of your requirement. Thank you for your understanding.