Ejemplo n.º 1
0
        static IEnumerable <Int32Vector> GetPoints()
        {
            var point = new Int32Vector();
            var delta = new Int32Vector {
                X = 1
            };

            var points = new HashSet <Int32Vector>();

            points.Add(point);

            bool IsValid(Int32Vector p) => IsInRange(p) && !points.Contains(p);

            while (true)
            {
                var p = point + delta;

                if (!IsValid(p))
                {
                    delta = TurnRight(delta);
                    p     = point + delta;

                    if (!IsValid(p))
                    {
                        return(points);
                    }
                }

                point = p;
                points.Add(point);
            }
        }
Ejemplo n.º 2
0
 static Int32Vector TurnRight(Int32Vector v) => new Int32Vector
 {
     X = -v.Y, Y = v.X
 };
Ejemplo n.º 3
0
 static bool IsInRange(Int32Vector p) => 0 <= p.X && p.X < Width && 0 <= p.Y && p.Y < Height;