Esempio n. 1
0
 // Find the middle between two points (positions)
 private static Position SegmentMiddle(Position p1, Position p2)
 {
     return new Position((p1.X + p2.X) / 2, (p1.Y + p2.Y) / 2);
 }
Esempio n. 2
0
 // Find the distance between two points (positions)
 public static double DistanceBetweenPoints(Position p1, Position p2)
 {
     return Math.Sqrt(Math.Pow(p2.X - p1.X, 2) + Math.Pow(p2.Y - p1.Y, 2));
 }
Esempio n. 3
0
        // returns obstructing object position
        private static Position GetObstructingObjectPosition(Sensor sensor)
        {
            Position pos = new Position();
            switch (sensor.SignalDirection)
            {
                case Sensor.Direction.Up:
                    pos.X = sensor.Position.X;
                    pos.Y = sensor.Position.Y - sensor.SignalLength;
                    break;

                case Sensor.Direction.Down:
                    pos.X = sensor.Position.X;
                    pos.Y = sensor.Position.Y + sensor.SignalLength;
                    break;

                case Sensor.Direction.Left:
                    pos.X = sensor.Position.X - sensor.SignalLength;
                    pos.Y = sensor.Position.Y;
                    break;

                case Sensor.Direction.Right:
                    pos.X = sensor.Position.X + sensor.SignalLength;
                    pos.Y = sensor.Position.Y;
                    break;
            }
            Console.Write(pos.Y);
            return pos;
        }