Exemplo n.º 1
0
 private void DiamondStep(IWorkingArray extendedArray, int sideLength)
 {
     for (int x = 0; x < extendedArray.SideLength() - 1; x += sideLength)
     {
         for (int y = 0; y < extendedArray.SideLength() - 1; y += sideLength)
         {
             double average =
                 (extendedArray.GetValue(x, y) +
                  extendedArray.GetValue(x + sideLength, y) +
                  extendedArray.GetValue(x, y + sideLength) +
                  extendedArray.GetValue(x + sideLength, y + sideLength)) / 4;
             float value = CalculateNextHeight(average, x + sideLength / 2, y + sideLength / 2);
             extendedArray.SetValue(x + sideLength / 2, y + sideLength / 2, value);
         }
     }
 }
Exemplo n.º 2
0
        private void SquareStep(IWorkingArray extendedArray, int sideLength)
        {
            int half        = sideLength / 2;
            int wholeLength = extendedArray.SideLength();

            for (int x = 0; x < wholeLength - 1; x += half)
            {
                for (int y = (x + half) % sideLength; y < wholeLength - 1; y += sideLength)
                {
                    double average =
                        (extendedArray.GetValue((x - half + wholeLength - 1) % (wholeLength - 1), y) +
                         extendedArray.GetValue((x + half) % (wholeLength - 1), y) +
                         extendedArray.GetValue(x, (y + half) % (wholeLength - 1)) +
                         extendedArray.GetValue(x, (y - half + wholeLength - 1) % (wholeLength - 1))) / 4;
                    float value = CalculateNextHeight(average, x + sideLength / 2, y + sideLength / 2);
                    extendedArray.SetValue(x + sideLength / 2, y + sideLength / 2, value);
                }
            }
        }