Exemple #1
0
        public AeroForceCache(double maxCacheVelocity, double maxCacheAoA, double atmosphereDepth, int vRes, int aoaRes, int altRes, VesselAerodynamicModel model)
        {
            Model = model;

            this.MaxVelocity   = maxCacheVelocity;
            this.MaxAoA        = maxCacheAoA;
            this.MaxAltitude   = atmosphereDepth;
            VelocityResolution = vRes;
            AoAResolution      = aoaRes;
            AltitudeResolution = altRes;

            InternalArray = new Vector2[VelocityResolution, AoAResolution, AltitudeResolution];
            for (int v = 0; v < VelocityResolution; ++v)
            {
                for (int a = 0; a < AoAResolution; ++a)
                {
                    for (int m = 0; m < AltitudeResolution; ++m)
                    {
                        InternalArray[v, a, m] = new Vector2(float.NaN, float.NaN);
                    }
                }
            }
        }
Exemple #2
0
        private IEnumerable <bool> ComputeTrajectoryIncrement(Vessel vessel, DescentProfile profile)
        {
            // create or update aerodynamic model
            if (aerodynamicModel_ == null || !aerodynamicModel_.isValidFor(vessel, vessel.mainBody))
            {
                aerodynamicModel_ = AerodynamicModelFactory.GetModel(vessel, vessel.mainBody);
            }
            else
            {
                aerodynamicModel_.IncrementalUpdate();
            }
            // create new VesselState from vessel, or null if it's on the ground
            var state = new VesselState(vessel);

            // iterate over patches until MaxPatchCount is reached
            for (int patchIdx = 0; patchIdx < Settings.MaxPatchCount; ++patchIdx)
            {
                // stop if we don't have a vessel state
                if (state == null)
                {
                    state = new VesselState(vessel);
                }

                // If we spent more time in this calculation than allowed, pause until the next frame


                if (incrementTime_.ElapsedMilliseconds > MaxIncrementTime)
                {
                    yield return(false);
                }
                // if we have a patched conics solver, check for maneuver nodes
                if (null != attachedVessel.patchedConicSolver)
                {
                    // search through maneuver nodes of the vessel
                    var maneuverNodes = attachedVessel.patchedConicSolver.maneuverNodes;
                    foreach (var node in maneuverNodes)
                    {
                        // if the maneuver node time corresponds to the end time of the last patch
                        if (node.UT == state.Time)
                        {
                            // add the velocity change of the burn to the velocity of the last patch
                            state.Velocity += node.GetBurnVector(CreateOrbitFromState(state));
                            break;
                        }
                    }

                    // Add one patch, then pause execution after every patch
                    foreach (bool result in AddPatch(state, true))
                    {
                        yield return(false);
                    }
                }
                else
                {
                    // Add one patch, then pause execution after every patch
                    foreach (bool result in AddPatch(state, false))
                    {
                        yield return(false);
                    }
                }

                state = AddPatch_outState;
            }
        }