标题:附合导线计算程序有错不知道怎么改求帮忙看一下谢谢诶
只看楼主
树临风
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2012-12-20
 问题点数:0 回复次数:0 
附合导线计算程序有错不知道怎么改求帮忙看一下谢谢诶
这是代码using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 已知两个连接角的附合导线_已知四点坐标_每个点左角及水平距离_求各点坐标
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("请输入M点的X坐标:");
            double XM = double.Parse(Console.ReadLine());
            Console.WriteLine("请输入M点的Y坐标:");
            double YM = double.Parse(Console.ReadLine());
            Console.WriteLine("请输入A点的X坐标:");
            double XA = double.Parse(Console.ReadLine());
            Console.WriteLine("请输入A点的Y坐标:");
            double YA = double.Parse(Console.ReadLine());
            Console.WriteLine("请输入B点的X坐标:");
            double XB = double.Parse(Console.ReadLine());
            Console.WriteLine("请输入B点的Y坐标:");
            double YB = double.Parse(Console.ReadLine());
            Console.WriteLine("请输入C点的X坐标:");
            double XC = double.Parse(Console.ReadLine());
            Console.WriteLine("请输入C点的Y坐标:");
            double YC = double.Parse(Console.ReadLine());
            
            //计算M到A的方位角
            double a0 = 导线.方位角(XM ,YM ,XA,YA );
            double a1 = 导线.方位角(XB ,YB,XC,YC );
            List<double> 坐标增量X集合 = new List<double>();
            List<double> 坐标增量Y集合 = new List<double>();
            List<double> 方位角集合 = new List<double>();
            List <double >水平距离平方集合=new List<double> ();
            int i = 1;
            double 坐标增量X和 = 0;
            double 坐标增量Y和=0;
            double 坐标增量X和绝对值 = 0;
            double 坐标增量Y和绝对值 = 0;
            double 水平距离和 = 0;
            double a = a0;
            do
            {
                Console .WriteLine ("输入{0}到{1}的水平距离S《直接回车结束输入》=",i,i+1);
                string str=Console .ReadLine ();
                if (str !="")break ;
                double S=double .Parse (str );
                Console .WriteLine ("输入{0}点的水平角《左角为正,右角weifu》=",i);
                double b=导线.DEG (double .Parse (Console .ReadLine ()));
                i++;
                //计算坐标增量
                double dx,dy;
                a=导线.坐标 (0,0,b,S,a,out dx ,out dy );
                方位角集合.Add(a);
                坐标增量X集合 .Add (dx );
               坐标增量Y集合 .Add (dy );
                坐标增量X和 +=dx ;
                坐标增量Y和 +=dy ;
                坐标增量X和绝对值 +=Math .Abs (dx );
                坐标增量Y和绝对值 +=Math .Abs (dy );
                水平距离和 +=S ;
            }
            while (true );
            Console.WriteLine("输入最后一个连接角<左角为正,右角为辅>=");
            double bn = 导线.DEG (double .Parse (Console .ReadLine ()));
            //推算BC方位角
            double aBC = 导线.方位角(方位角集合[方位角集合 .Count -1],bn );
            //计算方位角闭合差
            double 方位角闭合差 = aBC - a1;
            double 方位角改正数=-方位角闭合差 /(方位角集合 .Count +1);
            //先对角度平差计算,在计算坐标增量
            坐标增量X集合.Clear();
            坐标增量Y集合.Clear();
            坐标增量X和 = 0;
            坐标增量Y和 = 0;
            坐标增量X和绝对值 = 0;
            坐标增量Y和绝对值 = 0;
            for (int j = 0; j < 方位角集合.Count; j++)
            {
                方位角集合[j] +=方位角改正数 *(j+1);
                //计算坐标增量
                double 平距 = Math.Sqrt(水平距离平方集合[j]);
                double dx = 平距 * Math.Cos(方位角集合 [j]);
                double dy = 平距 * Math.Sin(方位角集合[j]);
                坐标增量X集合.Add(dx );
                坐标增量Y集合.Add(dy );
                坐标增量X和 += dx;
                坐标增量Y和 += dy;
                坐标增量X和绝对值 += Math.Abs(dx );
                坐标增量Y和绝对值 += Math.Abs(dy );

            }
            //计算闭合差
            double 闭合差X=XA +坐标增量X和 -XB ;
            double 闭合差Y=YA +坐标增量Y和 -YB ;
            //计算单位长度改正数
            double X坐标单位长度改正数=-闭合差X /坐标增量X和绝对值  ;
            double Y坐标单位长度改正数=-闭合差Y /坐标增量Y和绝对值 ;
            //计算导线相对精度
            int f=(int)(水平距离和 /Math .Sqrt ((闭合差X *闭合差X )+(闭合差Y *闭合差Y )));
            Console.WriteLine ("导线的相对精度为1/{0}",f);
            //计算没点坐标
            double X=XA;
            double Y=YA;
            for (int j=0;j<坐标增量X集合 .Count ;j++)
            
            {
                X+=坐标增量X集合 [j]+X坐标单位长度改正数 *Math .Abs (坐标增量X集合 [j]);
                Y+=坐标增量X集合 [j]+Y坐标单位长度改正数 *Math .Abs (坐标增量X集合 [j]);
                Console .WriteLine ("第{0}点的X坐标是{1},Y坐标是{2}",j+2,X,Y );

            }
            Console.WriteLine ("最后一个点的所标与B点坐标相同");

            Console .ReadLine ();



        }
        class 导线
        {
            static public double DEG(double ang)//将度分秒转化为弧度
            {
                int fuhao = (int)(ang / Math.Abs(ang));
                ang = Math.Abs(ang);
                int d = (int)ang;
                int m = ((int)(ang * 100)) - d * 100;
                double s = ang * 10000 - m * 100 - d * 10000;
                return (((d + m / 60.0 + s / 3600.0) * fuhao) / 180.0 * Math.PI);
            }
            //计算方位角,返回弧度值
            static public double 方位角(double x1, double y1, double x2, double y2)
            {
                double deltaX = x2 - x1;
                double deltaY = y2 - y1;
                double angle = Math.PI * 0.5;
                if (Math.Abs(deltaX) > 0.000000001)
                {
                    angle = Math.Atan2(deltaY, deltaX);

                }
                if (angle < 0.0)
                {
                    angle += Math.PI;
                }
                if (deltaY < 0.0)
                {
                    angle += Math.PI;
                }
                return angle;
            }
            static public double 坐标(double x0, double y0, double 左角, double 水平距离, double 已知方位角, out double x, out double y)
            {
                double 方位角 = 已知方位角 + 左角 + Math.PI;
                if (方位角 >= 2 * Math.PI)
                    方位角 -= 2 * Math.PI;
                if (方位角 < 0.0)
                    方位角 += 2 * Math.PI;
                x = x0 + 水平距离 * Math.Cos(方位角);
                y = y0 + 水平距离 * Math.Sin(方位角 );
                return 方位角;


            }
            //根据后视边方位角和左角,计算前进边的方位角
            static public double 方位角(double 后视边方位角, double 左角)
            {
                double 方位角 = 后视边方位角 + 左角 + Math.PI;
                if (方位角 >= 2 * Math.PI)
                    方位角 -= 2 * Math.PI;
                if (方位角 < 0.0)
                    方位角 += 2 * Math.PI;
                return 方位角;
            }
        }
    }
}
搜索更多相关主题的帖子: double 
2012-12-21 14:46



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-392784-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.108463 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved