Example #1
0
        public static void TestBearingShouldMakeYouMoveToRightPosition()
        {
            Random rand;
            double x1, y1, x2, y2;

            rand = new Random();
            x1   = rand.NextDouble();
            y1   = rand.NextDouble();
            x2   = rand.NextDouble();
            y2   = rand.NextDouble();

            Point2D orig = new Point2D(x1, y1);
            Point2D dest = new Point2D(x2, y2);

            double angle = orig.AbsoluteBearing(dest);

            MyRobot r = new MyRobot(orig, angle);

            double distance = orig.Norm(dest);

            r.MoveRobot(r.CalculateRobotNextPositionPolar(orig, angle, distance));

            r.Position.X.Should().BeApproximately(x2, 0.001);
            r.Position.Y.Should().BeApproximately(y2, 0.001);
        }