Esempio n. 1
0
        public void SevenCal2()
        {
            string        path  = @"C:\Users\niuni\Desktop\3.txt";
            var           lines = FileHelper.ReadThenSplitLine(path, ' ');
            List <double> b1    = new List <double>();
            List <double> l1    = new List <double>();
            List <double> h1    = new List <double>();
            List <double> b2    = new List <double>();
            List <double> l2    = new List <double>();
            List <double> h2    = new List <double>();

            double b = 0, l = 0, h = 0;

            for (int i = 0; i < lines.Count; i++)
            {
                if (lines[i] == null || lines[i].Length < 7)
                {
                    continue;
                }
                b = Angle.DMS2Arc(double.Parse(lines[i][1]));
                l = Angle.DMS2Arc(double.Parse(lines[i][2]));
                h = double.Parse(lines[i][3]);

                b1.Add(b);
                l1.Add(l);
                h1.Add(h);

                b = Angle.DMS2Arc(double.Parse(lines[i][4]));
                l = Angle.DMS2Arc(double.Parse(lines[i][5]));
                h = double.Parse(lines[i][6]);

                b2.Add(b);
                l2.Add(l);
                h2.Add(h);
            }

            SevenPara sev = SevenPara.CalPara(b1, l1, h1, b2, l2, h2, Ellipsoid.ELLIP_XIAN80, Ellipsoid.ELLIP_CGCS2000);

            Assert.IsTrue(Math.Abs(sev.XOff - 4) < 1e-3);
            Assert.IsTrue(Math.Abs(sev.YOff - 5) < 1e-3);
            Assert.IsTrue(Math.Abs(sev.ZOff - 6) < 1e-3);
            Assert.IsTrue(Math.Abs(sev.XRot - 1) < 1e-4);
            Assert.IsTrue(Math.Abs(sev.YRot - 2) < 1e-4);
            Assert.IsTrue(Math.Abs(sev.ZRot - 3) < 1e-4);
            Assert.IsTrue(Math.Abs(sev.M - 1) < 1e-4);
        }
Esempio n. 2
0
        public void SevenCal()
        {
            double dx = 0d, dy = 0d, dz = 0d;
            double rx = 0d, ry = 0d, rz = 0d;
            double s     = 0;
            Trans  trans = new Trans();

            Ellipsoid ell1 = Ellipsoid.ELLIP_XIAN80;
            Ellipsoid ell2 = Ellipsoid.ELLIP_CGCS2000;

            Random rand = new Random();

            for (int i = 0; i < 10; i++)
            {
                dx = rand.Next(1, 200) + rand.NextDouble();
                dy = rand.Next(50, 500) + rand.NextDouble();
                dz = rand.Next(50, 500) + rand.NextDouble();
                rx = (rand.Next(0, 10) / 10d + rand.NextDouble()) / 3600d * Angle.D2R;
                ry = (rand.Next(0, 10) / 10d + rand.NextDouble()) / 3600d * Angle.D2R;
                rz = (rand.Next(0, 10) / 10d + rand.NextDouble()) / 3600d * Angle.D2R;
                s  = rand.Next(0, 10) + rand.NextDouble();

                List <double> b1 = new List <double>();
                List <double> l1 = new List <double>();
                List <double> h1 = new List <double>();
                List <double> b2 = new List <double>();
                List <double> l2 = new List <double>();
                List <double> h2 = new List <double>();

                SevenPara sev1 = new SevenPara
                {
                    XOff = dx,
                    YOff = dy,
                    ZOff = dz,
                    XRot = rx,
                    YRot = ry,
                    ZRot = rz,
                    M    = s,
                };

                double bb1, ll1, hh1;
                double db, dl, dh;
                for (int j = 0; j < 4; j++)
                {
                    bb1 = (rand.Next(23, 30) + rand.NextDouble()) * Angle.D2R;
                    ll1 = (rand.Next(123, 130) + rand.NextDouble()) * Angle.D2R;
                    hh1 = rand.Next(-100, 500) + rand.NextDouble();

                    trans.Seven3d(out db, out dl, out dh, bb1, ll1, hh1, sev1, ell1, ell2);

                    b1.Add(bb1);
                    l1.Add(ll1);
                    h1.Add(hh1);

                    b2.Add(bb1 + db);
                    l2.Add(ll1 + dl);
                    h2.Add(hh1 + dh);
                }

                SevenPara sev2 = SevenPara.CalPara(b1, l1, h1, b2, l2, h2, ell1, ell2);

                Assert.IsTrue(Math.Abs(sev2.XOff - sev1.XOff) < 1e-4);
                Assert.IsTrue(Math.Abs(sev2.YOff - sev1.YOff) < 1e-4);
                Assert.IsTrue(Math.Abs(sev2.ZOff - sev1.ZOff) < 1e-4);
                Assert.IsTrue(Math.Abs(sev2.XRot - sev1.XRot) < 1e-5);
                Assert.IsTrue(Math.Abs(sev2.YRot - sev1.YRot) < 1e-5);
                Assert.IsTrue(Math.Abs(sev2.ZRot - sev1.ZRot) < 1e-5);
                Assert.IsTrue(Math.Abs(sev2.M - sev1.M) < 1e-5);
            }
        }