Diffusion-Limited Aggregation. Simulation in C++ ImGui
Diffusion-Limited Aggregation (DLA) can be explained as a random walk process (particles due to random movement walk away from the place where they started) due to the Brownian motion (see also one of my previous articles). The random motion behavior affects that the particle can be grouped in clusters which often mimics the fractals or tress. There are several examples in nature of impressive random shape creation. Please visit here to be more inspired by this phenomenon.
The following article gives you the intuition of the motion applied. The mathematical background you will find easily under the links I refer to.
There are several approaches to creating results and the random walk process is deeply involved in geometry growth. Computer simulations give an excellent ability to capture and study particle behavior. We can observe the radial movement from the single point (in this article simulation is performed in opposite direction) outwards to the creation of a straight line.
In the following article, I will describe the mechanism of creation that shapes and run a simulation that I made in C++ with visualization in ImGui.
The introduction to the C++ ImGui and information on how to compile and build programs you will find in one of my previous articles.
The source code you will find on my GitHub.
Diffusion-Limited Aggregation mechanism
For a certain dimension of 2D space (here canvas for example with the size 500 x 500 pixels), we generate randomly on the canvas number of particles that move randomly. The particle starts moving from the edges and the next step of a particle in the X and Y direction is random (I applied the Mersenne Twister engine).
The number of particles in the simulation is constant. The simulation starts from the initial conditions, where the first particle (not movable) is located in the center of the simulation space. While the simulation runs the particle moves and can be clustered (connected to the no-movable group of particles from the previous timestamp of the simulation). Connection occurs when the distance of a certain particle to one of the cluster particles is lower than two times the radius of the particle size. When collision the particle is pushed to the cluster. As we can assume the number of “collision checks” increases since more particles are clustered while running the simulation. The distance to the center affects the color of the stuck particle.
Below I depicted how the simulation runs in practice. As you can see, we are able to recreate the shapes of the particle behavior presented in this article.
If you are more patient and applied more and smaller particles, you can expect to receive the following results.
Thank you for reading.