Ejemplo n.º 1
0
        public void NoMovementAtAllTest()
        {
            IMathCalcUtility mathUtil = new MathCalcUtility ();
            Aircraft tetheredBalloon = new Aircraft ("1", Vector<double>.Build.DenseOfArray(new double[3]{0, 0, 0}));
            tetheredBalloon.DataBuffer.Add(Vector<double>.Build.DenseOfArray(new double[3]{0, 0, 0}));

            Aircraft thisAircraft = new Aircraft ("2", Vector<double>.Build.DenseOfArray(new double[3]{1, 0, 0}));
            thisAircraft.DataBuffer.Add(Vector<double>.Build.DenseOfArray(new double[3]{1, 0, 0}));

            double intersection = mathUtil.Intersection (tetheredBalloon, thisAircraft, 1);

            Assert.AreEqual (-1.0, intersection); //should be no intersection since tetheredBalloon isn't moving

            thisAircraft.Velocity = Vector<double>.Build.DenseOfArray (new double[3]{ 1, 2, 0 });
            intersection = mathUtil.Intersection (tetheredBalloon, thisAircraft, 1);

            Assert.AreEqual (-1.0, intersection); //still no intersection after thisAircraft changed course
        }
        public void FasterAircraftInFront()
        {
            IMathCalcUtility mathUtil = new MathCalcUtility ();

            Aircraft fasterAircraft = new Aircraft ("1", Vector<double>.Build.DenseOfArray(new double[3]{5, 0, 0}));
            fasterAircraft.DataBuffer.Add(Vector<double>.Build.DenseOfArray(new double[3]{5, 0, 0}));

            Aircraft thisAircraft = new Aircraft ("2", Vector<double>.Build.DenseOfArray(new double[3]{1, 0, 0}));
            thisAircraft.DataBuffer.Add(Vector<double>.Build.DenseOfArray(new double[3]{1, 0, 0}));

            double intersection = mathUtil.Intersection (fasterAircraft, thisAircraft, 1);

            Assert.AreEqual (-1.0, intersection); //should be no intersection
        }
        public void FasterAircraftCollision()
        {
            IMathCalcUtility mathUtil = new MathCalcUtility ();

            Aircraft fasterAircraft = new Aircraft ("1", Vector<double>.Build.DenseOfArray(new double[3]{-5, 0, 0}));
            fasterAircraft.DataBuffer.Add(Vector<double>.Build.DenseOfArray(new double[3]{50, 0, 0}));

            Aircraft thisAircraft = new Aircraft ("2", Vector<double>.Build.DenseOfArray(new double[3]{1, 0, 0}));
            thisAircraft.DataBuffer.Add(Vector<double>.Build.DenseOfArray(new double[3]{0, 0, 0}));

            double intersection = mathUtil.Intersection (thisAircraft, fasterAircraft, 1);

            Assert.AreEqual (Math.Sign(1), Math.Sign(intersection)); //should be an intersection //
        }
Ejemplo n.º 4
0
        public void StopMovementTest()
        {
            IMathCalcUtility mathUtil = new MathCalcUtility ();
            Aircraft stoppingAircraft = new Aircraft ("1", Vector<double>.Build.DenseOfArray(new double[3]{-5, 0, 0}));
            stoppingAircraft.DataBuffer.Add(Vector<double>.Build.DenseOfArray(new double[3]{50, 0, 0}));

            Aircraft thisAircraft = new Aircraft ("2", Vector<double>.Build.DenseOfArray(new double[3]{1, 0, 0}));
            thisAircraft.DataBuffer.Add(Vector<double>.Build.DenseOfArray(new double[3]{0, 0, 0}));

            double intersection = mathUtil.Intersection (thisAircraft, stoppingAircraft, 1);

            Assert.AreEqual (Math.Sign(1), Math.Sign(intersection)); //On collision course

            stoppingAircraft.Velocity = Vector<double>.Build.DenseOfArray (new double[3]{ 0, 0, 0 });
            // stoppingAircraft has stopped moving completely
            intersection = mathUtil.Intersection (stoppingAircraft, thisAircraft, 1);

            Assert.AreEqual (Math.Sign(1), Math.Sign(intersection)); //Still collision

            thisAircraft.Velocity = Vector<double>.Build.DenseOfArray (new double[3]{ 1, -10, 0 });
            intersection = mathUtil.Intersection (stoppingAircraft, thisAircraft, 1);

            Assert.AreEqual (-1.0, intersection); //No intersection after thisAircraft changed course
        }
Ejemplo n.º 5
0
        public void IntersectionTest()
        {
            //Test1
            MathCalcUtility utility = new MathCalcUtility ();

            Vector<double> plane1DataFrom = Vector<double>.Build.DenseOfArray(new double[3]{0, -1, 0});
            Vector<double> plane1DataTo = Vector<double>.Build.DenseOfArray(new double[3]{1, 0, 0});

            Vector<double> plane2DataFrom = Vector<double>.Build.DenseOfArray(new double[3]{6, -1, 0});
            Vector<double> plane2DataTo = Vector<double>.Build.DenseOfArray(new double[3]{5, 0, 0});

            Vector<double> plane1vec = utility.CalculateVector (plane1DataFrom, plane1DataTo);
            Vector<double> plane2vec = utility.CalculateVector (plane2DataFrom, plane2DataTo);

            Aircraft aircraft1 = new Aircraft ("1", plane1vec);
            aircraft1.DataBuffer.Add (plane1DataTo);

            Aircraft aircraft2 = new Aircraft ("2", plane2vec);
            aircraft2.DataBuffer.Add (plane2DataTo);

            double time = utility.Intersection (aircraft1, aircraft2, 0);

            Assert.AreEqual (2.0, time);
        }