Ejemplo n.º 1
0
        public EllipsoidalPoint <TLinear, TAngular> ToEllipsoial <TLinear, TAngular>(IEllipsoid ellipsoid, AngleRange horizontalRange)
            where TLinear : LinearUnit, new()
            where TAngular : AngularUnit, new()
        {
            double tempSemiMajor = ellipsoid.SemiMajorAxis.ChangeTo <TLinear>().Value;

            double tempSemiMinor = ellipsoid.SemiMinorAxis.ChangeTo <TLinear>().Value;

            double e2TempValue = ellipsoid.FirstEccentricity * ellipsoid.FirstEccentricity;

            double tempX = this.X.ChangeTo <TLinear>().Value;

            double tempY = this.Y.ChangeTo <TLinear>().Value;

            double tempZ = this.Z.ChangeTo <TLinear>().Value;

            PolarPoint <TLinear, TAngular> tempValue = (new Cartesian2DPoint <TLinear>(new TLinear()
            {
                Value = tempX
            }, new TLinear()
            {
                Value = tempY
            })).ToPolar <TLinear, TAngular>(horizontalRange);

            double pTempValue = tempValue.Radius.Value;

            double nTempValue = ellipsoid.SemiMajorAxis.Value;

            double latitudeTempValue1 = Math.Atan(tempZ / pTempValue *
                                                  1 / (1 - (e2TempValue * nTempValue) / (nTempValue + 0)));

            if (latitudeTempValue1.Equals(double.NaN))
            {
                return(new EllipsoidalPoint <TLinear, TAngular>(ellipsoid, tempValue.Angle, (new Radian(0, horizontalRange))));
            }

            double latitudeTempValue2 = 0;

            bool conditionValue = true;

            do
            {
                nTempValue = ellipsoid.CalculateN(new Radian(latitudeTempValue1, AngleRange.MinusPiTOPi)).ChangeTo <TLinear>().Value;

                latitudeTempValue2 = Math.Atan(tempZ / pTempValue *
                                               1 / (1 - (e2TempValue * nTempValue) / (nTempValue + 0)));

                if (Math.Abs(0 - 0) + Math.Abs(latitudeTempValue2 - latitudeTempValue1) < allowedDifference)
                {
                    conditionValue = false;
                }
                else
                {
                    latitudeTempValue1 = latitudeTempValue2;
                }
            } while (conditionValue);

            return(new EllipsoidalPoint <TLinear, TAngular>(ellipsoid, tempValue.Angle, (new Radian(latitudeTempValue2, horizontalRange))));
        }
Ejemplo n.º 2
0
        public Ellipsoidal <TLinear, TAngular> ToEllipsoidalForm <TLinear, TAngular>(IEllipsoid ellipsoid, AngleRange horizontalRange)
            where TLinear : LinearUnit, new()
            where TAngular : AngularUnit, new()
        {
            IAngularCollection longitude = new AngularCollection <TAngular>(this.NumberOfPoints, horizontalRange);

            IAngularCollection latitude = new AngularCollection <TAngular>(this.NumberOfPoints, AngleRange.MinusPiTOPi);

            double tempSemiMajor = ellipsoid.SemiMajorAxis.ChangeTo <TLinear>().Value;

            double tempSemiMinor = ellipsoid.SemiMinorAxis.ChangeTo <TLinear>().Value;

            double e2TempValue = ellipsoid.FirstEccentricity * ellipsoid.FirstEccentricity;

            //double tempOrigionX = ellipsoid.Origion.X.ChangeTo<TLinear>().Value;

            //double tempOrigionY = ellipsoid.Origion.Y.ChangeTo<TLinear>().Value;

            //double tempOrigionZ = ellipsoid.Origion.Z.ChangeTo<TLinear>().Value;

            //Matrix rotationMatrix = (Transformation.CalculateEulerElementMatrix(ellipsoid.Omega, ellipsoid.Phi, ellipsoid.Kappa)).Transpose();

            //Matrix transferMatrix = new Matrix(new double[][] { new double[] { tempOrigionX, tempOrigionY, tempOrigionZ } });

            for (int i = 0; i < this.NumberOfPoints; i++)
            {
                double tempX = this.X[i].ChangeTo <TLinear>().Value;

                double tempY = this.Y[i].ChangeTo <TLinear>().Value;

                double tempZ = this.Z[i].ChangeTo <TLinear>().Value;

                //Matrix tempCartesian = new Matrix(new double[][] { new double[] { tempX, tempY, tempZ } });

                //Matrix tempGeodetic = rotationMatrix * (tempCartesian - transferMatrix);

                //tempX = tempGeodetic[0, 0];

                //tempY = tempGeodetic[1, 0];

                //tempZ = tempGeodetic[2, 0];

                PolarPoint <TLinear, TAngular> tempValue = (new Cartesian2DPoint <TLinear>(new TLinear()
                {
                    Value = tempX
                }, new TLinear()
                {
                    Value = tempY
                })).ToPolar <TLinear, TAngular>(horizontalRange);

                longitude[i] = tempValue.Angle;

                double pTempValue = tempValue.Radius.Value;

                double nTempValue = tempSemiMajor;

                //double hTempValue1 = Math.Sqrt(tempX * tempX + tempY * tempY + tempZ * tempZ)
                //                    -
                //                    Math.Sqrt(tempSemiMajor * tempSemiMinor);

                double latitudeTempValue1 = Math.Atan(tempZ / pTempValue *
                                                      1 / (1 - (e2TempValue * nTempValue) / (nTempValue + 0)));

                if (latitudeTempValue1.Equals(double.NaN))
                {
                    continue;
                }
                //double hTempValue2 = 0;

                double latitudeTempValue2 = 0;

                bool conditionValue = true;

                do
                {
                    nTempValue = ellipsoid.CalculateN(new Radian(latitudeTempValue1, AngleRange.MinusPiTOPi)).ChangeTo <TLinear>().Value;

                    //hTempValue2 = pTempValue / Math.Cos(latitudeTempValue1) - nTempValue;

                    latitudeTempValue2 = Math.Atan(tempZ / pTempValue *
                                                   1 / (1 - (e2TempValue * nTempValue) / (nTempValue + 0)));

                    if (Math.Abs(0 - 0) + Math.Abs(latitudeTempValue2 - latitudeTempValue1) < allowedDifference)
                    {
                        conditionValue = false;
                    }
                    else
                    {
                        //hTempValue1 = hTempValue2;

                        latitudeTempValue1 = latitudeTempValue2;
                    }
                } while (conditionValue);

                //height.SetTheValue(i, hTempValue2);

                latitude[i] = new Radian(latitudeTempValue2, AngleRange.MinusPiTOPi);//).ChangeTo<TAngular>();
            }

            return(new Ellipsoidal <TLinear, TAngular>(longitude, latitude, ellipsoid, this.Handedness));
        }
Ejemplo n.º 3
0
        public GeodeticPoint <TLinear, TAngular> ToGeodetic <TLinear, TAngular>(IEllipsoid ellipsoid, AngleRange longitudinalRange)
            where TLinear : LinearUnit, new()
            where TAngular : AngularUnit, new()
        {
            double tempSemiMajor = ellipsoid.SemiMajorAxis.ChangeTo <TLinear>().Value;

            double tempSemiMinor = ellipsoid.SemiMinorAxis.ChangeTo <TLinear>().Value;

            double e2TempValue = ellipsoid.FirstEccentricity * ellipsoid.FirstEccentricity;

            double tempX = this.X.ChangeTo <TLinear>().Value;

            double tempY = this.Y.ChangeTo <TLinear>().Value;

            double tempZ = this.Z.ChangeTo <TLinear>().Value;

            PolarPoint <TLinear, TAngular> tempValue = (new Cartesian2DPoint <TLinear>(new TLinear()
            {
                Value = tempX
            }, new TLinear()
            {
                Value = tempY
            })).ToPolar <TLinear, TAngular>(longitudinalRange);

            double pTempValue = tempValue.Radius.Value;

            double nTempValue = ellipsoid.SemiMajorAxis.Value;

            double hTempValue1 = Math.Sqrt(tempX * tempX + tempY * tempY + tempZ * tempZ)
                                 -
                                 Math.Sqrt(tempSemiMajor * tempSemiMinor);

            double latitudeTempValue1 = Math.Atan(tempZ / pTempValue *
                                                  1 / (1 - (e2TempValue * nTempValue) / (nTempValue + hTempValue1)));

            if (latitudeTempValue1.Equals(double.NaN))
            {
                return(new GeodeticPoint <TLinear, TAngular>(ellipsoid, new TLinear()
                {
                    Value = 0
                }, tempValue.Angle, (new Radian(0, longitudinalRange))));
            }

            double hTempValue2 = 0, latitudeTempValue2 = 0;

            bool conditionValue = true;

            do
            {
                nTempValue = ellipsoid.CalculateN(new Radian(latitudeTempValue1, AngleRange.MinusPiTOPi)).ChangeTo <TLinear>().Value;

                hTempValue2 = pTempValue / Math.Cos(latitudeTempValue1) - nTempValue;

                latitudeTempValue2 = Math.Atan(tempZ / pTempValue *
                                               1 / (1 - (e2TempValue * nTempValue) / (nTempValue + hTempValue2)));

                if (Math.Abs(hTempValue2 - hTempValue1) + Math.Abs(latitudeTempValue2 - latitudeTempValue1) < allowedDifference)
                {
                    conditionValue = false;
                }
                else
                {
                    hTempValue1 = hTempValue2;

                    latitudeTempValue1 = latitudeTempValue2;
                }
            } while (conditionValue);

            TLinear height = new TLinear()
            {
                Value = hTempValue2
            };

            return(new GeodeticPoint <TLinear, TAngular>(ellipsoid, height, tempValue.Angle, (new Radian(latitudeTempValue2, longitudinalRange))));
        }