Пример #1
0
        public void SetValuesAt(GridIntersect loc, double width, double height, byte value)
        {
            int indexW = (int)Math.Round(width / _meshSize);
            int indexH = (int)Math.Round(height / _meshSize);
            int startX = Math.Max(loc.X - indexW, 0);
            int startY = loc.Y;
            int endX   = Math.Min(loc.X + indexW, xLength - 1);
            int endY   = Math.Min(loc.Y + indexH, yLength - 1);

            for (int xi = startX; xi <= endX; xi++)
            {
                for (int yi = startY; yi <= endY; yi++)
                {
                    grid[xi, yi] = value;
                }
            }
        }
Пример #2
0
        public void SetRadialValuesAt(GridIntersect loc, double width, double height, byte value)
        {
            int    indexWidth  = (int)Math.Round(width / _meshSize);
            int    indexHeight = (int)Math.Round(height / _meshSize);
            int    startY      = Math.Max(0, loc.Y);
            double radius      = width / 2.0;
            int    endY        = startY;

            if (indexHeight > 0)
            {
                endY = Math.Max(0, Math.Min(loc.Y + indexHeight, yLength - 1));
            }
            for (int yi = startY; yi <= endY; yi++)
            {
                var circleCenter = new GridIntersect {
                    X = loc.X, Y = yi
                };
                SetRadialValuesAt(circleCenter, radius, value);
            }
        }
Пример #3
0
        public void SetRadialValuesAt(GridIntersect loc, double radius, byte value)
        {
            int indexR  = (int)Math.Round(radius / _meshSize);
            int indexR2 = (int)Math.Pow(indexR, 2.0);
            int startX  = Math.Max(loc.X - indexR, 0);
            int startY  = loc.Y;
            int endX    = Math.Min(loc.X + indexR, xLength - 1);
            int endY    = Math.Min(loc.Y + indexR, yLength - 1);

            for (int xi = startX; xi <= endX; xi++)
            {
                for (int yi = startY; yi <= endY; yi++)
                {
                    double r2 = Math.Pow(xi - loc.X, 2.0) + Math.Pow(yi - loc.Y, 2.0);
                    if (r2 <= indexR2)
                    {
                        SetValue(xi, yi, value);
                    }
                }
            }
        }
Пример #4
0
 public void SetValueAt(GridIntersect loc, byte value)
 {
     SetValueAt(loc.X, loc.Y, value);
 }