예제 #1
0
        public Cartesian3D <T> GetCartesianForm <T>()
            where T : LinearUnit, new()
        {
            LinearCollection <T> x = new LinearCollection <T>(this.NumberOfPoints);

            LinearCollection <T> y = new LinearCollection <T>(this.NumberOfPoints);

            LinearCollection <T> z = new LinearCollection <T>(this.NumberOfPoints);

            double tempE = this.Datum.FirstEccentricity;

            for (int i = 0; i < this.NumberOfPoints; i++)
            {
                AngularUnit templatitude = this.Latitude[i];

                AngularUnit templongitude = this.Longitude[i];

                double tempHeight = this.Height[i].ChangeTo <T>().Value;

                double tempN = this.Datum.CalculateN(templatitude).ChangeTo <T>().Value;

                x.SetTheValue(i, (tempHeight + tempN) * templatitude.Cos * templongitude.Cos);

                y.SetTheValue(i, (tempHeight + tempN) * templatitude.Cos * templongitude.Sin);

                z.SetTheValue(i, (tempHeight + tempN * (1 - tempE * tempE)) * templatitude.Sin);
            }

            return(new Cartesian3D <T>(x, y, z, this.Handedness));
        }
예제 #2
0
        public Cartesian3D <T> ToCartesian <T>()
            where T : LinearUnit, new()
        {
            LinearCollection <T> x = new LinearCollection <T>(this.NumberOfPoints);

            LinearCollection <T> y = new LinearCollection <T>(this.NumberOfPoints);

            LinearCollection <T> z = new LinearCollection <T>(this.NumberOfPoints);

            for (int i = 0; i < this.NumberOfPoints; i++)
            {
                double tempRadius = this.Radius[i].ChangeTo <T>().Value;

                AngularUnit tempVerticalAngle = this.VerticalAngle[i];

                AngularUnit tempHorizontalAngle = this.HorizontalAngle[i];

                x.SetTheValue(i, tempRadius * tempVerticalAngle.Cos * tempHorizontalAngle.Cos);

                y.SetTheValue(i, tempRadius * tempVerticalAngle.Cos * tempHorizontalAngle.Sin);

                z.SetTheValue(i, tempRadius * tempVerticalAngle.Sin);
            }

            return(new Cartesian3D <T>(x, y, z, this.Handedness));
        }
예제 #3
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));
        }
예제 #4
0
        public Cartesian3D <T> ToCartesian <T>()
            where T : LinearUnit, new()
        {
            LinearCollection <T> x = new LinearCollection <T>(this.NumberOfPoints);

            LinearCollection <T> y = new LinearCollection <T>(this.NumberOfPoints);

            LinearCollection <T> z = new LinearCollection <T>(this.NumberOfPoints);

            double tempSemiMinor = Datum.SemiMinorAxis.Value;

            double tempSemiMajor = Datum.SemiMajorAxis.Value;

            //double tempOrigionX = this.AssociatedEllipsoid.Origion.X.Value;

            //double tempOrigionY = this.AssociatedEllipsoid.Origion.Y.Value;

            //double tempOrigionZ = this.AssociatedEllipsoid.Origion.Z.Value;

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

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

            for (int i = 0; i < this.NumberOfPoints; i++)
            {
                double tempN = this.Datum.CalculateN(this.VerticalAngle[i]).Value;

                double longCos = this.HorizontalAngle[i].Cos; double longSin = this.HorizontalAngle[i].Sin;

                double latCos = this.VerticalAngle[i].Cos; double latSin = this.VerticalAngle[i].Sin;

                Matrix tempGeodetic = new Matrix(new double[][] { new double[] { (tempN) * latCos * longCos,
                                                                                 (tempN) * latCos * longSin,
                                                                                 (tempN * tempSemiMinor * tempSemiMinor / (tempSemiMajor * tempSemiMajor)) * latSin } });

                //Matrix tempResult = rotationMatrix * tempGeodetic + transferMatrix;

                x.SetValue(i, new TLinear()
                {
                    Value = tempGeodetic[0, 0]
                });

                y.SetValue(i, new TLinear()
                {
                    Value = tempGeodetic[1, 0]
                });

                z.SetValue(i, new TLinear()
                {
                    Value = tempGeodetic[2, 0]
                });
            }

            return(new Cartesian3D <T>(x, y, z, this.Handedness));
        }
예제 #5
0
        public ICartesian3D Transform(Matrix rotation, ICartesian3DPoint translation, AxisType newHandedness)
        {
            if (rotation.NumberOfColumns != 3)
            {
                throw new NotImplementedException();
            }

            if (rotation.NumberOfRows != 3)
            {
                throw new NotImplementedException();
            }

            double tempX = (translation.X.ChangeTo <T>()).Value;

            double tempY = (translation.Y.ChangeTo <T>()).Value;

            double tempZ = (translation.Z.ChangeTo <T>()).Value;

            LinearCollection <T> x = new LinearCollection <T>(this.NumberOfPoints);

            LinearCollection <T> y = new LinearCollection <T>(this.NumberOfPoints);

            LinearCollection <T> z = new LinearCollection <T>(this.NumberOfPoints);


            for (int i = 0; i < this.NumberOfPoints; i++)
            {
                Matrix tempMatrix = new Matrix(new double[][] {
                    new double[] {
                        this.X.GetTheValue(i),
                        this.Y.GetTheValue(i),
                        this.Z.GetTheValue(i)
                    }
                });

                Matrix result = rotation * tempMatrix;

                x.SetTheValue(i, result[0, 0] - tempX);

                y.SetTheValue(i, result[1, 0] - tempY);

                z.SetTheValue(i, result[2, 0] - tempZ);
            }

            return(new Cartesian3D <T>(x, y, z, newHandedness));
        }
예제 #6
0
        public Cartesian2D <T> ToCartesian <T>()
            where T : LinearUnit, new()
        {
            LinearCollection <T> x = new LinearCollection <T>(this.NumberOfPoints);

            LinearCollection <T> y = new LinearCollection <T>(this.NumberOfPoints);

            for (int i = 0; i < this.NumberOfPoints; i++)
            {
                double tempRadius = this.Radius[i].ChangeTo <T>().Value;

                x.SetTheValue(i, tempRadius * this.Angle[i].Cos);

                y.SetTheValue(i, tempRadius * this.Angle[i].Sin);
            }

            return(new Cartesian2D <T>(x, y, this.Handedness));
        }
예제 #7
0
        public ICartesian2D Rotate(AngularUnit rotateAngle, RotateDirection direction)
        {
            LinearCollection <T> newX = new LinearCollection <T>(this.NumberOfPoints);

            LinearCollection <T> newY = new LinearCollection <T>(this.NumberOfPoints);

            double sin = (int)direction * (int)this.Handedness * rotateAngle.Sin;

            double cos = rotateAngle.Cos;

            for (int i = 0; i < NumberOfPoints; i++)
            {
                newX.SetTheValue(i, X.GetTheValue(i) * cos + Y.GetTheValue(i) * sin);

                newY.SetTheValue(i, (-1) * X.GetTheValue(i) * sin + Y.GetTheValue(i) * cos);
            }

            return(new Cartesian2D <T>(newX, newY, this.Handedness));
        }
예제 #8
0
        public ICartesian3D RotateAboutZ(AngularUnit value, RotateDirection direction)
        {
            LinearCollection <T> x = new LinearCollection <T>(this.NumberOfPoints);

            LinearCollection <T> y = new LinearCollection <T>(this.NumberOfPoints);

            //ILinearArray z = this.Z.Clone();

            double cos = value.Cos;

            double sin = (int)direction * (int)this.Handedness * value.Sin;

            for (int i = 0; i < this.NumberOfPoints; i++)
            {
                x.SetTheValue(i, this.X.GetTheValue(i) * cos + this.Y.GetTheValue(i) * sin);

                y.SetTheValue(i, -this.X.GetTheValue(i) * sin + this.Y.GetTheValue(i) * cos);
            }

            return(new Cartesian3D <T>(x, y, this.Z.Clone(), this.Handedness));
        }
예제 #9
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));
        }
예제 #10
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));
        }
예제 #11
0
        public Geodetic <TLinear, TAngular> ToGeodeticForm <TLinear, TAngular>(IEllipsoid ellipsoid, AngleRange longitudinalRange)
            where TLinear : LinearUnit, new()
            where TAngular : AngularUnit, new()
        {
            ILinearCollection height = new LinearCollection <TLinear>(this.NumberOfPoints);

            IAngularCollection longitude = new AngularCollection <TAngular>(this.NumberOfPoints, longitudinalRange);

            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>(longitudinalRange);

                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 + hTempValue1)));

                if (latitudeTempValue1.Equals(double.NaN))
                {
                    continue;
                }

                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);

                height.SetTheValue(i, hTempValue2);

                latitude[i] = new Radian(latitudeTempValue2, AngleRange.MinusPiTOPi);
            }

            return(new Geodetic <TLinear, TAngular>(height, longitude, latitude, ellipsoid, this.Handedness));
        }