Exemplo n.º 1
0
        /// <summary>
        /// Convert this UTMPoint to a Unity Vector3, projected to the screen using the provided matrix.
        /// </summary>
        /// <param name="v">   </param>
        /// <param name="toScreen"></param>
        /// <returns></returns>
        public static Vector3 ToScreen(this UTMPoint v, Matrix4x4 toScreen)
        {
            if (v is null)
            {
                throw new ArgumentNullException(nameof(v));
            }

            return(Vector3.Transform(v.ToSystemVector3(), toScreen));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Convert a Vector3 with a given UTM Zone to a <see cref="UTMPoint"/>
        /// </summary>
        /// <returns>The utm.</returns>
        /// <param name="v">      Value.</param>
        /// <param name="donatedZone">Donated zone.</param>
        public static Vector3 ToSystemVector3(this UTMPoint v)
        {
            if (v is null)
            {
                throw new ArgumentNullException(nameof(v));
            }

            return(new Vector3(v.X, v.Z, v.Y));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Converts this UTMPoint to a Latitude/Longitude point using the WGS-84 datum. The
        /// coordinate pair's units will be in meters, and should be usable to make distance
        /// calculations over short distances. /// reference: http://www.uwgb.edu/dutchs/usefuldata/utmformulas.htm
        /// </summary>
        /// <param name="utm">The UTM point to convert</param>
        /// <returns>The latitude/longitude</returns>
        public static LatLngPoint ToLatLng(this UTMPoint utm)
        {
            if (utm is null)
            {
                throw new ArgumentNullException(nameof(utm));
            }

            var    N0         = utm.Hemisphere == UTMPoint.GlobeHemisphere.Northern ? 0.0 : DatumWGS_84.FalseNorthing;
            var    xi         = (utm.Y - N0) / (DatumWGS_84.pointScaleFactor * DatumWGS_84.A);
            var    eta        = (utm.X - DatumWGS_84.E0) / (DatumWGS_84.pointScaleFactor * DatumWGS_84.A);
            var    xiPrime    = xi;
            var    etaPrime   = eta;
            double sigmaPrime = 1;
            double tauPrime   = 0;

            for (var j = 1; j <= 3; ++j)
            {
                var beta    = DatumWGS_84.beta[j - 1];
                var je2     = 2 * j * xi;
                var jn2     = 2 * j * eta;
                var sinje2  = Sin(je2);
                var coshjn2 = Cosh(jn2);
                var cosje2  = Cos(je2);
                var sinhjn2 = Sinh(jn2);

                xiPrime    -= beta * sinje2 * coshjn2;
                etaPrime   -= beta * cosje2 * sinhjn2;
                sigmaPrime -= 2 * j * beta * cosje2 * coshjn2;
                tauPrime   -= 2 * j * beta * sinje2 * sinhjn2;
            }

            var chi = Asin(Sin(xiPrime) / Cosh(etaPrime));

            var lat = chi;

            for (var j = 1; j <= 3; ++j)
            {
                lat += DatumWGS_84.delta[j - 1] * Sin(2 * j * chi);
            }

            float long0 = (utm.Zone * 6) - 183;
            var   lng   = Atan(Sinh(etaPrime) / Cos(xiPrime));

            return(new LatLngPoint(
                       Radians.Degrees((float)lat),
                       long0 + Radians.Degrees((float)lng),
                       utm.Z));
        }