Beispiel #1
0
        public IPolar Rotate(AngularUnit value, RotateDirection direction)
        {
            double tempValue = (int)direction * (int)Handedness * value.ChangeTo <TAngular>().Value;

            LinearCollection <TLinear> newRadius = (LinearCollection <TLinear>) this.Radius.Clone();

            AngularCollection <TAngular> newAngle = (AngularCollection <TAngular>) this.Angle.AddAllValuesWith(tempValue);

            return(new Polar <TLinear, TAngular>(newRadius, newAngle, this.Handedness));
        }
Beispiel #2
0
        public Polar <TLinear, TAngular> ToPolar <TLinear, TAngular>(AngleRange range)
            where TLinear : LinearUnit, new()
            where TAngular : AngularUnit, new()
        {
            ILinearCollection radius = new LinearCollection <TLinear>(this.NumberOfPoints);

            IAngularCollection angle = new AngularCollection <TAngular>(this.NumberOfPoints, range);

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

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

                radius.SetTheValue(i, Math.Sqrt(tempX * tempX + tempY * tempY));

                angle[i] = new Radian(Math.Atan2(tempY, tempX), AngleRange.MinusPiTOPi);
            }

            return(new Polar <TLinear, TAngular>(radius, angle, this.Handedness));
        }
Beispiel #3
0
        public Astronomical <TAngular> ToAstronomicForm <TAngular>(AngleRange horizontalRange)
            where TAngular : AngularUnit, new()
        {
            IAngularCollection horizontalAngle = new AngularCollection <TAngular>(this.NumberOfPoints, horizontalRange);

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

            for (int i = 0; i < this.NumberOfPoints; i++)
            {
                double tempX = this.X.GetTheValue(i);

                double tempY = this.Y.GetTheValue(i);

                double tempZ = this.Z.GetTheValue(i);

                horizontalAngle[i] = new Radian(Math.Atan2(tempY, tempX), horizontalRange);

                verticalAngle[i] = new Radian(Math.Atan2(tempZ, Math.Sqrt(tempX * tempX + tempY * tempY)), AngleRange.MinusPiTOPi);
            }

            return(new Astronomical <TAngular>(horizontalAngle, verticalAngle, this.Handedness));
        }
Beispiel #4
0
        public Spherical <TLinear, TAngular> ToSphericalForm <TLinear, TAngular>(AngleRange horizontalRange)
            where TLinear : LinearUnit, new()
            where TAngular : AngularUnit, new()
        {
            ILinearCollection radius = new LinearCollection <TLinear>(this.NumberOfPoints);

            IAngularCollection horizontalAngle = new AngularCollection <TAngular>(this.NumberOfPoints, horizontalRange);

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

            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;

                double tempX = this.X.GetTheValue(i);

                double tempY = this.Y.GetTheValue(i);

                double tempZ = this.Z.GetTheValue(i);

                //radius.SetTheValue(i, Math.Sqrt(tempX * tempX + tempY * tempY + tempZ * tempZ));
                radius[i] = new T()
                {
                    Value = Math.Sqrt(tempX * tempX + tempY * tempY + tempZ * tempZ)
                };

                horizontalAngle[i] = new Radian(Math.Atan2(tempY, tempX), horizontalRange);

                verticalAngle[i] = new Radian(Math.Atan2(tempZ, Math.Sqrt(tempX * tempX + tempY * tempY)), AngleRange.MinusPiTOPi);
            }

            return(new Spherical <TLinear, TAngular>(radius, horizontalAngle, verticalAngle, this.Handedness));
        }
Beispiel #5
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));
        }