Hi,
I am trying to simulate a set of values which are being calculated inside a class. Its based on cellular automata. I tried simulating the same from within the for loops but it never showed up as a simulation in the final output (I used a PImage on top on the real image). This is the class definition -> public class TumorGrowth extends PApplet
My question is how can I simulate the growth of the tumor in my case so that it shows growing or simulating based on the values returned in the 2D array? The function cancerGrowth() is called from within the program once the user presses the simulate button on the screen and its outside the draw() function. Is it possible to perform simulation outside the draw() function in processing.
Thanks!
- public float[][] cancerGrowth()
- {
- // time stepping
- for (int kt=1; kt < maxT; kt++)
- {
- // Step 1: Proliferation
- for (int i=1; i < _Nx; i++)
- {
- for (int j=1; j < _Ny; j++)
- {
- grid[i][j] = (float) (Ro*grid[i][j]);
- }
- }
- // Step 2: Motility step
- for (int i=2; i < _Nx-1; i++)
- {
- for (int j=2; j < (_Ny/2-1); j++) // Even Row
- {
- futureGrid[i][2*j] = (float) (p2 * grid[i][2*j] + _p * (grid[i][2*j+1] + grid[i+1][2*j+1] + grid[i][2*j-1] + grid[i+1][2*j-1] + grid[i+1][2*j] + grid[i-1][2*j]));
- }
- for (int j=2; j < (_Ny/2-1); j++) // Odd Row
- {
- futureGrid[i][2*j-1] = (float) (p2 * grid[i][2*j-1] + _p * (grid[i][2*j] + grid[i-1][2*j] + grid[i][2*j-2] + grid[i-1][2*j-2] + grid[i+1][2*j-1] + grid[i-1][2*j-1]));
- }
- }
- grid=futureGrid; // update CA.
- }
- return grid;
- }
1