Пример #1
0
        public List <GeoMath.GeoLocation> UniformDistributionInCircle(GeoMath.GeoLocation iOrigin, double iRangeKm, int iPointCount)
        {
            const double alpha = 2; // indicates how much one cares about the evenness of boundary
            int          boundaryPointCount = Math.Max(1, (int)Math.Round(alpha * Math.Sqrt((double)iPointCount)));
            double       cGoldenRatio       = (Math.Sqrt(5) + 1) / 2;
            double       pointRadius        = 0.0;
            double       pointTheta         = 0.0;

            GeoMath.GeoLocation        origin       = iOrigin;
            GeoMath.GeoLocation        point        = origin;
            List <GeoMath.GeoLocation> distribution = new List <GeoMath.GeoLocation>();

            Console.WriteLine("Computing uniform point distribution.");

            computeRadiusDel computeRadius = (k, n, b) =>
            {
                double radius = 0.0;

                Console.WriteLine("computeRadius(k=" + k + ", n=" + n + ", b=" + b);

                if (k < 1)
                {
                    radius = 0;
                }
                else if (k > (n - b))
                {
                    radius = 1; // put on the boundary
                }
                else
                {
                    radius = Math.Sqrt(k - 0.5) / Math.Sqrt(n - (b + 1) / 2); // apply square root
                }
                return(radius);
            };

            // the selected resolution determines the number of data points distributed
            for (int k = 1; k <= iPointCount; ++k)
            {
                pointRadius = computeRadius(k, iPointCount, boundaryPointCount);
                pointTheta  = 2 * Math.PI * k / (cGoldenRatio * cGoldenRatio);

                Console.WriteLine(pointRadius + ", " + pointTheta);

                point = GeoMath.FindPointAtDistanceFrom(origin, pointTheta, pointRadius * iRangeKm);

                distribution.Add(point);
            }

            return(distribution);
        }
Пример #2
0
 public WeatherScenario()
 {
     Position       = new GeoMath.GeoLocation();
     RadiusKm       = 250000;
     DataResolution = Resolution.Low;
 }