Beispiel #1
0
        public void ApplyForce(FARAeroSection.PartData pd, Vector3 localVel, Vector3 forceVector, Vector3 torqueVector)
        {
            double tmp = 0.0005 * Vector3.SqrMagnitude(localVel);
            double dynamicPressurekPa = tmp * atmDensity;
            double dragFactor         = dynamicPressurekPa *
                                        Mathf.Max(PhysicsGlobals.DragCurvePseudoReynolds.Evaluate(atmDensity *
                                                                                                  Vector3.Magnitude(localVel)),
                                                  1.0f);
            double liftFactor = dynamicPressurekPa;

            Vector3 localVelNorm   = Vector3.Normalize(localVel);
            Vector3 localForceTemp = Vector3.Dot(localVelNorm, forceVector) * localVelNorm;
            Vector3 partLocalForce =
                localForceTemp * (float)dragFactor + (forceVector - localForceTemp) * (float)liftFactor;

            forceVector  = pd.aeroModule.part.transform.TransformDirection(partLocalForce);
            torqueVector = pd.aeroModule.part.transform.TransformDirection(torqueVector * (float)dynamicPressurekPa);
            if (float.IsNaN(forceVector.x) || float.IsNaN(torqueVector.x))
            {
                return;
            }
            Vector3 centroid =
                pd.aeroModule.part.transform.TransformPoint(pd.centroidPartSpace - pd.aeroModule.part.CoMOffset);

            center.AddForce(centroid, forceVector);
            center.AddTorque(torqueVector);
        }
Beispiel #2
0
 public Vector3 LocalVelocity(FARAeroSection.PartData pd)
 {
     if (pd.aeroModule.part == null || pd.aeroModule.part.partTransform == null)
     {
         return(Vector3.zero);
     }
     return(pd.aeroModule.part.partTransform.InverseTransformVector(worldVel));
 }
 public void ApplyForce(FARAeroSection.PartData pd, Vector3 localVel, Vector3 forceVector, Vector3 torqueVector)
 {
     pd.aeroModule.AddLocalForceAndTorque(forceVector, torqueVector, pd.centroidPartSpace);
 }
 public Vector3 LocalVelocity(FARAeroSection.PartData pd)
 {
     return(pd.aeroModule.partLocalVel);
 }