public APoint3D ToPoint3D(APoint p)
        {
            if (p.X < 0 || p.Y < 0)
            {

            }
            var y = Math.Sin(__Lat);
            y = (1.0 + y) / (1.0 - y);
            y = 0.5 * Math.Log(y);
            var k = (int)(0.5 * y * __Width / Math.PI);

            y = Math.PI * (2.0 * (p.Y - k) - __height) / __Width;
            y = Math.Exp(2 * y);
            y = (y - 1) / (y + 1);
            var cos2 = Math.Sqrt(1.0 - y * y);

            var theta1 = __Lng - 0.5 * Math.PI + Math.PI * (2.0 * p.X - __Width) / __Width;

            return new APoint3D(Math.Cos(theta1) * cos2, y, -Math.Sin(theta1) * cos2);
        }
Esempio n. 2
0
 public bool Equals(APoint p)
 {
     return X == p.X && Y == p.Y;
 }
        private UColor[,] MainGen(
            CancellationToken token, // token for canceling
            int x, int y, int w, int h, // local generation
            int width, int height, // Generation original size
            double seed,
            ProjectionType projection,
            double seaLevel = 0,
            double lng = 0, double lat = 0
            )
        {
            __TmpImage = new UColor[w, h];

            __StartGenPos = new APoint(x, y);
            __EndGenPos = new APoint(x + w, y + h);

            __CancellationToken = token;

            __GenerationWidth = w;
            __GenerationHeigth = h;

            __Shades = new byte[w, h];

            Width = width;
            Height = height;

            __Lng = lng;
            __Lat = lat;

            if (__Lng > 180)
                __Lng -= 360;
            __Lng = __Lng * DEG2_RAD;
            __Lat = __Lat * DEG2_RAD;

            __SLat = Math.Sin(__Lat);
            __CLat = Math.Cos(__Lat);
            __SLng = Math.Sin(__Lng);
            __CLng = Math.Cos(__Lng);

            switch (projection)
            {
                case ProjectionType.Mercator:
                    Mercator();
                    break;
                case ProjectionType.Peter:
                    Peter();
                    break;
                case ProjectionType.Square:
                    Squarep();
                    break;
                //case ProjectionType.Mollweide:
                //    mollweide();
                //    break;
                //case ProjectionType.Sinusoid:
                //    Sinusoid();
                //    break;
                case ProjectionType.Stereo:
                    Stereo();
                    break;
                case ProjectionType.Orthographic:
                    Orthographic();
                    break;
                //case ProjectionType.Gnomonic:
                //    Gnomonic();
                //    break;
                //case ProjectionType.Icosahedral:
                //    Icosahedral();
                //    break;
                //case ProjectionType.Azimuth:
                //    Azimuth();
                //    break;
                //case ProjectionType.Conical:
                //    Conical();
                //    break;
                //case ProjectionType.Heightfield:
                //    Heightfield();
                //    break;
                default:
                    throw new NotImplementedException(projection.ToString());
            }

            if (__CancellationToken.IsCancellationRequested)
                return null;

            if (__ShadeType != ShadeType.None)
            {
                SmoothShades();

                for (int _y = 0; _y < __GenerationHeigth; _y++)
                {
                    for (int _x = 0; _x < __GenerationWidth; _x++)
                    {
                        var s = __Shades[_x, _y];
                        var uc = __TmpImage[_x, _y];
                        if (s != 255)
                        {
                            __TmpImage[_x, _y] = ReturnFuckngColor(
                                uc.A,
                                (s * uc.R / 150),
                                (s * uc.G / 150),
                                (s * uc.B / 150)
                                );
                        }
                    }
                }
            }

            return __TmpImage;
        }