Пример #1
0
        public bool CheckCollision(Robot robot, SegmentsIntersector segmentsIntersector)
        {
            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)
            {
                return true;
            }
            return false;
        }
Пример #2
0
 public PathFinder(ColliderContainer colliderContainer, ConfigurationSpace configurationSpace, Robot robot, LinearInterpolator linearInterpolator, DispatcherTimer timer)
 {
     this.colliderContainer = colliderContainer;
     this.configurationSpace = configurationSpace;
     this.robot = robot;
     this.linearInterpolator = linearInterpolator;
     this.timer = timer;
 }
Пример #3
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;
        }
Пример #4
0
 private void InitializeRobot()
 {
     robot = new Robot(dragCanvas);
     //IList<Line> lines =  robot.GetLines();
     //Canvas.Children.Add(lines[0]);
     //Canvas.Children.Add(lines[1]);
 }