Exemplo n.º 1
0
        public override Color GetPixel(int x, int y)
        {
            double theta = (double)x / m_Size.Width * DMS.TAU; //longitude
            double phi = (double)y / m_Size.Height * DMS.HALFTAU; //angle down from north pole (latitude-ish)
            Point2D pt = new Point2D(theta, phi);

            //"unroll" by adding TAU * number of turns to theta, (and then back it off one)
            while( DMS.TAU * pt.Y > m_x * pt.X )
            {
                pt.X += DMS.TAU;
            }
            pt.X -= DMS.TAU;

            //undo our spiral by rotating it clockwise
            pt.Theta -= m_alpha;

            //scale it so that we're referencing the stretched textStrip in it's native resolution
            pt.Scale(m_stretchedSize.Width / (m_n * m_y));

            //unstretch it
            double horiz = pt.X * 2.0 / m_stretchedSize.Width; // 0 ... 2
            horiz -= 1.0;                                      // -1 ... 1
            horiz *= m_maxStretched;                           // -m_maxStretched ... m_maxStretched
            horiz = unstretch(horiz);                          // -m_maxUnstretched ... m_maxUnstretched
            horiz /= m_maxUnstretched;                         // -1 ... 1
            horiz += 1.0;                                      // 0 ... 2
            horiz *= 0.5 * m_textStripeSize.Width;             // 0 ... textwidth
            pt.X = horiz;

            //wind our strip back up so we can reference the right pixel in the source
            while (pt.X >= m_Source.Width)
            {
                pt.X -= m_Source.Width;
                pt.Y += m_textStripeSize.Height;
            }

            if (pt.Y >= m_Source.Height || pt.Y < 0.0 || pt.X < 0.0 )
                return m_Blank;

            return m_Source.GetPixel((int)pt.X, (int)pt.Y);
        }
Exemplo n.º 2
0
        public Color GetSpherePixel(Point3D point)
        {
            if (mSourceType == DMSImageType.Equirectangular)
            {
                //latitude and longitude are pulled straight from spherical coordinates of the 3d pooint
                double longitude = point.Theta / DMS.TAU;
                double latitude = point.Phi / DMS.HALFTAU; //but really 0 is at the north pole.

                if (longitude < 0.0 ) longitude += 1.0;

                Point2D EquirectangularLocation = new Point2D( longitude, latitude );
                return GetPixel(EquirectangularLocation);
            }
            else
            {
                // we can get the location on a mirror ball image from the spherical coordinates by taking the sin of phi.
                Point2D MirrorBallLocation = Point2D.FromPolar(Math.Sin(point.Phi/2.0), point.Theta);

                //the coordinates are from -1 to 1, we need to convert them to 0 to 1
                MirrorBallLocation += new Point2D(1, 1);
                MirrorBallLocation.Scale(0.5);
                return GetPixel(MirrorBallLocation);
            }
        }