Пример #1
0
 private ScalarValue GetDynPres()
 {
     if (shared.Vessel != FlightGlobals.ActiveVessel)
     {
         throw new KOSException("You may only call addons:FAR:DYNPRES from the active vessel.");
     }
     if (Available())
     {
         double?result = FARWrapper.GetFARDynPres();
         if (result != null)
         {
             return(result);
         }
     }
     throw new KOSUnavailableAddonException("DYNPRES", "Ferram");
 }
Пример #2
0
 private Vector GetAeroForce()
 {
     if (shared.Vessel != FlightGlobals.ActiveVessel)
     {
         throw new KOSException("You may only call addons:FAR:AEROFORCE from the active vessel.");
     }
     if (Available())
     {
         Vector3?aeroforce = FARWrapper.GetFARAeroForce(shared.Vessel);
         if (aeroforce != null)
         {
             Vector3 outvector = (Vector3)aeroforce;
             return(new Vector(outvector.x, outvector.y, outvector.z));
         }
     }
     throw new KOSUnavailableAddonException("AEROFORCE", "Ferram");
 }
Пример #3
0
        private Vector GetAeroForceAt(ScalarValue altitude, Vector Velocity)
        {
            if (shared.Vessel != FlightGlobals.ActiveVessel)
            {
                throw new KOSException("You may only call addons:FAR:AEROFORCEAT from the active vessel.");
            }
            if (Available())
            {
                Vector3d airVelocity = Velocity.ToVector3D();

                Vector3d totalForce = FARWrapper.PredictFARAeroForce(shared.Vessel, airVelocity, altitude);

                if (Double.IsNaN(totalForce.x) || Double.IsNaN(totalForce.y) || Double.IsNaN(totalForce.z))
                {
                    // Don't send NaN into the simulation as it would cause bad things (infinite loops, crash, etc.). I think this case only happens at the atmosphere edge, so the total force should be 0 anyway.
                    return(new Vector(Vector3d.zero.x, Vector3d.zero.y, Vector3d.zero.z));
                }

                return(new Vector(totalForce.x, totalForce.y, totalForce.z));
            }
            throw new KOSUnavailableAddonException("AEROFORCEAT", "Ferram");
        }
Пример #4
0
 public override BooleanValue Available()
 {
     return(FARWrapper.Wrapped());
 }