Ejemplo n.º 1
0
    void generateNextGrid()
    {
        DifussionCell[,] nextGrid = new DifussionCell[width, height];

        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                nextGrid [x, y] = new DifussionCell();
            }
        }

        for (int x = 1; x < width - 1; x++)
        {
            for (int y = 1; y < height - 1; y++)
            {
                float a = grid[x, y].a;
                float b = grid[x, y].b;

                nextGrid[x, y].a = a + (dA * LaplaceA(x, y)) - (a * b * b) + (f * (1 - a));
                nextGrid[x, y].b = b + (dB * LaplaceB(x, y)) + (a * b * b) - ((k + f) * b);
            }
        }
        grid = nextGrid;
    }
Ejemplo n.º 2
0
    private void InitGrid()
    {
        grid = new DifussionCell[width, height];
        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                grid[x, y] = new DifussionCell();
            }
        }


        int i = (int)width * 100 / 120;
        int j = (int)height * 100 / 120;

        grid[(int)width * 100 / 120, (int)height * 100 / 120].b         = 1f;
        grid[(int)width * 100 / 120 + 1, (int)height * 100 / 120].b     = 1f;
        grid[(int)width * 100 / 120, (int)height * 100 / 120 + 1].b     = 1f;
        grid[(int)width * 100 / 120 + 1, (int)height * 100 / 120 + 1].b = 1f;


        grid[(int)width * 50 / 120, (int)height * 100 / 120].b         = 1f;
        grid[(int)width * 50 / 120 + 1, (int)height * 100 / 120].b     = 1f;
        grid[(int)width * 50 / 120, (int)height * 100 / 120 + 1].b     = 1f;
        grid[(int)width * 50 / 120 + 1, (int)height * 100 / 120 + 1].b = 1f;

        grid[(int)width * 100 / 120, (int)height * 60 / 120].b         = 1f;
        grid[(int)width * 100 / 120 + 1, (int)height * 60 / 120].b     = 1f;
        grid[(int)width * 100 / 120, (int)height * 60 / 120 + 1].b     = 1f;
        grid[(int)width * 100 / 120 + 1, (int)height * 60 / 120 + 1].b = 1f;
    }