예제 #1
0
        private void CalculateTurning()
        {
            // Initialize the properties in Tyre
            tyre.ForwardVelocity = ForwardVelocity;
            tyre.SteerAngle      = SteerAngle;
            tyre.LateralVelocity = Movement.LateralVelocity();
            tyre.YawVelocity     = Movement.YawVelocity();

            // Initialize the properties in Forces
            Forces.TyreForceFront = tyre.TyreForceFront();
            Forces.TyreForceRear  = tyre.TyreForceRear();

            // Initialize the properties in Movement
            Movement.FyTotal         = Forces.FyTotal();
            Movement.MzTotal         = Forces.MzMoment();
            Movement.DeltaT          = DeltaT;
            Movement.ForwardVelocity = ForwardVelocity;

            // Initialize the properties in Position
            previousYawVelocity      = Position.YawVelocity = Movement.YawVelocity();
            Position.LateralVelocity = Movement.LateralVelocity();
            Position.DeltaT          = DeltaT;
            Position.ForwardVelocity = ForwardVelocity;
            Position.YawAngle        = YawAngle;

            Position.YawVelocityIntegral();

            // Calculate the new world coordinates for the vehicle
            if (!reverseGear)
            {
                XCoordinate += Position.VehicleDisplacementX();
                YCoordinate += Position.VehicleDisplacementY();
            }
            else
            {
                // If reverse gear has been initiated, reverse position
                XCoordinate -= Position.VehicleDisplacementX();
                YCoordinate -= Position.VehicleDisplacementY();
            }

            //Set previous movement values
            Movement.PreviousLateralVelocity = Movement.LateralVelocity();
            Movement.PreviousYawVelocity     = previousYawVelocity;

            YawAngle += DeltaT * Movement.YawVelocity();
        }