Example #1
0
        public static List <LatitudinalRegion> createLatitudinalRegions(int _numberOf, double _defaultTemp)
        {
            //create even number of regions and one default one
            List <LatitudinalRegion> bands = new List <LatitudinalRegion>();
            double            currentAngle = 0, currentOppositAngle = 0, halfValue;
            LatitudinalRegion region;

            if (_numberOf % 2 != 0)
            {
                throw new ArgumentException("Number of Regions created must be even");
            }

            region = new LatitudinalRegion(90, _defaultTemp);
            bands.Add(region);
            halfValue = _numberOf / 2;
            for (int i = 0; i < halfValue; i++)
            {
                double currentAngleFract = ((90.0 / (halfValue + 1)) * (i + 1));
                currentAngle        = 90 - currentAngleFract;
                currentOppositAngle = 90 + currentAngleFract;

                region = new LatitudinalRegion(currentAngle, _defaultTemp, (-1 * currentAngleFract));
                region.setTemperatureAtAngle(0, _defaultTemp);

                bands.Add(region);

                region = new LatitudinalRegion(currentOppositAngle, _defaultTemp, currentAngleFract);
                region.setTemperatureAtAngle(0, _defaultTemp);

                bands.Add(region);
            }

            return(bands);
        }
        public override void distributeHeat()
        {
            double maxtemp = temperatureBands.Max(x => x.getTemperature());
            double heatDistributionModifier;

            LatitudinalRegion sourceRegion = this.temperatureBands.Where(x => x.getTemperature() == maxtemp).FirstOrDefault();

            sourceRegion.AddTemperatureModifier(ParametriUtente.Science.TemperatureGradientModifierName, (-1 * HeatDistributionFactor));

            for (int i = 0; i < 2; i++)
            {
                LatitudinalRegion targetRegion;

                if ((sourceRegion.getRegionAngle()
                     + (sourceRegion.getFactor() * (i + 1))
                     ) < 180 &&
                    (sourceRegion.getRegionAngle()
                     - (sourceRegion.getFactor() * (i + 1))
                    ) > 0
                    )
                {
                    targetRegion = this.temperatureBands.Where(x => x.getRegionAngle() == sourceRegion.getRegionAngle()
                                                               + (sourceRegion.getFactor() * (i + 1))).FirstOrDefault();

                    if (targetRegion.getRegionAngle() > sourceRegion.getRegionAngle())
                    {
                        heatDistributionModifier = HeatDistributionFactor * ((HeatDistributionFactor - (i + 1)) / HeatDistributionFactor);
                    }
                    else
                    {
                        heatDistributionModifier = HeatDistributionFactor * ((HeatDistributionFactor - (i + 1)) / HeatDistributionFactor);
                    }



                    targetRegion.AddTemperatureModifier(ParametriUtente.Science.TemperatureGradientModifierName, heatDistributionModifier);
                }
            }
        }