Exemplo n.º 1
0
        public void TestWheels()
        {
            _wheels.Calculate();
            _wheels.StoreResult();
            Assert.IsTrue(new Vector2(1, 0).Rotate(Math.PI / 4).Equals(WheelOutput.LastCalculations[0].Direction.Normalize(), 1e-5f));
            Assert.IsTrue(new Vector2(1, 0).Rotate(Math.PI / 5).Equals(WheelOutput.LastCalculations[1].Direction.Normalize(), 1e-5f));
            Assert.IsTrue(new Vector2(1, 0).Equals(WheelOutput.LastCalculations[2].Direction.Normalize(), 1e-5f));
            Assert.IsTrue(new Vector2(1, 0).Equals(WheelOutput.LastCalculations[3].Direction.Normalize(), 1e-5f));

            Assert.AreEqual(-100 / 9.25, WheelOutput.LastCalculations[0].LateralAcceleration, 1e-5);
            Assert.AreEqual(-100 / 10.75, WheelOutput.LastCalculations[1].LateralAcceleration, 1e-5);
            Assert.AreEqual(0, WheelOutput.LastCalculations[2].LateralAcceleration);
            Assert.AreEqual(0, WheelOutput.LastCalculations[3].LateralAcceleration);

            Assert.AreEqual(0, WheelOutput.LastCalculations[0].Slip);
            Assert.AreEqual(0, WheelOutput.LastCalculations[1].Slip);
            Assert.AreEqual(0, WheelOutput.LastCalculations[2].Slip);
            Assert.AreEqual(0, WheelOutput.LastCalculations[3].Slip);

            Assert.AreEqual(0, WheelOutput.LastCalculations[0].LongitudinalAccelerationForce);
            Assert.AreEqual(0, WheelOutput.LastCalculations[1].LongitudinalAccelerationForce);
            Assert.AreEqual(200, WheelOutput.LastCalculations[2].LongitudinalAccelerationForce);
            Assert.AreEqual(200, WheelOutput.LastCalculations[3].LongitudinalAccelerationForce);

            Assert.AreEqual(5, WheelOutput.LastCalculations[0].LongitudinalDecelerationForce);
            Assert.AreEqual(5, WheelOutput.LastCalculations[1].LongitudinalDecelerationForce);
            Assert.AreEqual(5, WheelOutput.LastCalculations[2].LongitudinalDecelerationForce);
            Assert.AreEqual(5, WheelOutput.LastCalculations[3].LongitudinalDecelerationForce);
        }
        /// <summary>
        /// this function is used to call all the calculate functions which runs once
        /// </summary>
        private void DoWork()
        {
            Aerodynamic.Calculate();
            Aerodynamic.StoreResult();
            Brake.Calculate();
            Brake.StoreResult();
            Engine.Calculate();
            Engine.StoreResult();
            GearBox.Calculate();
            GearBox.StoreResult();
            SecondaryDrive.Calculate();
            SecondaryDrive.StoreResult();
            Steering.Calculate();
            Steering.StoreResult();

            DoIterativeWork();

            //call the CalculateBackwards functions
            Aerodynamic.CalculateBackwards();
            Aerodynamic.StoreResult();
            Brake.CalculateBackwards();
            Brake.StoreResult();
            Engine.CalculateBackwards();
            Engine.StoreResult();
            GearBox.CalculateBackwards();
            GearBox.StoreResult();
            SecondaryDrive.CalculateBackwards();
            SecondaryDrive.StoreResult();
            Steering.CalculateBackwards();
            Steering.StoreResult();
            Track.Instance.CalculateBackwards();
            Track.Instance.StoreResult();
            Wheels.CalculateBackwards();
            Wheels.StoreResult();
            OverallCar.CalculateBackwards();
            OverallCar.StoreResult();
            Suspension.CalculateBackwards();
            Suspension.StoreResult();
        }