public void DistErrorEquations() { int m_Pnumber = UnknowPoints.Count(); int numAngle = StationInfos.Count(); List <LineClass> Distances = new List <LineClass>();//观测距离 //列边长误差方程 ExtractLineDist(Distances); int DistNum = Distances.Count; Bd = new Matrix(DistNum, m_Pnumber * 2); Ld = new Matrix(DistNum, 1); Vd = new Matrix(DistNum, 1); for (int D_index = 0; D_index < Distances.Count - 1; D_index++) { double dxj, dyj, dxk, dyk; int j = Tool_Class.Belong(UnknowPoints, Distances[D_index].SP.PID); int k = Tool_Class.Belong(UnknowPoints, Distances[D_index].EP.PID); double FWjk = Tool_Class.IIPointFW(Distances[D_index].SP, Distances[D_index].EP); dxj = -Math.Cos(FWjk); dyj = -Math.Sin(FWjk); dxk = -dxj; dyk = -dyj; if (j > -1) { Bd.SetNum(D_index, 2 * j, dxj); Bd.SetNum(D_index, 2 * j + 1, dyj); } if (k > -1) { Bd.SetNum(D_index, 2 * k, dxk); Bd.SetNum(D_index, 2 * k + 1, dyk); } double ld = Distances[D_index].Distance - Tool_Class.distIIP(Distances[D_index].SP, Distances[D_index].EP); Ld.SetNum(D_index, 0, ld); } }
//完善测站信息 private void PerfectStationInfos() { //添加控制点信息 foreach (StationClass TC in StationInfos) { int index = Tool_Class.Belong(ControlPoints, TC.SP.PID); if (index > -1) { TC.SP.X = ControlPoints[index].X; TC.SP.Y = ControlPoints[index].Y; TC.SP.IsControlP = true; } index = Tool_Class.Belong(ControlPoints, TC.FP.PID); if (index > -1) { TC.FP.X = ControlPoints[index].X; TC.FP.Y = ControlPoints[index].Y; TC.FP.IsControlP = true; } index = Tool_Class.Belong(ControlPoints, TC.BP.PID); if (index > -1) { TC.BP.X = ControlPoints[index].X; TC.BP.Y = ControlPoints[index].Y; TC.BP.IsControlP = true; } } //将当前点信息添加到测站信息 foreach (StationClass TC in StationInfos) { int SP_index, FP_index, BP_index; SP_index = Tool_Class.Belong(StartPoints, TC.SP.PID); if (SP_index > -1) { TC.SP = StartPoints[SP_index]; } FP_index = Tool_Class.Belong(StartPoints, TC.FP.PID); if (SP_index > -1) { TC.FP = StartPoints[FP_index]; } BP_index = Tool_Class.Belong(StartPoints, TC.BP.PID); if (BP_index > -1) { TC.BP = StartPoints[BP_index]; } } //添加已知两点的方位角 foreach (StationClass TC in StationInfos) { if (TC.SP.IsControlP && TC.BP.IsControlP) { TC.BAzimuth = Tool_Class.IIPointFW(TC.SP, TC.BP); TC.DisB = Tool_Class.distIIP(TC.SP, TC.BP); } if (TC.SP.IsControlP && TC.FP.IsControlP) { TC.FAzimuth = Tool_Class.IIPointFW(TC.SP, TC.FP); TC.DisF = Tool_Class.distIIP(TC.SP, TC.FP); } } }
//初始值计算 public void X0Y0Calculate() { int unkPnumber = UnknowPoints.Count; int kk = 0; while (kk < unkPnumber) { foreach (StationClass SC in StationInfos) { int SP_Index = Tool_Class.Belong(StartPoints, SC.SP.PID); if (StartPoints[SP_Index].IsControlP)//测站有点 { SC.SP.X = StartPoints[SP_Index].X; SC.SP.Y = StartPoints[SP_Index].Y; SC.SP.IsControlP = true; int BP_Index = Tool_Class.Belong(StartPoints, SC.BP.PID); if (StartPoints[BP_Index].IsControlP)//后视有点 { SC.BP.X = StartPoints[BP_Index].X; SC.BP.Y = StartPoints[BP_Index].Y; SC.BP.IsControlP = true; int FP_Index = Tool_Class.Belong(StartPoints, SC.FP.PID); if (StartPoints[FP_Index].IsControlP == false)//前视无点 { double BAzimuth = Tool_Class.IIPointFW(SC.SP, SC.BP); double FAzimuth = BAzimuth + SC.LAngle; FAzimuth = Tool_Class.AjustAngle(FAzimuth);//前视方位角 SC.FP = Tool_Class.AzimuthDistToP(SC.SP, FAzimuth, SC.DisF); SC.FP.PID = StartPoints[FP_Index].PID; SC.FP.IsControlP = true; StartPoints[FP_Index].X = SC.FP.X; StartPoints[FP_Index].Y = SC.FP.Y; StartPoints[FP_Index].IsControlP = true; kk++; } } else//后视无点 { int FP_Index = Tool_Class.Belong(StartPoints, SC.FP.PID); if (StartPoints[FP_Index].IsControlP)//前视有点 { SC.FP.X = StartPoints[FP_Index].X; SC.FP.Y = StartPoints[FP_Index].Y; SC.FP.IsControlP = true; double FAzimuth = Tool_Class.IIPointFW(SC.SP, SC.FP); double BAzimuth = FAzimuth - SC.LAngle; BAzimuth = Tool_Class.AjustAngle(BAzimuth); SC.BP = Tool_Class.AzimuthDistToP(SC.SP, BAzimuth, SC.DisB); SC.BP.PID = StartPoints[BP_Index].PID; SC.BP.IsControlP = true; StartPoints[BP_Index].X = SC.BP.X; StartPoints[BP_Index].Y = SC.BP.Y; StartPoints[BP_Index].IsControlP = true; kk++; } } } } } //更新未知点 PerfectStationInfos(); //补充测站信息 updataUnknowPoints(UnknowPoints, StartPoints); //更新未知点 }
public List <PointClass> IICoordTans(List <PointClass> SourcePoints, List <PointClass> TargetPoints, List <PointClass> IIDimTarPoints) { int Index = 0; List <PointClass> CommonP = new List <PointClass>(); //计算公共点,并将公共点存到COMMONp foreach (PointClass TP in SourcePoints) { Index = Tool_Class.Belong(TargetPoints, TP.PID);//获取原坐标点在目标坐标系中的索引值 if (Index != -1) { CommonP.Add(new PointClass { PID = TP.PID, X = TP.X, Y = TP.Y, IsCommonP = true }); } } //确定旋转电与参照点:计算最远距离点,从而确定了旋转点(第0个元素)与参照点(第一个元素)点号 string[] sArray = new string[2]; //记录旋转点与参照点名 PointClass SRotateP = new PointClass(); //源坐标旋转点 PointClass SRefP = new PointClass(); //源坐标参照点 PointClass TRotateP = new PointClass(); //目标坐标旋转点 PointClass TRefP = new PointClass(); //目标坐标参照点 sArray = Tool_Class.DistMaxListP(CommonP); Index = Tool_Class.Belong(CommonP, sArray[0]); SRotateP = CommonP[Index]; Index = Tool_Class.Belong(CommonP, sArray[1]); SRefP = CommonP[Index]; ////////////////////////////////////////////// double sfw = Tool_Class.IIPointFW(SRotateP, SRefP); //确定源坐标两个点(旋转点和参照点)方位角 double sd = Tool_Class.distIIP(SRotateP, SRefP); //确定源坐标两个点(旋转点和参照点)距离 ////////////获取目标系的旋转点与参照点 Index = Tool_Class.Belong(TargetPoints, sArray[0]); TRotateP = TargetPoints[Index]; Index = Tool_Class.Belong(TargetPoints, sArray[1]); TRefP = TargetPoints[Index]; //////////////// double Tfw = Tool_Class.IIPointFW(TRotateP, TRefP); //确定源坐标两个点(旋转点和参照点)方位角 double Td = Tool_Class.distIIP(TRotateP, TRefP); //确定源坐标两个点(旋转点和参照点)距离 double detfw = Tfw - sfw; double k = Td / sd - 1; //定义基线向量的矩阵 Matrix sBase = new Matrix(2, SourcePoints.Count); Matrix tBase = new Matrix(2, SourcePoints.Count); //计算源坐标系中各点相对于旋转点的基线向量,并将其扩大到(k+1)后存储到sBase矩阵中 for (Index = 0; Index < SourcePoints.Count; Index++) { double Bx = (SourcePoints[Index].X - SRotateP.X) * (1 + k); double By = (SourcePoints[Index].Y - SRotateP.Y) * (1 + k); sBase.SetNum(0, Index, Bx); sBase.SetNum(1, Index, By); } //计算旋转矩阵 Matrix R = new Matrix(2, 2); R.SetNum(0, 0, Math.Cos(detfw)); R.SetNum(0, 1, -Math.Sin(detfw)); R.SetNum(1, 0, 1 * Math.Sin(detfw)); R.SetNum(1, 1, Math.Cos(detfw)); //对sBase中的基线向量进行旋转放到tBase中 tBase = Matrix.Mutiply(R, sBase); //平移后,最终结果放到IIDimTraPoints for (Index = 0; Index < SourcePoints.Count; Index++) { IIDimTarPoints.Add(new PointClass { PID = SourcePoints[Index].PID, X = TRotateP.X + tBase.getNum(0, Index), Y = TRotateP.Y + tBase.getNum(1, Index) }); } return(CommonP); }