From the Lab
Spacing Control for Coordinated Particle System (1)
Chujia Wei — July 9, 2013 - 2:37pm
If we have an attribute of spacing value for each pixle in a map, and particles will have to follow the spacing value to adjust their distance with neighbors, we then can control the spacing of particles based on an image. And if the spacing value is associated with the gradient value, the particles will be able to shape object in the image by changing their spacing.
As shown in the image below, there are two parts of spacing area on the canvas. When particles enter an area with a smaller spacing, the less chances they would kill adjacent neighbors and more possibilities to generate a new one.
The codes of space control (AB is the distance between particle A and B; Td is the threshold of current pixel; and V is a spacing viable for the current pixel):
average_Td = A_Td + B_Td; // get the average threshold of pixels that A and B currently in
average_V = A_V + B_V; // get the average viable
BTH_offset = 1.41;
DTH_offset = 0.58;
if (AB<DTH_offset * average_Td * average_V)
merge A and B as one particle;
else if (AB>BTH_offset * average_Td * average_V )
create a new particle between A and B;
//NOTE*: All the pixels on the left half of the canvas is set as: V = 1; and the right half is: V = 0.8. The threshold Td is set as 10 through out the canvas.