Latitude() public static method

public static Latitude ( Vector3 p ) : double
p Vector3
return double
Exemplo n.º 1
0
        /// <summary>
        /// Calculates the longitude and latitude of the center
        /// of projection to the passed values ​​of latitudes and longitudes.
        /// </summary>
        /// <param name="latLonSequence">Array of real numbers that contains the latitude and longitude
        /// (to be completed in the form of a sequence of pairs: "latitude", "longitude")</param>
        /// <param name="centerLat">The output value of latitude</param>
        /// <param name="centerLon">The output value of the longitude</param>
        public static void GetCenter(double[] latLonSequence, out double centerLat, out double centerLon)
        {
            if (latLonSequence.Length % 2 != 0)
            {
                throw new ArgumentException("The array should contain an even number of elements", "values");
            }

            int    n = latLonSequence.Length / 2;
            double x = 0;
            double y = 0;
            double z = 0;

            for (int i = 0; i < latLonSequence.Length; i += 2)
            {
                Vector3 v = UnitSphere.LatLonToGeocentric(latLonSequence[i], latLonSequence[i + 1]);
                x += v.X / n;
                y += v.Y / n;
                z += v.Z / n;
            }

            Vector3 result = new Vector3(x, y, z);

            centerLat = UnitSphere.Latitude(result);
            centerLon = UnitSphere.Longitude(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Calculates the latitude and longitude points.
        /// </summary>
        /// <param name="x">X coordinate in the plane of projection</param>
        /// <param name="y">Y-coordinate in the plane of projection</param>
        /// <param name="lat">Latitude of the</param>
        /// <param name="lon">Longitude points</param>
        public void Unproject(double x, double y, out double lat, out double lon)
        {
            Vector3 vector = _center + _xAxis * x + _yAxis * y;

            lat = UnitSphere.Latitude(vector);
            lon = UnitSphere.Longitude(vector);
        }