コード例 #1
0
        /// <summary>
        /// Calculates the total forces on the airframe.
        /// </summary>
        /// <param name="elapsedTime"></param>
        private void CalculateForces(float elapsedTime, Vector3 wind)
        {
            if (ApiModel.CalculateForces(elapsedTime, wind))
            {
                return;
            }
            Lift = GetLiftForce(wind);
            Drag = GetDragForce(wind);
            double sideLift             = GetSideLiftForce(wind);
            double sideDrag             = GetSideDragForce(wind);
            double sideGroundResistance = 0;
            double groundResistance     = 0;

            // verified : gravity, liftX, throttle, liftZ
            if (TouchedDown)
            {
                if ((ApiModel.Vx < 10f) && (ApiModel.Vx > 0.01))
                {
                    double realBeta = -Math.Atan2(ApiModel.Vy, ApiModel.Vx);
                    sideGroundResistance = Math.Sin(realBeta) * gravityMass;
                }
                groundResistance = ApiModel.Vx / 10.0;
            }

            ApiModel.Fx = (float)(+sideLift * Math.Sin(ApiModel.Beta)
                                  - sideDrag * Math.Cos(ApiModel.Beta)
                                  - Lift * Math.Sin(ApiModel.Alpha)
                                  - Drag * Math.Cos(ApiModel.Alpha)
                                  + AircraftParameters.MaximumThrust * Throttle * AircraftParameters.GetThrustCoefficient((double)ApiModel.Vx)
                                  - gravityMass * Math.Sin(ApiModel.Pitch)
                                  - groundResistance);
            ApiModel.Fy = (float)(+sideLift * Math.Cos(ApiModel.Beta) + sideDrag * Math.Sin(ApiModel.Beta) + gravityMass * Math.Sin(ApiModel.Roll) * Math.Cos(ApiModel.Pitch) + sideGroundResistance);
            ApiModel.Fz = (float)(-Lift * Math.Cos(ApiModel.Alpha) - Drag * Math.Sin(ApiModel.Alpha) + gravityMass * Math.Cos(ApiModel.Roll) * Math.Cos(ApiModel.Pitch));
        }