Пример #1
0
        public Normal3 Sample(Random random)
        {
            ISphere sphere    = new UnitSphere(Position3.Origin);
            Normal3 direction = ((Direction3)sphere.SurfacePosition(random)).Normalized();

            return(IDirection3.InSameClosedHemisphere(Orientation, direction) ? direction : -direction);
        }
Пример #2
0
        private double[] applyInverted(double[] p)
        {
            double[] result = new double[p.Length];

            int delta = 2;

            if (p.Length % 3 == 0)
            {
                delta = 3;
            }

            for (int i = 0; i < p.Length / 2; i += delta)
            {
                if (delta == 3)
                {
                    result[i + 2] = p[i + 2];
                }

                Vector3 vector = _center + _xAxis * p[i] + _yAxis * p[i + 1];
                result[i + 1] = Radians.ToDegrees(UnitSphere.Latitude(vector));
                result[i]     = Radians.ToDegrees(UnitSphere.Longitude(vector));
            }

            return(result);
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the MapAround.CoordinateSystems.Transformations.Gnomonic.
        /// </summary>
        /// <param name="centerLongitude">Longitude of projection center in degrees</param>
        /// <param name="centerLatitude">Latitude of projection center in degrees</param>
        public Gnomonic(double centerLongitude, double centerLatitude)
            : this(false)
        {
            _center =
                UnitSphere.LatLonToGeocentric(
                    Degrees.ToRadians(centerLatitude),
                    Degrees.ToRadians(centerLongitude));

            double[] center = { _center.X, _center.Y, _center.Z };
            double[] vector = new double[3];

            int k = getMinEntryIndex(center);
            int j = (k + 2) % 3;
            int i = (j + 2) % 3;

            vector[i] = -center[j];
            vector[j] = center[i];
            vector[k] = 0;

            _xAxis = (new Vector3(vector[0], vector[1], vector[2])).Unitize();
            _yAxis = _center.CrossProduct(_xAxis);
        }
Пример #4
0
        private double[] apply(double[] p)
        {
            double[] result = new double[p.Length];

            int delta = 2;

            if (p.Length % 3 == 0)
            {
                delta = 3;
            }

            for (int i = 0; i < p.Length / 2; i += delta)
            {
                if (delta == 3)
                {
                    result[i + 2] = p[i + 2];
                }

                Vector3 vector =
                    UnitSphere.LatLonToGeocentric(
                        Degrees.ToRadians(p[i + 1]),
                        Degrees.ToRadians(p[i]));

                double r = vector * _center;

                if (r < 1e-8)
                {
                    throw new ApplicationException();
                }

                vector = vector / r;

                result[i]     = vector * _xAxis;
                result[i + 1] = vector * _yAxis;
            }

            return(result);
        }
Пример #5
0
        public Normal3 Sample(Random random)
        {
            ISphere sphere = new UnitSphere(Position3.Origin);

            return(new Normal3(sphere.SurfacePosition(random).Vector));
        }