Exemple #1
0
        internal void DrawFrame(Point2[] pixels, DataForMap2D data, Bitmap bmp, int step = 0)
        {
            switch (Projection)
            {
            case Projection.Healpix:
                data.Draw(bmp, 0, pixels, YResolution);
                break;

            case Projection.Healpix2Equirectangular:
            case Projection.Equirectangular:
                foreach (var pixel in pixels)
                {
                    var    coor = Equirectangular.CoorFromXY(pixel, YResolution, HealpixManager, step);
                    double?altitude;
                    if (Projection == Projection.Healpix2Equirectangular)
                    {
                        var deltas = data.ApproxMan.GetDeltas(coor);
                        altitude = data.ApproxMan.GetMeanAltitude(deltas);
                        data.CheckMaxMin(altitude);
                    }
                    else
                    {
                        altitude = data.GetAltitude(new HealCoor(coor));
                    }

                    if (altitude.HasValue)
                    {
                        data.Colors.SetPixelOnBmp(altitude.Value, bmp, pixel, Scale);
                    }
                }
                break;
            }
        }
        /// <summary>
        /// also sets Colors
        ///
        /// good to override InitAltitudes(...) but seems not possible
        /// </summary>
        internal void InitPoints(Point2[] pixels, bool isGrey)
        {
            ColorsManager colorsManager = null;

            switch (_map.Projection)
            {
            case Projection.Healpix:
            case Projection.Healpix2Equirectangular:     /*mean min, nax will be calculated later  */
                colorsManager = InitAltitudes(ApproxMan.Pixels, isGrey);
                break;

            case Projection.Equirectangular:     /*min and max may not be precalculated*/
                double?min = MinDefault, max = MaxDefault;
                if (min == null || max == null)
                {
                    // slow?
                    var pix = (from pixel in pixels
                               select new HealCoor(Equirectangular.CoorFromXY(pixel, _map.YResolution, HealpixManager))
                               ).ToArray();
                    colorsManager = InitAltitudes(pix, isGrey);
                }
                break;
            }
            colorsManager.SetScales(_map.ColorsAbove, _map.ColorsUnder);
        }
Exemple #3
0
        /* data in spherical geocoordinates!!!
         * 5 arc-min grids contain 2,160 x 4,320 data points, are 18 MB in size and extend from
         * -90+5/120 deg to  +90-5/120 deg in latitude direction, and from
         * -180+5/120 deg to +180-5/120 deg in longitude direction.
         *
         * for 1 arc-min The first record is the South-West corner (-89.9917 deg latitude,
         * -179.9917 deg longitude), and the last record is the North-East corner
         * (89.9917 deg latitude, 179.9917 deg latitude)
         * Each grid file contains 10,800 x 21,600 = 233,280,000 records */
        public int Offset(int accuracyMin = 1)
        {
            var equirectangular = new Equirectangular(accuracyMin);
            var coor            = new Coor {
                X = X, Y = -Y
            };

            return(equirectangular.FullOffset(coor));
        }
Exemple #4
0
        /// <summary>
        /// Gets the apex
        /// </summary>
        /// <param name="canvasHeight">the canvas height</param>
        /// <returns></returns>
        public Vertex GetApex(double canvasHeight)
        {
            if (canvasHeight <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(canvasHeight), $"canvasHeight cannot be less than or equal to 0: {canvasHeight}");
            }

            return(Equirectangular.ApexOf(GetVertex(canvasHeight, true),
                                          GetVertex(canvasHeight, false)));
        }
 protected void Circle(T basin, double r = .2)
 {
     if (basin != null)
     {
         var width = .03;//.05 for k4
         foreach (var pixel in Data.PixMan.Pixels)
         {
             var healCoor = (HealCoor)pixel;
             var dist     = basin.DistanceTo(healCoor);
             if (Data.Colors != null &&
                 dist >= r - width && dist <= r + width)
             {
                 var eqProjection = new Equirectangular(HealpixManager, YResolution);
                 var point        = eqProjection.Offset(healCoor);
                 Data.Colors.SetPixelOnBmp(Color.FromArgb(255, 174, 201), Bmp,
                                           (int)(point.X), (int)point.Y, Scale);
             }
         }
     }
 }
        protected void ChangeRotation(int step, double koef = 10000)
        {
            if (koef > 0 && EllipsoidAcceleration.SiderealDayInSeconds < double.MaxValue / 2 ||
                -koef < EllipsoidAcceleration.SiderealDayInSeconds)
            {
                EllipsoidAcceleration.SiderealDayInSeconds += koef;
                foreach (var basin in Data.PixMan.Pixels)
                {
                    if (Data.SamePolesAndEquatorGravitation)
                    {
                        basin.gHpure = 0;
                    }
                    basin.RecalculateDelta_g();
                }

                var eqProjection = new Equirectangular(HealpixManager, YResolution);
                var point        = eqProjection.Offset(Data.PixMan.Pixels[HealpixManager.RingsCount / 2]);
                var line         = (int)(point.X + step);
                ChangeLines.Add(Math.Max(0, line));
            }
        }
 public virtual void Draw(
     Bitmap bmp,
     double deltaX      = 0,
     IEnumerable basins = null,
     int yResolution    = 2,
     int scale          = 1)
 {
     if (basins != null && Colors != null)
     {
         foreach (var pixel in basins)
         {
             var healCoor     = (HealCoor)pixel;
             var eqProjection = new Equirectangular(HealpixManager, yResolution);
             var point        = eqProjection.Offset(healCoor);
             Colors.SetPixelOnBmp(
                 healCoor.Altitude,
                 bmp,
                 (int)(point.X + deltaX),
                 (int)point.Y, scale);
         }
     }
 }
        public void Offset()
        {
            var e    = new Equirectangular(5);
            var coor = new Coor {
                X = 0, Y = 0
            };

            Assert.AreEqual(2160, e.Offset(coor).X);
            Assert.AreEqual(1080, e.Offset(coor).Y);

            e = new Equirectangular(new HealpixManager(5));
            Assert.AreEqual(64, e.Offset(coor).X); // or 64?
            Assert.AreEqual(32, e.Offset(coor).Y);
            coor = new Coor {
                X = 180, Y = -90
            };
            Assert.AreEqual(127, e.Offset(coor).X);
            Assert.AreEqual(64, e.Offset(coor).Y); // or 64?

            coor = new Coor {
                X = -180, Y = -90
            };
            Assert.AreEqual(0, e.Offset(coor).X);
        }