Ejemplo n.º 1
0
        public void GenerateAnglesArray(Robot robot, Canvas Canvas, SegmentsIntersector segmentsIntersector)
        {
            int positiveCounter = 0;

            for (int i = 0; i < maxAngle; i++)
            {
                for (int j = 0; j < maxAngle; j++)
                {
                    robot.UpdateAngles(i, j);
                    robot.Reset(Canvas);
                    Line firstLine  = robot.GetLines()[0];
                    Line secondLine = robot.GetLines()[1];
                    bool sentinel   = false;
                    foreach (var extendedRectangle in Colliders)
                    {
                        foreach (var line in extendedRectangle.GetLines())
                        {
                            bool intersectionWithFirst  = segmentsIntersector.Intersect(firstLine, line);
                            bool intersectionWithSecond = segmentsIntersector.Intersect(secondLine, line);

                            if (intersectionWithFirst || intersectionWithSecond)
                            {
                                sentinel = true;
                                break;
                            }
                        }
                        if (sentinel)
                        {
                            break;
                        }
                    }
                    if (sentinel)
                    {
                        anglesArray[i, j] = false;
                    }
                    else
                    {
                        anglesArray[i, j] = true;
                        positiveCounter++;
                        if (i % 4 == 0 && j % 2 == 0)
                        {
                            //firstLine.Stroke = new SolidColorBrush() {Color = Color.FromArgb(50, 0, 255, 0)};
                            secondLine.Stroke = new SolidColorBrush()
                            {
                                Color = Color.FromArgb(50, 0, 0, 200)
                            };
                            //lineContainer.Add(firstLine);
                            secondLine.X1 = secondLine.X2 - 1;
                            secondLine.Y1 = secondLine.Y2 - 1;
                            lineContainer.Add(secondLine);
                            Canvas.Children.Add(secondLine);
                        }
                    }
                }
            }
            int d = 10;
        }
Ejemplo n.º 2
0
        public void GenerateAnglesArray(Robot robot, Canvas Canvas, SegmentsIntersector segmentsIntersector)
        {
            int positiveCounter = 0;
            for (int i = 0; i < maxAngle; i++)
                for (int j = 0; j < maxAngle; j++)
                {
                    robot.UpdateAngles(i, j);
                    robot.Reset(Canvas);
                    Line firstLine = robot.GetLines()[0];
                    Line secondLine = robot.GetLines()[1];
                    bool sentinel = false;
                    foreach (var extendedRectangle in Colliders)
                    {
                        foreach (var line in extendedRectangle.GetLines())
                        {
                            bool intersectionWithFirst = segmentsIntersector.Intersect(firstLine, line);
                            bool intersectionWithSecond = segmentsIntersector.Intersect(secondLine, line);

                            if (intersectionWithFirst || intersectionWithSecond)
                            {
                                sentinel = true;
                                break;
                            }
                        }
                        if (sentinel)
                        {
                            break;
                        }
                    }
                    if (sentinel)
                    {
                        anglesArray[i, j] = false;
                    }
                    else
                    {
                        anglesArray[i, j] = true;
                        positiveCounter++;
                        if (i%4 == 0 && j % 2 == 0)
                        {
                            //firstLine.Stroke = new SolidColorBrush() {Color = Color.FromArgb(50, 0, 255, 0)};
                            secondLine.Stroke = new SolidColorBrush() {Color = Color.FromArgb(50, 0, 0, 200)};
                            //lineContainer.Add(firstLine);
                            secondLine.X1 = secondLine.X2 - 1;
                            secondLine.Y1 = secondLine.Y2 - 1;
                            lineContainer.Add(secondLine);
                            Canvas.Children.Add(secondLine);
                        }
                    }
                }
            int d = 10;
        }