More selected projects

A.vs.B

This program runs a generation by generation system with a simulation of two chemicals reacting and diffusing each other. The result is a variety of patterns, similar to patterns found in nature.

produced by: Annie Tådne


Concept and background research

The formula is one of the explanations to animal pigmentation. It consists of one activator and one inhabitant, and when combined they interact and oscillate with each other. Because the algorithm being so rich of nature, this is a fascinating algorithm to work with in computational art projects.

The system feeds by different iterating patterns. When one of the chemicals is being poured into the system, they start compete with each other, creating new patterns differing from how the chemical was poured in. You could almost compare it with the pattern a barista is creating by pouring foamed milk into the coffee while making a cappuccino.


Technical

The program uses a convolutional grid with 9 different directions, all with different values. "The Laplacian is performed with a 3x3 convolution with centre weight -1, adjacent neighbours .2, and diagonals .05." (Karl Sims). This values are applied following function, representing the movement of chemical A.

float laplaceA(int x, int y) {
    float sumA = 0;


    sumA += grid[x][y][0] * -1.0; //centre
    sumA += grid[x - 1][y][0] * 0.2; //adjacent left
    sumA += grid[x + 1][y][0] * 0.2; //adjacent right
    sumA += grid[x][y - 1][0] * 0.2; //above
    sumA += grid[x][y + 1][0] * 0.2; //below
    sumA += grid[x - 1][y - 1][0] * 0.05; //diagonal up to left
    sumA += grid[x + 1][y - 1][0] * 0.05; //diagonal up to right
    sumA += grid[x + 1][y + 1][0] * 0.05; //diagonal down to left
    sumA += grid[x - 1][y + 1][0] * 0.05; //diagonal down to right

    return sumA;
}

 

The mathematical Gray-Scott model is being translated into code.

nextGeneration[x][y][0] = a +
((dA * laplaceA(x, y)) -

(a * b * b) +
(feed * (1.0 - a)))
* dT;

 

The patterns that feed the systems are made by iterating nested for loops.

for (int x = border; x < width; x += random(rndMin, rndMax)) {
    for (int y = border; y < height; y += random(rndMin, rndMax)) {
        grid[x][y][1] = 1.0;
    }
}

 

Future development

Make chemicals iterate from image or camera live feed. Create a similar system but built in 3D. Make a 2D print. Make a 3D print. Add interaction, maybe with motion tracking?


References

Gray Scott Model of Reaction Diffusion. (n.d.). Retrieved January 14, 2018, from https://groups.csail.mit.edu/mac/projects/amorphous/GrayScott/

D., Shiffman (Director). (2016, May 26). Reaction Diffusion Algorithm in p5.js [Video file]. Retrieved January 14, 2018, from https://www.youtube.com/watch?v=BV9ny785UNc

K., Sims. (n.d.). Reaction-Diffusion Tutorial. Retrieved January 14, 2018, from http://karlsims.com/rd.html