Exemple #1
0
        public override void OnUpdate()
        {
            var lat = vessel.mainBody.GetLatitude(this.vessel.GetWorldPos3D());

            celestrialBodyFieldStrengthMod = MagneticFieldDefinitionsHandler.GetMagneticFieldDefinitionForBody(vessel.mainBody).StrengthMult;
            flux           = collectionMultiplier * vessel.mainBody.GetBeltAntiparticles(_homeworld, vessel.altitude, lat);
            ParticleFlux   = flux.ToString("E");
            collectionRate = _effectiveFlux * PluginHelper.SecondsInHour;
            canCollect     = _moduleAnimateGeneric == null ? true :  _moduleAnimateGeneric.GetScalar == 1;
        }
        public static double GetBeltAntiparticles(this CelestialBody body, CelestialBody homeworld, double altitude, double lat)
        {
            if (body.flightGlobalsIndex != 0 && altitude <= PluginHelper.getMaxAtmosphericAltitude(body))
            {
                return(0);
            }

            BeltData beltdata;

            if (!BeltDataCache.TryGetValue(body.name, out beltdata))
            {
                double mp       = body.Mass;
                double rp       = body.Radius;
                double rt       = body.rotationPeriod;
                double relmp    = mp / homeworld.Mass;
                double relrp    = rp / homeworld.Radius;
                double relrt    = rt / homeworld.rotationPeriod;
                double peakbelt = 1.5 * homeworld.Radius * relrp;

                beltdata = new BeltData()
                {
                    density      = relmp * relrp / relrt * 50,
                    ampere       = peakbelt / Math.Sqrt(2),
                    strengthMult = MagneticFieldDefinitionsHandler.GetMagneticFieldDefinitionForBody(body.name).StrengthMult
                };

                BeltDataCache.Add(body.name, beltdata);
            }

            double beltparticles = beltdata.strengthMult * beltdata.density
                                   * Math.Sqrt(2 / Math.PI)
                                   * Math.Pow(altitude, 2)
                                   * Math.Exp(-Math.Pow(altitude, 2) / (2 * Math.Pow(beltdata.ampere, 2)))
                                   / (Math.Pow(beltdata.ampere, 3));

            if (body.flightGlobalsIndex == 0)
            {
                beltparticles = beltparticles / 1000;
            }

            return(beltparticles * Math.Abs(Math.Cos(lat / 180 * Math.PI)) * body.specialMagneticFieldScaling());
        }
Exemple #3
0
 public static double specialMagneticFieldScaling(this CelestialBody body)
 {
     return(MagneticFieldDefinitionsHandler.GetMagneticFieldDefinitionForBody(body.name).StrengthMult);
 }