Esempio n. 1
0
        //反算数据读取
        public void Readfile2(out double a, out double f, out List <DGeoLine> DLines, out List <GeoLine> Clines)
        {
            GeoLine  cline;
            DGeoLine dline;

            a      = 0;
            f      = 0;
            Clines = new List <GeoLine>();
            DLines = new List <DGeoLine>();

            OpenFileDialog file = new OpenFileDialog();

            file.Filter           = "All files(*.*)|*.*|text files(*.txt)|*.txt";
            file.FilterIndex      = 2;
            file.InitialDirectory = Application.StartupPath;
            file.RestoreDirectory = true;

            if (file.ShowDialog() == DialogResult.OK)
            {
                string path   = file.FileName.ToString();
                var    reader = new StreamReader(path);

                string str = reader.ReadLine();
                var    arr = str.Split(',');
                a = double.Parse(arr[0]);
                f = 1.0 / double.Parse(arr[1]);

                str = reader.ReadLine();

                while (str != null)
                {
                    cline = new GeoLine();
                    dline = new DGeoLine();

                    arr         = str.Split(',');
                    cline.Name1 = arr[0];
                    cline.B1    = double.Parse(arr[1]);
                    cline.L1    = double.Parse(arr[2]);
                    cline.Name2 = arr[3];
                    cline.B2    = double.Parse(arr[4]);
                    cline.L2    = double.Parse(arr[5]);

                    Clines.Add(cline);

                    dline.Name1 = cline.Name1;
                    dline.B1    = Dms2Str(cline.B1);
                    dline.L1    = Dms2Str(cline.L1);
                    dline.B2    = Dms2Str(cline.B2);
                    dline.L2    = Dms2Str(cline.L2);
                    dline.Name2 = cline.Name2;

                    DLines.Add(dline);

                    str = reader.ReadLine();
                }
            }
            else
            {
                return;
            }
        }
Esempio n. 2
0
        //反算公式
        public void GeoLineFan(double a, double f, GeoLine G, out double S, out double A1, out double A2)
        {
            G.B1 = Dms2Rad(G.B1);
            G.B2 = Dms2Rad(G.B2);
            G.L1 = Dms2Rad(G.L1);
            G.L2 = Dms2Rad(G.L2);
            double e1 = Math.Sqrt((2 - f) * f);
            double u1, u2;
            double l;

            u1 = Math.Atan(Math.Sqrt(1 - e1 * e1) * Math.Tan(G.B1));
            u2 = Math.Atan(Math.Sqrt(1 - e1 * e1) * Math.Tan(G.B2));
            l  = G.L2 - G.L1;

            double a1, a2, b1, b2;

            a1 = Math.Sin(u1) * Math.Sin(u2);
            a2 = Math.Cos(u1) * Math.Cos(u2);
            b1 = Math.Cos(u1) * Math.Sin(u2);
            b2 = Math.Sin(u1) * Math.Cos(u2);

            double namda, delta, delta1, sigma, sigma1;
            double A, B, C, arfa, beta, gama;
            double p, q, sinA0;

            delta = 0;

            //循环体
            do
            {
                namda = l + delta;
                p     = Math.Cos(u2) * Math.Sin(namda);
                q     = b1 - b2 * Math.Cos(namda);
                G.A1  = Math.Atan(p / q);
                if (p > 0)
                {
                    if (q > 0)
                    {
                        G.A1 = Math.Abs(G.A1);
                    }
                    else
                    {
                        G.A1 = Math.PI - Math.Abs(G.A1);
                    }
                }
                else
                {
                    if (q > 0)
                    {
                        G.A1 = 2 * Math.PI - Math.Abs(G.A1);
                    }
                    else
                    {
                        G.A1 = Math.PI + Math.Abs(G.A1);
                    }
                }
                if (G.A1 < 0)
                {
                    G.A1 = G.A1 + 2 * Math.PI;
                }
                if (G.A1 > 2 * Math.PI)
                {
                    G.A1 = G.A1 - 2 * Math.PI;
                }

                sigma = Math.Atan((p * Math.Sin(G.A1) + q * Math.Cos(G.A1)) / (a1 + a2 * Math.Cos(namda)));
                if (a1 + a2 * Math.Cos(namda) > 0)
                {
                    sigma = Math.Abs(sigma);
                }
                else
                {
                    sigma = Math.PI - Math.Abs(sigma);
                }

                sinA0  = Math.Cos(u1) * Math.Sin(G.A1);
                sigma1 = Math.Atan(Math.Tan(u1) / Math.Cos(G.A1));
                ParameterCal(a, f, sinA0, out A, out B, out C, out arfa, out beta, out gama);
                delta1 = delta;
                delta  = (arfa * sigma + beta * Math.Cos(2 * sigma1 + sigma) * Math.Sin(sigma) + gama * Math.Sin(2 * sigma) * Math.Cos(4 * sigma1 + 2 * sigma)) * sinA0;
            } while (Math.Abs(delta - delta1) > 1e-10);

            sigma1 = Math.Atan(Math.Tan(u1) / Math.Cos(G.A1));
            G.S    = ((sigma - B * Math.Sin(sigma) * Math.Cos(2 * sigma1 + sigma) - C * Math.Sin(2 * sigma) * Math.Cos(4 * sigma1 + 2 * sigma))) / A;
            G.A2   = Math.Atan(Math.Cos(u1) * Math.Sin(namda) / (b1 * Math.Cos(namda) - b2));
            if (G.A2 < 0)
            {
                G.A2 = G.A2 + Math.PI * 2;
            }
            if (G.A2 > Math.PI * 2.0)
            {
                G.A2 = G.A2 - Math.PI * 2;
            }
            if (G.A1 < Math.PI && G.A2 < Math.PI)
            {
                G.A2 = G.A2 + Math.PI;
            }
            if (G.A1 > Math.PI && G.A2 > Math.PI)
            {
                G.A2 = G.A2 - Math.PI;
            }

            S  = G.S;
            A1 = G.A1;
            A2 = G.A2;
        }