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 the calculation functions which are calles more than one time
 /// </summary>
 private void DoIterativeWork()
 {
     //iterate as long as the result is not exact enough
     //ToDo: Add loop for iterations
     Track.Instance.Calculate();
     Track.Instance.StoreResult();
     Suspension.Calculate();
     Suspension.StoreResult();
     Wheels.Calculate();
     Wheels.StoreResult();
     OverallCar.Calculate();
     OverallCar.StoreResult();
 }