Exemplo n.º 1
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));
        }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
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));
        }
Exemplo n.º 5
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));
        }
Exemplo n.º 6
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));
        }
Exemplo n.º 7
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));
        }
Exemplo n.º 8
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));
        }