后方交会代码

 /// <summary>
   /// 测点信息
   /// </summary>
   /// <param name="list"></param>
   /// <returns></returns>
  public class PointInfo
    {
        /// <summary>
        /// 是否基准点 0基准点 1 测量点 2全站仪
        /// </summary>
        public int Type { get; set; }
        /// <summary>
        /// X坐标
        /// </summary>
        public double Y { get; set; }
        /// <summary>
        /// Y坐标
        /// </summary>
        public double X { get; set; }
        /// <summary>
        /// 水平位置
        /// </summary>
        public double Hz { get; set; }
    }
        /// <summary>
        /// 后方交会算法 返回坐标
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        private static double[] Resection(List<PointInfo> list)
        {
            var dataList = list.Where(x => x.Type == 0).ToList();
            if (dataList.Count < 3) return null;//至少三个基准点
            var pointA = dataList[0];
            var pointB = dataList[1];
            var pointC = dataList[2];

            //三个基准点坐标
            double xa = pointA.X;
            double xb = pointB.X;
            double xc = pointC.X;
            double ya = pointA.Y;
            double yb = pointB.Y;
            double yc = pointC.Y;

            double alpha = pointC.Hz - pointB.Hz;
            double beta = pointA.Hz - pointC.Hz;
            double gamma = pointB.Hz - pointA.Hz;
            double cotA = ((xb - xa) * (xc - xa) + (yb - ya) * (yc - ya)) / ((xb - xa) * (yc - ya) - (yb - ya) * (xc - xa));
            double cotB = ((xc - xb) * (xa - xb) + (yc - yb) * (ya - yb)) / ((xc - xb) * (ya - yb) - (yc - yb) * (xa - xb));
            double cotC = ((xa - xc) * (xb - xc) + (ya - yc) * (yb - yc)) / ((xa - xc) * (yb - yc) - (ya - yc) * (xb - xc));

            double pA = 1.0 / (cotA - Math.Pow(Math.Tan(alpha), -1));
            double pB = 1.0 / (cotB - Math.Pow(Math.Tan(beta), -1));
            double pC = 1.0 / (cotC - Math.Pow(Math.Tan(gamma), -1));

            double xp = (pA * xa + pB * xb + pC * xc) / (pA + pB + pC);
            double yp = (pA * ya + pB * yb + pC * yc) / (pA + pB + pC);
            return new double[2] { xp, yp };
        }

 

 

 

posted @ 2020-08-26 15:02  还是苦瓜  阅读(368)  评论(0编辑  收藏  举报