Ejemplo n.º 1
0
        Vector4 SampleColor(float x, float y)
        {
            int ix = (int)Mathf.Floor(x);
            int iy = (int)Mathf.Floor(y);

            x -= ix;
            y -= iy;

            float cx = 1.0f - x;
            float cy = 1.0f - y;

            var c1 = Source.Get(ix, iy);
            var c2 = Source.Get(ix + 1, iy);
            var c3 = Source.Get(ix, iy + 1);
            var c4 = Source.Get(ix + 1, iy + 1);

            var color = new Vector4
                        (
                (c1.x * cx + c2.x * x) * cy + (c3.x * cx + c4.x * x) * y,
                (c1.y * cx + c2.y * x) * cy + (c3.y * cx + c4.y * x) * y,
                (c1.z * cx + c2.z * x) * cy + (c3.z * cx + c4.z * x) * y,
                (c1.w * cx + c2.w * x) * cy + (c3.w * cx + c4.w * x) * y
                        );

            return(color);
        }
Ejemplo n.º 2
0
        private Vector4 SampleColor(double lon, double lat)
        {
            lon = lon / Math.PI * (Source.Width / 2.0);
            lat = lat / Math.PI * Source.Height;

            int ilon = (int)Math.Floor(lon);
            int ilat = (int)Math.Floor(lat);

            lon -= ilon;
            lat -= ilat;

            double clon = 1.0 - lon;
            double clat = 1.0 - lat;

            var c1 = Source.Get((ilon + Source.Width) % Source.Width, ilat);
            var c2 = Source.Get((ilon + Source.Width + 1) % Source.Width, ilat);
            var c3 = Source.Get((ilon + Source.Width) % Source.Width, ilat + 1);
            var c4 = Source.Get((ilon + Source.Width + 1) % Source.Width, ilat + 1);

            var color = new Vector4
                        (
                (float)((c1.x * clon + c2.x * lon) * clat + (c3.x * clon + c4.x * lon) * lat),
                (float)((c1.y * clon + c2.y * lon) * clat + (c3.y * clon + c4.y * lon) * lat),
                (float)((c1.z * clon + c2.z * lon) * clat + (c3.z * clon + c4.z * lon) * lat),
                (float)((c1.w * clon + c2.w * lon) * clat + (c3.w * clon + c4.w * lon) * lat)
                        );

            return(color);
        }
Ejemplo n.º 3
0
        public float SampleHeight(float x, float y)
        {
            int ix = (int)Mathf.Floor(x);
            int iy = (int)Mathf.Floor(y);

            x -= ix;
            y -= iy;

            float cx = 1.0f - x;
            float cy = 1.0f - y;
            float h1 = Source.Get(ix, iy).x;
            float h2 = Source.Get(ix + 1, iy).x;
            float h3 = Source.Get(ix, iy + 1).x;
            float h4 = Source.Get(ix + 1, iy + 1).x;

            return((h1 * cx + h2 * x) * cy + (h3 * cx + h4 * x) * y);
        }
Ejemplo n.º 4
0
        private float SampleHeight(double lon, double lat)
        {
            lon = lon / Math.PI * (Source.Width / 2.0);
            lat = lat / Math.PI * Source.Height;

            int ilon = (int)Math.Floor(lon);
            int ilat = (int)Math.Floor(lat);

            lon -= ilon;
            lat -= ilat;

            double clon = 1.0 - lon;
            double clat = 1.0 - lat;

            float h1 = Source.Get((ilon + Source.Width) % Source.Width, ilat).x;
            float h2 = Source.Get((ilon + Source.Width + 1) % Source.Width, ilat).x;
            float h3 = Source.Get((ilon + Source.Width) % Source.Width, ilat + 1).x;
            float h4 = Source.Get((ilon + Source.Width + 1) % Source.Width, ilat + 1).x;

            return((float)((h1 * clon + h2 * lon) * clat + (h3 * clon + h4 * lon) * lat));
        }