四等水准附和导线、闭合导线平差VB代码

合集下载

水准网平差(VB代码)

水准网平差(VB代码)

误差理论与测量平差础)课程设计报告系(部):土木工程系实习单位:山东交通学院班级:测绘084学生姓名:田忠星学号080712420带队教师:夏小裕﹑周宝兴时间:10 年12 月13 日到10 年12 月19 日山东交通学院目录:1.摘要P32.概述P33.水准网间接平差程序设计思路P3—P44.平差程序流程图P4—P65.程序源代码及说明P7—P236.计算结果P23—P267.总结P26—P27一:摘要在测量工作中,为了能及时发现错误和提高测量成果的精度,常作多余观测,这就产生了平差问题。

在一个平差问题中,当所选的独立参数X?的个数等于必要观测数t 时,可将每个观测值表达成这t 个参数的函数,组成观测方程,这种以观测方程为函数模型的平差方法,就是间接平差。

二:概述:该课程设计的主要目是对水准网进行间接平差,在输入数据后依次计算高程近似值﹑误差方程和平差计算。

三:水准网间接平差程序设计思路1.根据平差问题的性质,选择t 个独立量(既未知点的高程)作为参数X?2.将每一个观测量的平差值(既观测的高程差值)分别表达成L L V3.由误差方程系数 B 和自由项组成法方程,法方程个数等于参数的个数t ;4. 解算法方程,求出参数X?,计算参数(高程)的平差值X?=X0 +x? ;5.由误差方程计算V,求出观测量(高差)平差值L L V 6.评定精度单位权中误差平差值函数的中误差四:平差程序流程图1. 已知数据的输入 需要输入的数据包括水准网中已知点数﹑未知点数以及这些点 的点号, 已知高程和高差观测值﹑距离观测值。

程序采用文件方 式进行输入,约定文件输入的格式如下: 第一行:已知点数﹑未知点数﹑观测值个数 第二行:点号(已知点在前,未知点在后) 第三行:已知高程(顺序与上一行的点号对应) 第四行:高差观测值,按“起点点号,终点点号。

高差观测值, 距离观测值”的顺序输入。

本节中使用的算例的数据格式如下2,3,7 1,2,3,4,5 5.016,6.016 1,3,1.359,1.11,4,2.009,1.7 2,3,0.363,2.3 2,4,1.012,2.7 3,4,0.657,2.4 3,5,0.238,1.4 5,2,-0.595,2.6 2.平差计算过程V TPV rV TPVnus(1)近似高程的计算。

闭合导线平差程序设计

闭合导线平差程序设计
进行角度闭合差调整时,将闭合差反符号平均分 配到各观测角,剩余误差(残差)分配到转折角较大的 几个观测角中;进行坐标增量闭合差调整时,采用与 对应边长成正比例的原则来计算坐标增量的改正数, 残差分配到边长较大的坐标增量中。 2闭合导线平差计算公式
角度闭合差垢龋邶理
角度闭合差(图根导线)的允许值:廊允=±,,、/i
fy=-fy+Y坐标增量 d=d+边长 endscan
thisform.1abel21.caption=dltrim(strOCx,7,3))
万方数据
32
·北京测绘·
2008年第3期
thisforrmlabel21.visible=.t. th厶form./abel22.caption---alhrim(str(fy,7,3)) th函form./abel22.visible=.t. 料计算导线全长闭合差 f=-round(sqrt弧2+:75,乞),3) x=int(d/s9 k=str(1,1)+’,/,’+alltrim(str(x)) thisform.1abel23.caption--alhrim(strOC,,7,3)) thisform./abel23.visible=.t. thisform.1abel24.caption=k thisform.1abel24.visible=.L -t计算坐标增量改正值 丘1=0 fyl=0 /f int(x)<2000
北京:科学出版社,2004
The Design of Procedure About Closed Traverse Adjustment
Abstract:This paper designs the traverse adjustment procedure on traverse approximate adjustment principle and Visual FoxPr06.0 developing platform.The procedure can accomplish the contmUed adjustment of level control and height control of closed traverse,and it gab also make result of adjustment into all kinds of file forms according to the different demands, meanwhile,it can draw the picture of the traverse. Key words:Closed Traverse;Adjustment:Procedure Design;Application

水准网平差(VB代码)

水准网平差(VB代码)

(误差理论与测量平差础)课程设计报告系(部):土木工程系实习单位:山东交通学院班级:测绘084学生姓名:田忠星学号********* 带队教师:夏小裕﹑周宝兴时间:10 年12 月13日到10 年12 月19日山东交通学院目录:1.摘要P32.概述P33.水准网间接平差程序设计思路P3—P44. 平差程序流程图P4—P65. 程序源代码及说明P7—P236. 计算结果P23—P267. 总结P26—P27一:摘要在测量工作中,为了能及时发现错误和提高测量成果的精度,常作多余观测,这就产生了平差问题。

在一个平差问题中,当所选的独立参数Xˆ的个数等于必要观测数t时,可将每个观测值表达成这t个参数的函数,组成观测方程,这种以观测方程为函数模型的平差方法,就是间接平差。

二:概述:该课程设计的主要目是对水准网进行间接平差,在输入数据后依次计算高程近似值﹑误差方程和平差计算。

三:水准网间接平差程序设计思路1.根据平差问题的性质,选择t个独立量(既未知点的高程)作为参数Xˆ2. 将每一个观测量的平差值(既观测的高程差值)分别表达成3.由误差方程系数B和自由项组成法方程,法方程个数等于参数的个数t ;4. 解算法方程,求出参数Xˆ,计算参数(高程)的平差值Xˆ=X0 +xˆ;5.由误差方程计算V,求出观测量(高差)平差值6.评定精度单位权中误差VLL+ =∧VLL+ =∧平差值函数的中误差四:平差程序流程图1. 已知数据的输入需要输入的数据包括水准网中已知点数﹑未知点数以及这些点的点号,已知高程和高差观测值﹑距离观测值。

程序采用文件方式进行输入,约定文件输入的格式如下:第一行:已知点数﹑未知点数﹑观测值个数第二行:点号(已知点在前,未知点在后)第三行:已知高程(顺序与上一行的点号对应)第四行:高差观测值,按“起点点号,终点点号。

高差观测值,距离观测值”的顺序输入。

本节中使用的算例的数据格式如下2,3,71,2,3,4,55.016,6.0161,3,1.359,1.11,4,2.009,1.7 2,3,0.363,2.3,ˆ20s u n PV V r PV V T T +-==σ.ˆˆˆ0ˆϕϕϕσσQ =2,4,1.012,2.73,4,0.657,2.43,5,0.238,1.45,2,-0.595,2.62.平差计算过程(1)近似高程的计算。

测量导线计算VB程序设计

测量导线计算VB程序设计

收稿日期:2003-03-13作者简介:薄志义(1964-),男,辽宁工程技术大学测量工程专业毕业,中国矿业大学(北京校区)在读博士生,副教授。

测量导线计算VB 程序设计薄志义1,2(1.中国矿业大学北京校区,北京100083;2.北京工业职业技术学院,北京100042)摘 要:应用Visual BASIC (VB )计算机编程语言对图根导线计算进行编程设计。

探讨了VB 编程方法技巧与测量计算有机的结合,程序具有较高的实用性。

关键词:测量导线;计算;VB ;程序设计中图分类号:P209 文献标识码:B 文章编号:1671-6558(2003)03-08-04VB Program Design of T raverse C alculationBo Zhiyi 1,2(1.China University of Mining &Technology ,Beijing 100083,China 2.Beijing Vocational &Technical Institute of Industry ,Beijing 100042,China )Abstract :This article applies Visual BASIC to program design of traverse calculation ,and explores better combi 2nation of programming methods and traverse calculation ,which proves to have high practical value.Key words :traverse ;calculation ;VB ;seismic source ;program design1测量导线计算VB 程序的功能本程序适用于地形测量、地籍测量、工程测量中的图根导线的计算。

平差导线代码

平差导线代码

B=NaN(45,30);P=NaN(45,45);Si=NaN(19,1);X0=NaN(18,1);Y0=NaN(18,1);XY=NaN(30,1);S0=NaN(19,1);L=NaN(45,1);r=15;rou=206265;Li=NaN(26,1);L0=NaN(26,1);a=NaN(26,1);b=NaN(26,1);c=NaN(26,1);d=NaN(26,1);j1=NaN(26,1);j2=NaN(26,1);sgm0=6;X1=NaN(15,1);Y1=NaN(15,1);S1=NaN(19,1);L1=NaN(26,1);L1dms=NaN(26,3);Sdev=NaN(19,1);Qx=NaN(15,1);Qy=NaN(15,1);Qxy=NaN(15,1);K=NaN(15,1);E=NaN(15,1);F=NaN(15,1);Qe=NaN(15,1);Fe=NaN(15,1);Fai=NaN(15,3);Li(1,1)=(134+35/60+52.7/3600)/180*pi;Li(2,1)=(202+19/60+10.7/3600)/180*pi;Li(3,1)=(129+30/60+14.9/3600)/180*pi;Li(4,1)=(162+9/60+14.2/3600)/180*pi;Li(5,1)=(138+43/60+48.6/3600)/180*pi;Li(6,1)=(175+52/60+30.1/3600)/180*pi;Li(7,1)=(144+48/60+40.2/3600)/180*pi;Li(8,1)=(134+33/60+3.1/3600)/180*pi;Li(9,1)=(189+13/60+5.9/3600)/180*pi;Li(10,1)=(170+33/60+51.6/3600)/180*pi;Li(11,1)=(112+44/60+18.3/3600)/180*pi;Li(12,1)=(171+13/60+58/3600)/180*pi;Li(13,1)=(146+38/60+42.3/3600)/180*pi;Li(14,1)=(360-(212+55/60+25.8/3600))/180*pi;Li(15,1)=(50+26/60+14.2/3600)/180*pi;Li(16,1)=(360-(297+41/60+39.7/3600))/180*pi;Li(17,1)=(167+26/60+28.8/3600)/180*pi;Li(18,1)=(360-(245+3/60+31.1/3600))/180*pi;Li(19,1)=(91+23/60+26.5/3600)/180*pi;Li(20,1)=(360-(206+19/60+41.2/3600))/180*pi;Li(21,1)=(360-(189+32/60+52.5/3600))/180*pi;Li(22,1)=(66+59/60+34.1/3600)/180*pi;Li(23,1)=(360-(279+55/60+6.8/3600))/180*pi;Li(24,1)=(155+58/60+21.4/3600)/180*pi;Li(25,1)=(96+35/60+25.7/3600)/180*pi;Li(26,1)=(360-(294+25/60+59.4/3600))/180*pi;Si(1,1)=45.878;Si(2,1)=25.083;Si(3,1)=58.859;Si(4,1)=33.166;Si(5,1)=43.223;Si(6,1)=62.642;Si(7,1)=37.399;Si(8,1)=46.764;Si(9,1)=39.761;Si(10,1)=35.981;Si(11,1)=40.878;Si(12,1)=53.546;Si(13,1)=45.165;Si(14,1)=64.024;Si(15,1)=44.644;Si(16,1)=56.887;Si(17,1)=42.365;Si(18,1)=52.129;Si(19,1)=56.626;X0(1,1)=256.832;Y0(1,1)=288.001;X0(2,1)=267.182;Y0(2,1)=265.153;X0(3,1)=310.011;Y0(3,1)=224.779;X0(4,1)=307.803;Y0(4,1)=191.667;X0(5,1)=291.856;Y0(5,1)=151.494;X0(6,1)=236.081;Y0(6,1)=122.978;X0(7,1)=201.643;Y0(7,1)=108.393;X0(8,1)=155.941;Y0(8,1)=118.303;X0(9,1)=134.685;Y0(9,1)=151.906;X0(10,1)=110.827;Y0(10,1)=178.840;X0(11,1)=89.129;Y0(11,1)=213.509;X0(12,1)=119.980;Y0(12,1)=257.274; X0(13,1)=151.325;Y0(13,1)=289.791;X0(14,1)=251.244;Y0(14,1)=188.915; X0(15,1)=190.059;Y0(15,1)=212.716;X0(16,1)=133.395;Y0(16,1)=207.687; X0(17,1)=204.453;Y0(17,1)=252.576;X0(18,1)=213.783;Y0(18,1)=303.863; %{X0(1,1)=256.829;Y0(1,1)=287.987;X0(2,1)=267.176;Y0(2,1)=265.120;X0(3,1)=310.005;Y0(3,1)=224.746;X0(4,1)=307.804;Y0(4,1)=191.653;X0(5,1)=291.857;Y0(5,1)=151.480;X0(6,1)=236.082;Y0(6,1)=122.964;X0(7,1)=201.667;Y0(7,1)=108.433;X0(8,1)=155.965;Y0(8,1)=118.343;X0(9,1)=134.709;Y0(9,1)=151.946;X0(10,1)=110.851;Y0(10,1)=178.880;X0(11,1)=89.129;Y0(11,1)=213.509;X0(12,1)=119.980;Y0(12,1)=257.274; X0(13,1)=151.325;Y0(13,1)=289.791;X0(14,1)=251.244;Y0(14,1)=188.915; X0(15,1)=190.059;Y0(15,1)=212.716;X0(16,1)=133.395;Y0(16,1)=207.687; X0(17,1)=204.453;Y0(17,1)=252.576;X0(18,1)=213.780;Y0(18,1)=303.849; %}%X0(18,1) is the coordinate of point 0 ;S0(1,1)=sqrt((X0(18,1)-X0(1,1))^2+(Y0(18,1)-Y0(1,1))^2);S0(14,1)=sqrt((X0(13,1)-X0(18,1))^2+(Y0(13,1)-Y0(18,1))^2);S0(15,1)=sqrt((X0(11,1)-X0(16,1))^2+(Y0(11,1)-Y0(16,1))^2);S0(16,1)=sqrt((X0(15,1)-X0(16,1))^2+(Y0(15,1)-Y0(16,1))^2);S0(17,1)=sqrt((X0(15,1)-X0(17,1))^2+(Y0(15,1)-Y0(17,1))^2);S0(18,1)=sqrt((X0(18,1)-X0(17,1))^2+(Y0(18,1)-Y0(17,1))^2);S0(19,1)=sqrt((X0(4,1)-X0(14,1))^2+(Y0(4,1)-Y0(14,1))^2);for i=1:12S0(i+1,1)=sqrt((X0(i,1)-X0(i+1,1))^2+(Y0(i,1)-Y0(i+1,1))^2);end%the angle operationa(1,1)=Y0(2,1)-Y0(1,1); b(1,1)=X0(2,1)-X0(1,1);c(1,1)=Y0(18,1)-Y0(1,1); d(1,1)=X0(18,1)-X0(1,1);for i=2:12a(i,1)=Y0(i+1,1)-Y0(i,1); b(i,1)=X0(i+1,1)-X0(i,1);c(i,1)=Y0(i-1,1)-Y0(i,1); d(i,1)=X0(i-1,1)-X0(i,1);enda(13,1)=Y0(18,1)-Y0(13,1); b(13,1)=X0(18,1)-X0(13,1);c(13,1)=Y0(12,1)-Y0(13,1); d(13,1)=X0(12,1)-X0(13,1);% the next is the 14th angle ;a(14,1)=Y0(1,1)-Y0(18,1); b(14,1)=X0(1,1)-X0(18,1);c(14,1)=Y0(13,1)-Y0(18,1); d(14,1)=X0(13,1)-X0(18,1);a(15,1)=Y0(16,1)-Y0(11,1); b(15,1)=X0(16,1)-X0(11,1);c(15,1)=Y0(10,1)-Y0(11,1); d(15,1)=X0(10,1)-X0(11,1);a(16,1)=Y0(12,1)-Y0(11,1); b(16,1)=X0(12,1)-X0(11,1);c(16,1)=Y0(16,1)-Y0(11,1); d(16,1)=X0(16,1)-X0(11,1);a(17,1)=Y0(11,1)-Y0(16,1); b(17,1)=X0(11,1)-X0(16,1);c(17,1)=Y0(15,1)-Y0(16,1); d(17,1)=X0(15,1)-X0(16,1);a(18,1)=Y0(16,1)-Y0(15,1); b(18,1)=X0(16,1)-X0(15,1);c(18,1)=Y0(17,1)-Y0(15,1); d(18,1)=X0(17,1)-X0(15,1);a(19,1)=Y0(17,1)-Y0(15,1); b(19,1)=X0(17,1)-X0(15,1);c(19,1)=Y0(14,1)-Y0(15,1); d(19,1)=X0(14,1)-X0(15,1);a(20,1)=Y0(14,1)-Y0(15,1); b(20,1)=X0(14,1)-X0(15,1);c(20,1)=Y0(16,1)-Y0(15,1); d(20,1)=X0(16,1)-X0(15,1);a(21,1)=Y0(15,1)-Y0(17,1); b(21,1)=X0(15,1)-X0(17,1);c(21,1)=Y0(18,1)-Y0(17,1); d(21,1)=X0(18,1)-X0(17,1);a(22,1)=Y0(17,1)-Y0(18,1); b(22,1)=X0(17,1)-X0(18,1);c(22,1)=Y0(13,1)-Y0(18,1); d(22,1)=X0(13,1)-X0(18,1);a(23,1)=Y0(1,1)-Y0(18,1); b(23,1)=X0(1,1)-X0(18,1);c(23,1)=Y0(17,1)-Y0(18,1); d(23,1)=X0(17,1)-X0(18,1);a(24,1)=Y0(15,1)-Y0(14,1); b(24,1)=X0(15,1)-X0(14,1);c(24,1)=Y0(4,1)-Y0(14,1); d(24,1)=X0(4,1)-X0(14,1);a(25,1)=Y0(14,1)-Y0(4,1); b(25,1)=X0(14,1)-X0(4,1);c(25,1)=Y0(3,1)-Y0(4,1); d(25,1)=X0(3,1)-X0(4,1);a(26,1)=Y0(5,1)-Y0(4,1); b(26,1)=X0(5,1)-X0(4,1);c(26,1)=Y0(14,1)-Y0(4,1); d(26,1)=X0(14,1)-X0(4,1);for i=1:26if(a(i,1)>0&&b(i,1)>0)j1(i,1)=atan(a(i,1)/b(i,1));else if(a(i,1)>0&&b(i,1)<0)j1(i,1)=atan(a(i,1)/b(i,1))+pi;else if(a(i,1)<0&&b(i,1)<0)j1(i,1)=atan(a(i,1)/b(i,1))+pi;elsej1(i,1)=atan(a(i,1)/b(i,1))+2*pi;endendendif(c(i,1)>0&&d(i,1)>0)j2(i,1)=atan(c(i,1)/d(i,1));else if(c(i,1)>0&&d(i,1)<0)j2(i,1)=atan(c(i,1)/d(i,1))+pi;else if(c(i,1)<0&&d(i,1)<0)j2(i,1)=atan(c(i,1)/d(i,1))+pi;elsej2(i,1)=atan(c(i,1)/d(i,1))+2*pi;endendendL0(i,1)=j1(i,1)-j2(i,1);if(L0(i,1)<0)L0(i,1)= L0(i,1)+2*pi;endendfor i=20:45L(i,1)=Li(i-19,1)-L0(i-19,1);L(i,1)=L(i,1)*rou;endB=zeros(45,30);B(1,21)=-(X0(1,1)-X0(18,1))/S0(1,1);B(1,22)=-(Y0(1,1)-Y0(18,1))/S0(1,1);B(1,1)=(X0(1,1)-X0(18,1))/S0(1,1);B(1,2)=(Y0(1,1)-Y0(18,1))/S0(1,1);for i=2:10B(i,2*i-3)=-(X0(i,1)-X0(i-1,1))/S0(i,1);B(i,2*i-2)=-(Y0(i,1)-Y0(i-1,1))/S0(i,1);B(i,2*i-1)=(X0(i,1)-X0(i-1,1))/S0(i,1);B(i,2*i)=(Y0(i,1)-Y0(i-1,1))/S0(i,1);endfor i=1:19L(i,1)=(Si(i,1)-S0(i,1))*1000;endB(11,19)=-(X0(11,1)-X0(10,1))/S0(11,1);B(11,20)=-(Y0(11,1)-Y0(10,1))/S0(11,1);B(12,23)=(X0(12,1)-X0(11,1))/S0(12,1);B(12,24)=(Y0(12,1)-Y0(11,1))/S0(12,1);B(13,23)=-(X0(13,1)-X0(12,1))/S0(13,1);B(13,24)=-(Y0(13,1)-Y0(12,1))/S0(13,1);B(13,25)=(X0(13,1)-X0(12,1))/S0(13,1);B(13,26)=(Y0(13,1)-Y0(12,1))/S0(13,1);B(14,25)=-(X0(18,1)-X0(13,1))/S0(14,1);B(14,26)=-(Y0(18,1)-Y0(13,1))/S0(14,1);B(14,21)=(X0(18,1)-X0(13,1))/S0(14,1);B(14,22)=(Y0(18,1)-Y0(13,1))/S0(14,1);B(15,27)=(X0(16,1)-X0(11,1))/S0(15,1);B(15,28)=(Y0(16,1)-Y0(11,1))/S0(15,1);B(16,27)=-(X0(15,1)-X0(16,1))/S0(16,1);B(16,28)=-(Y0(15,1)-Y0(16,1))/S0(16,1);B(17,29)=(X0(17,1)-X0(15,1))/S0(17,1);B(17,30)=(Y0(17,1)-Y0(15,1))/S0(17,1);B(18,29)=-(X0(18,1)-X0(17,1))/S0(18,1);B(18,30)=-(Y0(18,1)-Y0(17,1))/S0(18,1);B(18,21)=(X0(18,1)-X0(13,1))/S0(18,1);B(18,22)=(Y0(18,1)-Y0(13,1))/S0(18,1);B(19,7)=(X0(4,1)-X0(14,1))/S0(19,1);B(19,8)=(Y0(4,1)-Y0(14,1))/S0(19,1);%the rim is over;B(20,1)=rou*((Y0(2,1)-Y0(1,1))/(S0(2,1)^2)-(Y0(18,1)-Y0(1,1))/(S0(1,1)^ 2));B(20,2)=-rou*((X0(2,1)-X0(1,1))/(S0(2,1)^2)-(X0(18,1)-X0(1,1))/(S0(1,1) ^2));B(20,3)=-rou*((Y0(2,1)-Y0(1,1))/(S0(2,1)^2));B(20,4)=rou*((X0(2,1)-X0(1,1))/(S0(2,1)^2));B(20,21)=rou*(Y0(18,1)-Y0(1,1))/(S0(1,1)^2);B(20,22)=-rou*((X0(18,1)-X0(1,1))/(S0(1,1)^2));for i=2:9B(i+19,2*i-1)=rou*((Y0(i+1,1)-Y0(i,1))/(S0(i+1,1)^2)-(Y0(i-1,1)-Y0(i,1) )/(S0(i,1)^2));B(i+19,2*i)=-rou*((X0(i+1,1)-X0(i,1))/(S0(i+1,1)^2)-(X0(i-1,1)-X0(i,1)) /(S0(i,1)^2));B(i+19,2*i-3)=rou*((Y0(i-1,1)-Y0(i,1))/(S0(i,1)^2));B(i+19,2*i-2)=-rou*((X0(i-1,1)-X0(i,1))/(S0(i,1)^2));B(i+19,2*i+1)=-rou*((Y0(i+1,1)-Y0(i,1))/(S0(i+1,1)^2));B(i+19,2*i+2)=rou*((X0(i+1,1)-X0(i,1))/(S0(i+1,1)^2));endB(29,19)=rou*((Y0(11,1)-Y0(10,1))/(S0(11,1)^2)-(Y0(9,1)-Y0(10,1))/(S0(1 0,1)^2));B(29,20)=-rou*((X0(11,1)-X0(10,1))/(S0(11,1)^2)-(X0(9,1)-X0(10,1))/(S0( 10,1)^2));B(29,17)=rou*((Y0(9,1)-Y0(10,1))/(S0(10,1)^2));B(29,18)=-rou*((X0(9,1)-X0(10,1))/(S0(10,1)^2));B(30,19)=rou*((Y0(10,1)-Y0(11,1))/(S0(11,1)^2));B(30,20)=-rou*((X0(10,1)-X0(11,1))/(S0(11,1)^2));B(30,23)=-rou*((Y0(12,1)-Y0(11,1))/(S0(12,1)^2));B(30,24)=rou*((X0(12,1)-X0(11,1))/(S0(12,1)^2));B(31,23)=rou*((Y0(13,1)-Y0(12,1))/(S0(13,1)^2)-(Y0(11,1)-Y0(12,1))/(S0( 12,1)^2));B(31,24)=-rou*((X0(13,1)-X0(12,1))/(S0(13,1)^2)-(X0(11,1)-X0(12,1))/(S0 (12,1)^2));B(31,25)=-rou*((Y0(13,1)-Y0(12,1))/(S0(13,1)^2));B(31,26)=rou*((X0(13,1)-X0(12,1))/(S0(13,1)^2));B(32,25)=rou*((Y0(18,1)-Y0(13,1))/(S0(14,1)^2)-(Y0(12,1)-Y0(13,1))/(S0( 13,1)^2));B(32,26)=-rou*((X0(18,1)-X0(13,1))/(S0(14,1)^2)-(X0(12,1)-X0(13,1))/(S0 (13,1)^2));B(32,23)=rou*((Y0(12,1)-Y0(13,1))/(S0(13,1)^2));B(32,24)=-rou*((X0(12,1)-X0(13,1))/(S0(13,1)^2));B(32,21)=-rou*(Y0(18,1)-Y0(13,1))/(S0(14,1)^2);B(32,22)=rou*((X0(18,1)-X0(13,1))/(S0(14,1)^2));B(33,21)=rou*((Y0(1,1)-Y0(18,1))/(S0(1,1)^2)-(Y0(13,1)-Y0(18,1))/(S0(14 ,1)^2));B(33,22)=-rou*((X0(1,1)-X0(18,1))/(S0(1,1)^2)-(X0(13,1)-X0(18,1))/(S0(1 4,1)^2));B(33,25)=rou*((Y0(13,1)-Y0(18,1))/(S0(14,1)^2));B(33,26)=-rou*((X0(13,1)-X0(18,1))/(S0(14,1)^2));B(33,1)=-rou*(Y0(1,1)-Y0(18,1))/(S0(1,1)^2);B(33,2)=rou*((X0(1,1)-X0(18,1))/(S0(1,1)^2));B(34,19)=rou*((Y0(10,1)-Y0(11,1))/(S0(11,1)^2));B(34,20)=-rou*((X0(10,1)-X0(11,1))/(S0(11,1)^2));B(34,27)=-rou*((Y0(16,1)-Y0(11,1))/(S0(15,1)^2));B(34,28)=rou*((X0(16,1)-X0(11,1))/(S0(15,1)^2));B(35,27)=rou*((Y0(16,1)-Y0(11,1))/(S0(15,1)^2));B(35,28)=-rou*((X0(16,1)-X0(11,1))/(S0(15,1)^2));B(35,23)=-rou*((Y0(12,1)-Y0(11,1))/(S0(12,1)^2));B(35,24)=rou*((X0(12,1)-X0(11,1))/(S0(12,1)^2));B(36,27)=rou*((Y0(11,1)-Y0(16,1))/(S0(15,1)^2)-(Y0(15,1)-Y0(16,1))/(S0( 16,1)^2));B(36,28)=-rou*((X0(11,1)-X0(16,1))/(S0(15,1)^2)-(X0(15,1)-X0(16,1))/(S0 (16,1)^2));B(37,29)=rou*((Y0(17,1)-Y0(15,1))/(S0(17,1)^2));B(37,30)=-rou*((X0(17,1)-X0(15,1))/(S0(17,1)^2));B(37,27)=-rou*((Y0(16,1)-Y0(15,1))/(S0(16,1)^2));B(37,28)=rou*((X0(16,1)-X0(15,1))/(S0(16,1)^2));B(38,29)=-rou*((Y0(17,1)-Y0(15,1))/(S0(17,1)^2));B(38,30)=rou*((X0(17,1)-X0(15,1))/(S0(17,1)^2));B(39,27)=rou*((Y0(16,1)-Y0(15,1))/(S0(16,1)^2));B(39,28)=-rou*((X0(16,1)-X0(15,1))/(S0(16,1)^2));B(40,29)=rou*((Y0(15,1)-Y0(17,1))/(S0(17,1)^2)-(Y0(18,1)-Y0(17,1))/(S0(18,1)^2));B(40,30)=-rou*((X0(15,1)-X0(17,1))/(S0(17,1)^2)-(X0(18,1)-X0(17,1))/(S0 (18,1)^2));B(40,21)=rou*((Y0(18,1)-Y0(17,1))/(S0(18,1)^2));B(40,22)=-rou*((X0(18,1)-X0(17,1))/(S0(18,1)^2));B(41,21)=rou*((Y0(17,1)-Y0(18,1))/(S0(18,1)^2)-(Y0(13,1)-Y0(18,1))/(S0( 14,1)^2));B(41,22)=-rou*((X0(17,1)-X0(18,1))/(S0(18,1)^2)-(X0(13,1)-X0(18,1))/(S0 (14,1)^2));B(41,25)=rou*((Y0(13,1)-Y0(18,1))/(S0(14,1)^2));B(41,26)=-rou*((X0(13,1)-X0(18,1))/(S0(14,1)^2));B(41,29)=-rou*(Y0(17,1)-Y0(18,1))/(S0(18,1)^2);B(41,30)=rou*((X0(17,1)-X0(18,1))/(S0(18,1)^2));B(42,21)=rou*((Y0(1,1)-Y0(18,1))/(S0(1,1)^2)-(Y0(17,1)-Y0(18,1))/(S0(18 ,1)^2));B(42,22)=-rou*((X0(1,1)-X0(18,1))/(S0(1,1)^2)-(X0(17,1)-X0(18,1))/(S0(1 8,1)^2));B(42,29)=rou*((Y0(17,1)-Y0(18,1))/(S0(18,1)^2));B(42,30)=-rou*((X0(17,1)-X0(18,1))/(S0(18,1)^2));B(42,1)=-rou*(Y0(1,1)-Y0(18,1))/(S0(1,1)^2);B(42,2)=rou*((X0(1,1)-X0(18,1))/(S0(1,1)^2));B(43,7)=rou*(Y0(4,1)-Y0(14,1))/(S0(19,1)^2);B(43,8)=-rou*((X0(4,1)-X0(14,1))/(S0(19,1)^2));B(44,7)=rou*((Y0(14,1)-Y0(4,1))/(S0(19,1)^2)-(Y0(3,1)-Y0(4,1))/(S0(4,1) ^2));B(44,8)=-rou*((X0(14,1)-X0(4,1))/(S0(19,1)^2)-(X0(3,1)-X0(4,1))/(S0(4,1 )^2));B(44,5)=rou*((Y0(3,1)-Y0(4,1))/(S0(4,1)^2));B(44,6)=-rou*((X0(3,1)-X0(4,1))/(S0(4,1)^2));B(45,7)=rou*((Y0(5,1)-Y0(4,1))/(S0(5,1)^2)-(Y0(14,1)-Y0(4,1))/(S0(19,1) ^2));B(45,8)=-rou*((X0(5,1)-X0(4,1))/(S0(5,1)^2)-(X0(14,1)-X0(4,1))/(S0(19,1 )^2));B(45,9)=-rou*((Y0(5,1)-Y0(4,1))/(S0(5,1)^2));B(45,10)=rou*((X0(5,1)-X0(4,1))/(S0(5,1)^2));%µ¥Î»»¯³ÉͳһµÄºÁÃ×for i=20:45for j=1:30B(i,j)=B(i,j)/1000;endend%P matrixP=zeros(45,45);for i=1:19P(i,i)=sgm0^2/(S0(i,1)/2000*1000)^2;endfor i=20:45P(i,i)=sgm0^2/36;endXY=inv(B'*P*B)*B'*P*L;V=B*XY-L;sgm1=sqrt(V'*P*V/r);Q=inv(B'*P*B);Dx=sgm1^2*Q;for i=1:15X1(i,1)=XY(2*i-1,1)/1000;Y1(i,1)=XY(2*i,1)/1000;endfor i=1:10X1(i,1)= X1(i,1)+ X0(i,1);Y1(i,1)= Y1(i,1)+ Y0(i,1);endX1(11,1)= X1(11,1)+ X0(18,1);Y1(11,1)= Y1(11,1)+ Y0(18,1);for i=12:13X1(i,1)= X1(i,1)+ X0(i,1);Y1(i,1)= Y1(i,1)+ Y0(i,1);endX1(14,1)= X1(14,1)+ X0(16,1);Y1(14,1)= Y1(14,1)+ Y0(16,1);X1(15,1)= X1(15,1)+ X0(17,1);Y1(15,1)= Y1(15,1)+ Y0(17,1);% question 3S1(1,1)=sqrt((X1(11,1)-X1(1,1))^2+(Y1(11,1)-Y1(1,1))^2);S1(11,1)=sqrt((X1(10,1)-X0(11,1))^2+(Y1(10,1)-Y0(11,1))^2);S1(12,1)=sqrt((X0(11,1)-X1(12,1))^2+(Y0(11,1)-Y1(12,1))^2);S1(13,1)=sqrt((X1(12,1)-X1(13,1))^2+(Y1(12,1)-Y1(13,1))^2);S1(14,1)=sqrt((X1(13,1)-X1(11,1))^2+(Y1(13,1)-Y1(11,1))^2);S1(15,1)=sqrt((X1(14,1)-X0(11,1))^2+(Y1(14,1)-Y0(11,1))^2);S1(16,1)=sqrt((X1(14,1)-X0(15,1))^2+(Y1(14,1)-Y0(15,1))^2);S1(17,1)=sqrt((X1(15,1)-X0(15,1))^2+(Y1(15,1)-Y0(15,1))^2);S1(18,1)=sqrt((X1(15,1)-X1(11,1))^2+(Y1(15,1)-Y1(11,1))^2);S1(19,1)=sqrt((X1(4,1)-X0(14,1))^2+(Y1(4,1)-Y0(14,1))^2);for i=1:9S1(i+1,1)=sqrt((X1(i,1)-X1(i+1,1))^2+(Y1(i,1)-Y1(i+1,1))^2); end%¼ÆËã¸÷½Ç¶ÈµÄ¹Û²âÖµµÄƽ²îÖµ%******¿ÉÄÜ»áÓÐ360¶ÈµÄ²îÒì*****a(1,1)=Y1(2,1)-Y1(1,1); b(1,1)=X1(2,1)-X1(1,1);c(1,1)=Y1(11,1)-Y1(1,1); d(1,1)=X1(11,1)-X1(1,1);for i=2:9a(i,1)=Y1(i+1,1)-Y1(i,1); b(i,1)=X1(i+1,1)-X1(i,1);c(i,1)=Y1(i-1,1)-Y1(i,1); d(i,1)=X1(i-1,1)-X1(i,1);enda(10,1)=Y0(11,1)-Y1(10,1); b(10,1)=X0(11,1)-X1(10,1);c(10,1)=Y1(9,1)-Y1(10,1); d(10,1)=X1(9,1)-X1(10,1);a(11,1)=Y1(12,1)-Y0(11,1); b(11,1)=X1(12,1)-X0(11,1);c(11,1)=Y1(10,1)-Y0(11,1); d(11,1)=X1(10,1)-X0(11,1);a(12,1)=Y1(13,1)-Y1(12,1); b(12,1)=X1(13,1)-X1(12,1);c(12,1)=Y0(11,1)-Y1(12,1); d(12,1)=X0(11,1)-X1(12,1);a(13,1)=Y1(11,1)-Y1(13,1); b(13,1)=X1(11,1)-X1(13,1);c(13,1)=Y1(12,1)-Y1(13,1); d(13,1)=X1(12,1)-X1(13,1);a(14,1)=Y1(1,1)-Y1(11,1); b(14,1)=X1(1,1)-X1(11,1);c(14,1)=Y1(13,1)-Y1(11,1); d(14,1)=X1(13,1)-X1(11,1);a(15,1)=Y1(14,1)-Y0(11,1); b(15,1)=X1(14,1)-X0(11,1);c(15,1)=Y1(10,1)-Y0(11,1); d(15,1)=X1(10,1)-X0(11,1);a(16,1)=Y1(12,1)-Y0(11,1); b(16,1)=X1(12,1)-X0(11,1);c(16,1)=Y1(14,1)-Y0(11,1); d(16,1)=X1(14,1)-X0(11,1);a(17,1)=Y0(11,1)-Y1(14,1); b(17,1)=X0(11,1)-X1(14,1); c(17,1)=Y0(15,1)-Y1(14,1); d(17,1)=X0(15,1)-X1(14,1); a(18,1)=Y1(14,1)-Y0(15,1); b(18,1)=X1(14,1)-X0(15,1); c(18,1)=Y1(15,1)-Y0(15,1); d(18,1)=X1(15,1)-X0(15,1); a(19,1)=Y1(15,1)-Y0(15,1); b(19,1)=X1(15,1)-X0(15,1); c(19,1)=Y0(14,1)-Y0(15,1); d(19,1)=X0(14,1)-X0(15,1); a(20,1)=Y0(14,1)-Y0(15,1); b(20,1)=X0(14,1)-X0(15,1); c(20,1)=Y1(14,1)-Y0(15,1); d(20,1)=X1(14,1)-X0(15,1); a(21,1)=Y0(15,1)-Y1(15,1); b(21,1)=X0(15,1)-X1(15,1); c(21,1)=Y1(11,1)-Y1(15,1); d(21,1)=X1(11,1)-X1(15,1); a(22,1)=Y1(15,1)-Y1(11,1); b(22,1)=X1(15,1)-X1(11,1); c(22,1)=Y1(13,1)-Y1(11,1); d(22,1)=X1(13,1)-X1(11,1); a(23,1)=Y1(1,1)-Y1(11,1); b(23,1)=X1(1,1)-X1(11,1);c(23,1)=Y1(15,1)-Y1(11,1); d(23,1)=X1(15,1)-X1(11,1); a(24,1)=Y0(15,1)-Y0(14,1); b(24,1)=X0(15,1)-X0(14,1); c(24,1)=Y1(4,1)-Y0(14,1); d(24,1)=X1(4,1)-X0(14,1);a(25,1)=Y0(14,1)-Y1(4,1); b(25,1)=X0(14,1)-X1(4,1);c(25,1)=Y1(3,1)-Y1(4,1); d(25,1)=X1(3,1)-X1(4,1);a(26,1)=Y1(5,1)-Y1(4,1); b(26,1)=X1(5,1)-X1(4,1);c(26,1)=Y0(14,1)-Y1(4,1); d(26,1)=X0(14,1)-X1(4,1); for i=1:26if(a(i,1)>0&&b(i,1)>0)j1(i,1)=atan(a(i,1)/b(i,1));else if(a(i,1)>0&&b(i,1)<0)j1(i,1)=atan(a(i,1)/b(i,1))+pi;else if(a(i,1)<0&&b(i,1)<0)j1(i,1)=atan(a(i,1)/b(i,1))+pi;elsej1(i,1)=atan(a(i,1)/b(i,1))+2*pi;endendendif(c(i,1)>0&&d(i,1)>0)j2(i,1)=atan(c(i,1)/d(i,1));else if(c(i,1)>0&&d(i,1)<0)j2(i,1)=atan(c(i,1)/d(i,1))+pi;else if(c(i,1)<0&&d(i,1)<0)j2(i,1)=atan(c(i,1)/d(i,1))+pi;elsej2(i,1)=atan(c(i,1)/d(i,1))+2*pi;endendendL1(i,1)=j1(i,1)-j2(i,1);if(L1(i,1)<0)L1(i,1)= L1(i,1)+2*pi;endend%***»¡¶Èת»¯Îª½Ç¶È***for i=1:26L1dms(i,:)=degrees2dms(rad2deg(L1(i,1)));end%******±ß³¤Ïà¶ÔÖÐÎó²î*****for i=1:19Sdev(i,1)=sqrt(Dx(i,i))/S1(i,1)/1000;end%*******Îó²îÍÖÔ²****for i=1:15Qx(i,1)=Q(2*i-1,2*i-1);Qy(i,1)=Q(2*i,2*i);Qxy(i,1)=Q(2*i-1,2*i);K(i,1)=sqrt((Qx(i,1)-Qy(i,1))^2+4*Qxy(i,1)^2);E(i,1)=sqrt(0.5*sgm1^2*(Qx(i,1)+Qy(i,1)+K(i,1))); F(i,1)=sqrt(0.5*sgm1^2*(Qx(i,1)+Qy(i,1)-K(i,1))); Qe(i,1)=0.5*(Qx(i,1)+Qy(i,1)+K(i,1));Fe(i,1)=atan((Qe(i,1)-Qx(i,1))/Qxy(i,1));if(Fe(i,1)<0)Fe(i,1)= Fe(i,1)+2*pi;endFe(i,1)=rad2deg(Fe(i,1));Fai(i,:)=degrees2dms( Fe(i,1));end% the next is used for iteration%{for i= 1:10X0(i,1)=X1(i,1);Y0(i,1)=Y1(i,1);endX0(18,1)=X1(11,1);Y0(18,1)=Y1(11,1);for i=12:13X0(i,1)=X1(i,1);Y0(i,1)=Y1(i,1);endX0(16,1)=X1(14,1);Y0(16,1)=Y1(14,1);X0(17,1)=X1(15,1);Y0(17,1)=Y1(15,1);%}。

vb水准

vb水准

导线测量平差水准测量平差VB程序导线测量, 水准测量, 程序符合导线平差程序如下:Const pi As Double = 3.14159265358979 Private Sub Command1_Click() Form8.Hide mj = Val(Text1.Text) If list1.Text = "等精度" Then ma = Val(Text2.Text) mb = Val(Text3.Text) End If If Opt1.Value Then ij = 1 ElseIf Opt2.V alue Then ij = Val(Text4.Text) End If CommonDialog1.ShowOpen On Error GoTo errorhandler Open CommonDialog1.FileName For Input As #1 If Form8.Caption = "闭合导线" Then Input #1, bi1, bi2 End If Dim a1() Do n1 = n1 + 1 ReDim Preserve a1(1 To n1) Input #1, a1(n1) Loop Until Left(a1(n1), 1) = "*" n1 = (n1 - 1) / 3 ReDim Preserve a1(1 To 3 * n1) Dim c() Do t = t + 1 ReDim Preserve c(1 To t) Input #1, c(t) Loop Until Left(c(t), 1) = "*" t = t - 1 ReDim Preserve c(1 To t) Dim b1() If list1.Text = "等精度" Then '等精度时,取角度和距离观测值Do n2 = n2 + 1 ReDim Preserve b1(1 To n2) Input #1, b1(n2) Loop Until Left(b1(n2), 1) = "*" n2 = (n2 - 1) / 4 ReDim Preserve b1(1 To 4 * n2) Dim d1() Do While Not EOF(1) n3 = n3 + 1 ReDim Preserve d1(1 To n3) Input #1, d1(n3) Loop n3 = n3 / 3 ElseIf list1.Text = "不等精度" Then '不等精度时,取角度和距离观测值以及中误差Dim b5() Do n2 = n2 + 1 ReDim Preserve b1(1 To 4 * n2), b5(1 To n2) Input #1, b1(4 * n2 - 3), b1(4 * n2 - 2), b1(4 * n2 - 1), b1(4 * n2), b5(n2) Loop Until Left(b1(4 * n2 - 3), 1) = "*" Dim d4() ReDim d1(1 To 3), d4(1 To 1) d1(1) = b1(4 * n2 - 2): d1(2) = b1(4 * n2 - 1) d1(3) = b1(4 * n2): d4(1) = b5(n2) n2 = n2 - 1 ReDim Preserve b1(1 To 4 * n2), b5(1 To n2) n3 = n3 + 1 Do While Not EOF(1) n3 = n3 + 1 ReDim Preserve d1(1 To 3 * n3), d4(1 To n3) Input #1, d1(3 * n3 - 2), d1(3 * n3 - 1), d1(3 * n3), d4(n3) Loop End If Close #1 n6 = 0 Dim ax1() If Form8.Caption = "附有条件的导线网" Then '如是附有条件的导线,取条件CommonDialog1.ShowOpen Open CommonDialog1.FileName For Input As #2 Do While Not EOF(2) n6 = n6 + 1 ReDim Preserve ax1(1 To n6) Input #2, ax1(n6) Loop n6 = n6 / 4 Close #2 End If For i = 1 To n2 If b1(4 * i - 3) Like b1(4 * i - 2) Or b1(4 * i - 3) Like b1(4 * i - 1) Or b1(4 * i - 2) Like b1(4 * i - 1) Then MsgBox "角度观测中,第" & i & "行存在重复点名!", , "错误" Exit Sub End If Next For i = 1 To n3 If d1(3 * i - 2) Like d1(3 * i - 1) Then MsgBox "边长观测中,第" & i & "行存在重复点名!", , "错误" Exit Sub End If Next Dim b11(), d11() ReDim b11(1 To 4 * n2), d11(1 To 3 * n3) For i = 1 To n2 For i1 = 1 To t If b1(4 * i - 3) Like c(i1) Then b11(4 * i - 3) = i1 + n1 GoTo 1 End If Next For i1 = 1 To n1 If b1(4 * i - 3) Like a1(3 * i1 - 2) Then b11(4 * i - 3) = i1 GoTo 1 End If Next int8 = MsgBox("角度观测中,第" & i & "行存在错误测站点" & b1(4 * i - 3) & "!", , "错误!") If int8 = vbOK Then Exit Sub 1: For i1 = 1 To t If b1(4 * i - 2) Like c(i1) Then b11(4 * i - 2) = i1 + n1 GoTo 2 End If Next For i1 = 1 To n1 If b1(4 * i - 2) Like a1(3 * i1 - 2) Then b11(4 * i - 2) = i1 GoTo 2 End If Next int8 = MsgBox("角度观测中,第" & i & "行存在错误后视点" & b1(4 * i - 2) & "!", , "错误!") If int8 = vbOK Then Exit Sub 2: For i1 = 1 To t If b1(4 * i - 1) Like c(i1) Then b11(4 * i - 1) = i1 + n1 GoTo 3 End If Next For i1 = 1 To n1 If b1(4 * i - 1) Like a1(3 * i1 - 2) Then b11(4 * i - 1) = i1 GoTo 3 End If Next int8 = MsgBox("角度观测中,第" & i & "行存在错误前视点" & b1(4 * i - 1) & "!", , "错误!") If int8 = vbOK Then Exit Sub 3: b11(4 * i) = b1(4 * i) Next For i = 1 To n3 For i1 = 1 To t If d1(3 * i - 2) Like c(i1) Then d11(3 * i - 2) = i1 + n1 GoTo 4 End If Next For i1 = 1 To n1 If d1(3 * i - 2) Like a1(3 * i1 - 2) Then d11(3 * i - 2) = i1 GoTo 4 End If Next int8 = MsgBox("边长观测中,第" & i & "行存在错误点" & d1(3 * i - 2) & "!", , "错误!") If int8 = vbOK Then Exit Sub 4: For i1 = 1 To t If d1(3 * i - 1) Like c(i1) Then d11(3 * i - 1) = i1 + n1 GoTo 5 End If Next For i1 = 1 To n1 If d1(3 * i - 1) Like a1(3 * i1 - 2) Then d11(3 * i - 1) = i1 GoTo 5 End If Next int8 = MsgBox("边长观测中,第" & i & "行存在错误点" & d1(3 * i - 1) & "!", , "错误!") If int8 = vbOK Then Exit Sub 5: d11(3 *i) = d1(3 * i) Next Dim x0() If Form8.Caption = "附合导线" Then ReDim x0(1 To 2 * t + 2) x0() = 附合导线(a1(), b11(), d11(), t) fx = x0(2 * t + 1) '坐标闭合差fy = x0(2 * t + 2) fs = Sqr(fx * fx + fy * fy) fx = Format(fx * 100, "0.0") fy = Format(fy * 100, "0.0") s = 0 For i = 1 To n3 '全长相对闭合差s = s + d1(3 * i) Next fs = Int(s / fs) For i = 1 To n2 '方位闭合差If b11(4 * i - 3) <= n1 And b11(4 * i - 2) <= n1 Then i1 = b11(4 * i - 3): i2 = b11(4 * i - 2) x1 = a1(3 * i1 - 1): y1 = a1(3 * i1) x2 = a1(3 * i2 - 1): y2 = a1(3 * i2) aq = xlu(x2, y2, x1, y1) ElseIf b11(4 * i - 3) <= n1 And b11(4 * i - 1) <= n1 Then i1 = b11(4 * i - 3): i2 = b11(4 * i - 1) x1 = a1(3 * i1 - 1): y1 = a1(3 * i1) x2 = a1(3 * i2 - 1): y2 = a1(3 * i2) az = xlu(x1, y1, x2, y2) End If bb = bb + hu(b1(4 * i)) Next bb = (aq + bb - n2 * pi - az) * 206264.806247096 bb = Format(bb, "0.00") bb1 = mj * Sqr(n2) bb1 = Format(bb1, "0.00") ReDim Preserve x0(1 To 2 * t) ElseIf Form8.Caption = "闭合导线" Then ReDim x0(1 To 2 * t + 2) x0() = 附合导线(a1(), b11(), d11(), t) fx = x0(2 * t + 1) '坐标闭合差fy = x0(2 * t + 2) fs = Sqr(fx * fx + fy * fy) fx = Format(fx * 100, "0.0") fy = Format(fy * 100, "0.0") s = 0 For i = 1 To n3 s = s + d1(3 * i) Next fs = Int(s / fs) For i = 1 To n2 bb = bb + hu(b1(4 * i)) Next If bi1 = 0 Then '方位闭合差If bi2 = 0 Then bb = (bb - (n2 - 2) * pi) * 206264.806247096 ElseIf bi2 = 1 Then bb = (bb - (n2 + 2) * pi) * 206264.806247096 End If ElseIf bi1 = 1 Then For i = 1 To n2 If b11(4 * i - 3) <= n1 And b11(4 * i - 2) <= n1 Then i1 = b11(4 * i - 3): i2 = b11(4 * i - 2) x1 = a1(3 * i1 - 1): y1 = a1(3 * i1) x2 = a1(3 * i2 - 1): y2 = a1(3 * i2) aq = xlu(x2, y2, x1, y1) End If Exit For Next If bi2 = 0 Then bb = (bb - aq - (n2 - 3) * pi) * 206264.806247096 ElseIf bi2 = 1 Then bb = (bb - aq - (n2 + 1) * pi) * 206264.806247096 End If End If bb1 = mj * Sqr(n2) bb1 = Format(bb1, "0.00") ReDim Preserve x0(1 To 2 * t) ElseIf Form8.Caption = "导线网平差" Then ReDim ax1(0) ReDim x0(1 To 2 * t) x0() = 导线网(a1(), b11(), d11(), ax1(), t) Else ReDim x0(1 To 2 * t) x0() = 导线网(a1(), b11(), d11(), ax1(), t) End If mj1 = mj For ii = 1 To ij Dim b2(), l2(), p() ReDim Preserve b2(1 To n2, 1 To 2 * t), l2(1 To n2), p(1 To n2 + n3) l2() = 角常系数1(a1(), b11(), x0()) b2() = 方系数2(a1(), b11(), x0()) Dim b3(), l3() ReDim b3(1 To n3, 1 To 2 * t), l3(1 To n3) b3() = 边系数2(a1(), d11(), x0()) l3() = 边常数项1(a1(), d11(), x0()) Dim b(), l() ReDim Preserve b(1 To n2 + n3, 2 * t), l(1 To n2 + n3) For j = 1 To 2 * t For i = 1 To n2 If b2(i, j) = "" Then b2(i, j) = 0 End If b(i, j) = 10 ^ 4 * b2(i, j) / 206264.806247096 If list1.Text = "等精度" Then p(i) = 1 ElseIf list1.Text = "不等精度" Then p(i) = mj1 * mj1 / (b5(i) * b5(i)) End If l(i) = 10 ^ 4 * l2(i) / 206264.806247096 Next For i = 1 To n3 If b3(i, j) = "" Then b3(i, j) = 0 End If b(i + n2, j) = b3(i, j) If list1.Text = "等精度" Then p(i + n2) = 2350.4 * mj1 * mj1 / ((ma + mb * d1(3 * i) / 1000) * (ma + mb * d1(3 * i) / 1000)) ElseIf list1.Text = "不等精度" Then p(i + n2) = 2350.4 * mj1 * mj1 / (d4(i) * d4(i)) End If l(i + n2) = l3(i) Next Next If Form8.Caption = "附有条件的导线网" Then '如是附有条件的导线,计算系数Dim ax(), lx() ReDim ax(1 To 2 * t, 1 To n6), lx(1 To n6) For i = 1 To n6 For i1 = 1 To n1 If ax1(4 * i - 3) Like a1(3 * i1 - 2) Then x1 = a1(3 * i1 - 1): y1 = a1(3 * i1) GoTo 111 End If Next i1 = i1 - 1 For i2 = 1 To t If ax1(4 * i - 3) Like c(i2) Then x1 = x0(2 * i2 - 1): y1 = x0(2 * i2) GoTo 111 End If Next 111: For i3 = 1 To n1 If ax1(4 * i - 2) Like a1(3 * i3 - 2) Then x1 = a1(3 * i3 - 1): y1 = a1(3 * i3) GoTo 112 End If Next i3 = i3 - 1 For i4 = 1 To t If ax1(4 * i - 2) Like c(i4) Then x2 = x0(2 * i4 - 1): y2 = x0(2 * i4) GoTo 112 End If Next 112: ss1 = Sqr((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) x3 = x2 - x1: y3 = y2 - y1 If ax1(4 * i) = 0 Then '如是方位角时,计算系数lx(i) = 10000 * (xlu(x1, y1, x2, y2) - hu(ax1(4 * i - 1))) If ax1(4 * i - 3) <> a1(3 * i1 - 2) Then ax(2 * i2 - 1, i) = 10000 * y3 / (ss1 * ss1) ax(2 * i2, i) = -10000 * x3 / (ss1 * ss1) End If If ax1(4 * i - 2) <> a1(3 * i3 - 2) Then ax(2 * i4 - 1, i) = -10000 * y3 / (ss1 * ss1) ax(2 * i4, i) = 10000 * x3 / (ss1 * ss1) End If ElseIf ax1(4 * i) = 1 Then '如是距离,计算系数lx(i) = ss1 - ax1(4 * i - 1) If ax1(4 * i- 3) <> a1(3 * i1 - 2) Then ax(2 * i2 - 1, i) = -x3 / ss1: ax(2 * i2, i) = -y3 / ss1 End If If ax1(4 * i -2) <> a1(3 * i3 - 2) Then ax(2 * i4 - 1, i) = x3 / ss1: ax(2 * i4, i) = y3 / ss1 End If End If Next Fori = 1 To 2 * t For j = 1 To n6 If ax(i, j) = "" Then ax(i, j) = 0 End If Next Next End If Dim u(), nni(), xx(), nni1() ReDim u(1 To 2 * t), nni(1 To t * (2 * t + 1)) nni() = 法系数(b(), p()) u() = 常数项(b(), p(), l()) If Form8.Caption = "附有条件的导线网" Then ReDim nni1(1 To (2 * t + n6) * (2 * t + n6 + 1) / 2) nni1() = 附有条件的法方程(nni(), ax()) ReDim Preserve u(1 To 2 * t + n6) For i = 1 To n6 u(2 * t + i) = lx(i) Next nni1() = ni(nni1(), 2 * t + n6) xx() = bx(nni1(), u()) ReDim Preserve xx(1 To 2 * t) nni() = 条件从有到无(nni1(), t, n6) Else nni() = ni(nni(), 2 * t) xx() = bx(nni(), u()) End IfFor i = 1 To 2 * tx0(i) = x0(i) + xx(i)NextDim v(), fz()ReDim v(1 To n2 + n3), fz(1 To 2 * t)v() = 改正数(b(), xx(), l())Dim v1(), v2()ReDim v1(1 To n2), v2(1 To n3)For i = 1 To n2v1(i) = v(i) * 206264.806247096 / 10000m1 = m1 + v1(i) * v1(i)Nextm1 = Sqr(m1 / (n2 - 1)): m1 = Format(m1, "0.00")For i = 1 To n3v2(i) = v(i + n2)Nextmm0 = 单位权中误差(v(), p())mm0 = Sqr(mm0 / (n2 + n3 - 2 * t + n6))m0 = mm0 * 206264.806247096 / 10000If Optd2.Value Thenmj1 = m0End IfNextDim vas1 As String * 5, vas2 As String * 5, vas3 As String * 5, vas4 As String * 20Dim vas5 As String * 10, vas6 As String * 20txt = txt & Chr(13) & Chr(10)txt = txt & "导线平差成果表" & Chr(13) & Chr(10)txt = txt & Chr(13) & Chr(10)txt = txt & "角度观测成果表" & Chr(13) & Chr(10)txt = txt & Chr(13) & Chr(10)txt = txt & "-------------------------------------------------------------------" & Chr(13) & Chr(10)txt = txt & "测站" & Space(1) & "后视" & Space(1) & "前视" & Space(1) & "方向观测值(°′″)" & Space(1) & "改正数(″)" & Space(1) & "方向平差值(°′″)" & Space(1) & Chr(13) & Chr(10)Dim f(), f1(), f2()ReDim f(1 To n2)f() = 角度平差值(v1(), b1())For i = 1 To n2ReDim f1(1 To 3), f2(1 To 3)f1() = 度分离(b1(4 * i))v1(i) = Format(v1(i), "0.00")f2() = 度分离(f(i))LSet vas1 = b1(4 * i - 3)LSet vas2 = b1(4 * i - 2)LSet vas3 = b1(4 * i - 1)LSet vas4 = f1(1) & Space(1) & f1(2) & Space(1) & f1(3)LSet vas5 = v1(i)LSet vas6 = f2(1) & Space(1) & f2(2) & Space(1) & f2(3)txt = txt & vas1 & vas2 & vas3 & vas4 & vas5 & vas6 & Chr(13) & Chr(10)Nexttxt = txt & "---------------------------------------------------------------------" & Chr(13) & Chr(10)txt = txt & Chr(13) & Chr(10)txt = txt & "边长观测成果表" & Chr(13) & Chr(10)txt = txt & Chr(13) & Chr(10)txt = txt & "---------------------------------------------------------------------" & Chr(13) & Chr(10) Dim bz()ReDim bz(1 To n3 + 3)bz() = 边长相对中误差(mm0, nni(), b3(), d1())Dim bc()ReDim bc(1 To n3)bc = 边长平差值(v2(), d1())txt = txt & "起点" & Space(1) & "终点" & Space(1) & "观测边长(m)" & Space(1) & "改正数(mm)" & "边长平差值(m)" & Space(1) & "边长观测值的相对中误差" & Chr(13) & Chr(10) Dim vas7 As String * 12, vas8 As String * 12For i = 1 To n3v2(i) = v2(i) * 1000: v2(i) = Format(v2(i), "0.0")LSet vas1 = d1(3 * i - 2)LSet vas2 = d1(3 * i - 1)LSet vas7 = d1(3 * i)LSet vas5 = v2(i)LSet vas8 = bc(i)LSet vas6 = "1:" & Space(1) & bz(i)txt = txt & vas1 & vas2 & vas7 & vas5 & vas8 & vas6 & Chr(13) & Chr(10)Nexttxt = txt & "--------------------------------------------------------------------" & Chr(13) & Chr(10)txt = txt & Chr(13) & Chr(10)txt = txt & "点位误差及误差椭圆" & Chr(13) & Chr(10)txt = txt & Chr(13) & Chr(10)txt = txt & "---------------------------------------------------------------------------------" & Chr(13) & Chr(10)txt = txt & "点号" & Space(1) & "误差X(mm)" & Space(1) & "误差Y(mm)" & Space(1) & "点位误差(mm)" & Space(1) & "椭圆长轴E(mm)" & Space(1) & "椭圆短轴(mm)" & Space(1) & "方位角(°′″)" & Chr(13) & Chr(10)Dim dw(), e()ReDim dw(1 To 3 * t), e(1 To 3 * t)dw() = 点位误差(mm0, t, nni())e() = 点位误差椭圆(mm0, t, nni())Dim vas9 As String * 10, vas10 As String * 10, vas11 As String * 12, vas12 As String * 12For i = 1 To tf1() = 度分离(e(3 * i))LSet vas1 = c(i)LSet vas9 = dw(3 * i - 2)LSet vas10 = dw(3 * i - 1)LSet vas7 = dw(3 * i)LSet vas8 = e(3 * i - 2)LSet vas11 = e(3 * i - 1)LSet vas12 = f1(1) & Space(1) & f1(2) & Space(1) & f1(3)txt = txt & vas1 & vas9 & vas10 & vas7 & vas8 & vas11 & vas12 & Chr(13) & Chr(10)Nexttxt = txt & "---------------------------------------------------------------------------------" & Chr(13) & Chr(10)txt = txt & Chr(13) & Chr(10)txt = txt & "坐标成果表" & Chr(13) & Chr(10)txt = txt & Chr(13) & Chr(10)txt = txt & "----------------------------------------------" & Chr(13) & Chr(10)txt = txt & "点号" & Space(2) & "坐标X(m)" & Space(12) & "坐标Y(m)" & Space(11) & Chr(13) & Chr(10)For i = 1 To n1LSet vas1 = a1(3 * i - 2)LSet vas4 = a1(3 * i - 1)LSet vas6 = a1(3 * i)txt = txt & vas1 & vas4 & vas6 & Chr(13) & Chr(10)NextFor i = 1 To tx0(2 * i - 1) = Format(x0(2 * i - 1), "0.0000"): x0(2 * i) = Format(x0(2 * i), "0.0000")LSet vas1 = c(i)LSet vas4 = x0(2 * i - 1)LSet vas6 = x0(2 * i)txt = txt & vas1 & vas4 & vas6 & Chr(13) & Chr(10)Nextm0 = Format(m0, "0.0")txt = txt & "---------------------------------------------" & Chr(13) & Chr(10)txt = txt & Chr(13) & Chr(10)txt = txt & "整网精度评定" & Chr(13) & Chr(10)txt = txt & Chr(13) & Chr(10)Dim vass As String * 20, vas17 As String * 20txt = txt & "----------------------------------------------" & Chr(13) & Chr(10) LSet vass = "导线全长:"LSet vas17 = bz(n3 + 3) & "Km"txt = txt & vass & vas17 & Chr(13) & Chr(10)LSet vass = "验前测角中误差:"LSet vas17 = mj & "″"txt = txt & vass & vas17 & Chr(13) & Chr(10)LSet vass = "验后测角中误差:"LSet vas17 = m1 & "″"txt = txt & vass & vas17 & Chr(13) & Chr(10)If Form8.Caption = "附合导线" ThenLSet vass = "实测角度闭合差:"LSet vas17 = bb & "″"txt = txt & vass & vas17 & Chr(13) & Chr(10)LSet vass = "允许角度闭合差:"LSet vas17 = bb1 & "″"txt = txt & vass & vas17 & Chr(13) & Chr(10)LSet vass = "坐标闭合差(cm):"LSet vas17 = "fx=" & fx & Space(1) & "fy=" & fytxt = txt & vass & vas17 & Chr(13) & Chr(10)LSet vass = "坐标增量相对差:"LSet vas17 = "1:" & fstxt = txt & vass & vas17 & Chr(13) & Chr(10)ElseIf Form8.Caption = "闭合导线" Thenbb = Format(bb, "0.0")LSet vass = "角度闭合差:"LSet vas17 = bb & "″"txt = txt & vass & vas17 & Chr(13) & Chr(10)LSet vass = "允许角度闭合差:"LSet vas17 = bb1 & "″"txt = txt & vass & vas17 & Chr(13) & Chr(10)LSet vass = "坐标闭合差(cm):"LSet vas17 = "fx=" & fx & Space(1) & "fy=" & fytxt = txt & vass & vas17 & Chr(13) & Chr(10)LSet vass = "坐标增量相对差:"LSet vas17 = "1:" & fstxt = txt & vass & vas17 & Chr(13) & Chr(10)End IfLSet vass = "单位权中误差:"LSet vas17 = m0 & "″"txt = txt & vass & vas17 & Chr(13) & Chr(10)LSet vass = "最弱边相对中误差" & "(" & d1(3 * bz(n3 + 1) - 2) & "-" & d1(3 * bz(n3 + 1) - 1) & ")" & ":"LSet vas17 = "1:" & bz(n3 + 2)txt = txt & vass & vas17 & Chr(13) & Chr(10)Form1.Text1.Alignment = 2Form1.Text1.Text = txterrorhandler:If Err.Number = 75 ThenExit SubEnd If100: End SubPrivate Sub list1_Click()If list1.Text = "不等精度" Then '等精度和不等精度的互换Label1.Caption = "单位权中误差(″)"Text2.BackColor = &H80000004Text2.Locked = TrueText3.BackColor = &H80000004Text3.Locked = TrueElseIf list1.Text = "等精度" ThenLabel1.Caption = "测角中误差(″)"Text2.BackColor = &H80000005Text2.Locked = FalseText3.BackColor = &H80000005Text3.Locked = FalseEnd IfEnd SubPrivate Sub Opt1_Click()If Opt1.Value ThenFrame3.Enabled = FalseLabel5.Enabled = FalseText4.BackColor = &H80000004Text4.Text = 1Text4.Locked = TrueOptd1.Enabled = FalseOptd2.Enabled = FalseEnd IfEnd SubPrivate Sub Opt2_Click()If Opt2.Value ThenFrame3.Enabled = TrueLabel5.Enabled = TrueText4.BackColor = &H80000005 Text4.Locked = FalseOptd1.Enabled = TrueOptd1.Value = TrueOptd2.Enabled = TrueEnd IfEnd SubPrivate Function 查错(a1(), n1, n2)End Function[em1][em1][em1]。

平差程序核心代码(VB)

平差程序核心代码(VB)

原文地址:平差程序核心代码(VB)作者:俞礼彬平差核心代码群:Const PI = 3.14159265358932'求AB的坐标方位角,输入是两点坐标,输出的是弧度值Public Function DirectAB(Xa#, Y a#, Xb#, Yb#) As Double Dim detX#, detY#, tana#detX = Xb - XadetY = Yb - Y aIf Abs(detX) < 0.000001 ThenIf detY > 0 ThenDirectAB = PI / 2ElseDirectAB = PI * 3 / 2End IfElsetana = detY / detXDirectAB = Atn(tana)If detX < 0 ThenDirectAB = PI + DirectABElseIf detX > 0 And detY < 0 ThenDirectAB = PI * 2 + DirectABEnd IfEnd IfEnd Function'弧度化为度.分秒的形式:输入弧度值,输出度.分秒(各占两位)Public Function HuToDo(ByV al Hu As Double) As Single Dim du%, fen%, miao%Hu = Hu * 180 / PIdu = Fix(Hu)Hu = (Hu - du) * 60fen = Fix(Hu)Hu = (Hu - fen) * 60miao = Fix(Hu + 0.5)If miao = 60 Thenfen = fen + 1miao = 0End IfIf fen = 60 Thendu = du + 1fen = 0End IfHuToDo = du + fen / 100 + miao / 10000End Function'将度.分秒形式化为弧度:输入为度.分秒形式,输出为弧度Public Function DoToHu(ByV al DoFenMiao As Double) As Single Dim du%, fen%, miao%, angle#du = Fix(DoFenMiao)DoFenMiao = (DoFenMiao - du) * 100fen = Fix(DoFenMiao)miao = (DoFenMiao - fen) * 100angle = du + fen / 60 + miao / 3600DoToHu = angle * PI / 180End Function'矩阵转置的通用过程Public Sub MatrixTrans(A, c)Dim i%, j%Dim R1%, C1%On Error Resume NextC1 = UBound(A, 2) - LBound(A, 2) + 1If Err ThenMsgBox "输入的矩阵维数不对!"Exit SubEnd IfR1 = UBound(A, 1) - LBound(A, 1) + 1ReDim c(1 To C1, 1 To R1)For i = 1 To R1For j = 1 To C1c(j, i) = A(i, j)Next jNext iEnd Sub'矩阵相加的通用过程Public Sub MatrixPlus(A, b, c)Dim i%, j%Dim R1%, C1%, R2%, C2%On Error Resume NextC1 = UBound(A, 2) - LBound(A, 2) + 1If Err ThenMsgBox "第一个矩阵维数不对!"Exit SubEnd IfOn Error Resume NextC2 = UBound(b, 2) - LBound(b, 2) + 1If Err ThenMsgBox "第二个矩阵维数不对!"Exit SubEnd IfR1 = UBound(A, 1) - LBound(A, 1) + 1R2 = UBound(b, 1) - LBound(b, 1) + 1If R1 <> R2 Or C1 <> C2 ThenMsgBox "输入的两个矩阵维数不等,不能相加!"Exit SubEnd IfReDim c(1 To m, 1 To n) As DoubleFor i = 1 To mFor j = 1 To nc(i, j) = A(i, j) + b(i, j)Next jNext iEnd Sub'矩阵相减的通用过程Public Sub MatrixMinus(A, b, c)Dim i%, j%Dim R1%, C1%, R2%, C2%On Error Resume NextC1 = UBound(A, 2) - LBound(A, 2) + 1If Err ThenMsgBox "第一个矩阵维数不对!"Exit SubEnd IfOn Error Resume NextC2 = UBound(b, 2) - LBound(b, 2) + 1If Err ThenMsgBox "第二个矩阵维数不对!"Exit SubEnd IfR1 = UBound(A, 1) - LBound(A, 1) + 1R2 = UBound(b, 1) - LBound(b, 1) + 1If R1 <> R2 Or C1 <> C2 ThenMsgBox "输入的两个矩阵维数不等,不能相减!"Exit SubEnd IfReDim c(1 To m, 1 To n) As DoubleFor i = 1 To mFor j = 1 To nc(i, j) = A(i, j) - b(i, j)Next jNext iEnd Sub'矩阵相乘:输入矩阵或数Qa、Qb,自动识别它们的维数,并输出它们的乘积QnPublic Sub Matrix_Multy(Qn, Qa, Qb)Dim ia%, ib%, ic%Dim ai%, bi%, ci%Dim e1 As Boolean, e2 As Boolean, e3 As Boolean, e4 As Boolean, e5 As Boolean, e6 As Boolean, e7 As BooleanOn Error Resume Next '看Qa是不是一维数组ic = UBound(Qa, 2) - LBound(Qa, 2)If Err Then e1 = TrueOn Error Resume Next '看Qa是不是一维数组ib = UBound(Qb, 2) - LBound(Qb, 2)If Err Then e2 = TrueIf e1 = False And e2 = False Then '二维矩阵相乘For ai = LBound(Qa, 1) To UBound(Qa, 1)For bi = LBound(Qb, 2) To UBound(Qb, 2)For ci = LBound(Qa, 2) To UBound(Qa, 2)Qn(ai, bi) = Qn(ai, bi) + Qa(ai, ci) * Qb(ci, bi)Next ciNext biNext aiElseIf e1 = True And e2 = False ThenOn Error Resume Nextia = UBound(Qa) - LBound(Qa)If Err Then e6 = TrueIf e6 Then '数乘以二维矩阵For ai = LBound(Qb, 1) To UBound(Qb, 1)For bi = LBound(Qb, 2) To UBound(Qb, 2)Qn(ai, bi) = Qa * Qb(ai, bi)Next biNext aiElse '一维矩阵乘以二维矩阵For ci = LBound(Qb, 2) To UBound(Qb, 2)For ai = LBound(Qa, 1) To UBound(Qa, 1)Qn(ci) = Qn(ci) + Qa(ai) * Qb(ai, ci)Next aiNext ciEnd IfElseIf e1 = False And e2 = True ThenOn Error Resume Nextic = UBound(Qb) - LBound(Qb)If Err Then e7 = TrueIf e7 Then '二维矩阵乘以数For ai = LBound(Qa, 1) To UBound(Qa, 1)For bi = LBound(Qa, 2) To UBound(Qa, 2)Qn(ai, bi) = Qa(ai, bi) * QbNext biNext aiElse '二维矩阵乘以一维矩阵For ai = LBound(Qa, 1) To UBound(Qa, 1)For bi = LBound(Qa, 2) To UBound(Qa, 2)Qn(ai) = Qn(ai) + Qa(ai, bi) * Qb(bi)Next biNext aiEnd IfElseDim errT As IntegerOn Error Resume Next '结果是否是一个数errT = UBound(Qn)If Err Then e3 = TrueIf e3 Then '一维矩阵乘以一维矩阵得一个数For ai = LBound(Qa, 1) To UBound(Qa, 1)For bi = LBound(Qa, 2) To UBound(Qa, 2)Qn = Qn + Qa(ai) * Qb(bi)Next biNext aiExit SubEnd IfOn Error Resume Next '是否是数乘一维矩阵ia = UBound(Qa) - LBound(Qa)If Err Then e4 = TrueIf e4 ThenFor bi = LBound(Qa, 2) To UBound(Qa, 2)Qn(bi) = Qa * Qb(bi)Next biExit SubEnd IfOn Error Resume Next '是否是一维矩阵乘数ib = UBound(Qb) - LBound(Qb)If Err Then e5 = TrueIf e5 ThenFor ai = LBound(Qa, 1) To UBound(Qa, 1)Qn(ai) = Qa(ai) * QbNext aiExit SubEnd If'一维矩阵相乘结果是二维矩阵For ai = LBound(Qa, 1) To UBound(Qa, 1)For bi = LBound(Qa, 2) To UBound(Qa, 2)Qn(ai, bi) = Qa(ai) * Qb(bi)Next biNext aiEnd IfEnd Sub'矩阵相乘的通用过程Public Sub MatrixMulti(A, b, c)Dim i%, j%, K%Dim R1%, C1%, R2%, C2%On Error Resume NextC1 = UBound(A, 2) - LBound(A, 2) + 1If Err ThenMsgBox "第一个矩阵维数不对!"Exit SubEnd IfOn Error Resume NextC2 = UBound(b, 2) - LBound(b, 2) + 1If Err ThenMsgBox "第二个矩阵维数不对!"Exit SubEnd IfR1 = UBound(A, 1) - LBound(A, 1) + 1R2 = UBound(b, 1) - LBound(b, 1) + 1If C1 <> R2 ThenMsgBox "输入的两个矩阵大小不对,不能相乘!"Exit SubEnd Ifm = R1: s = C1: n = C2ReDim c(1 To m, 1 To n) As DoubleFor i = 1 To mFor j = 1 To nFor K = 1 To sc(i, j) = c(i, j) + A(i, K) * b(K, j)Next KNext jNext iEnd Sub'列选主元法Guass约化求解线性方程组Public Sub MajorInColGuass(A, b, X)Dim Row%, Col%, n% '矩阵大小Dim iStep%, iRow%, iCol% '循环变量Dim L() As Double '各行的约化系数'计算并检查矩阵的大小Row = UBound(A, 1) - LBound(A, 1) + 1Col = UBound(A, 2) - LBound(A, 2) + 1If Row <> Col ThenMsgBox "方程组的系数矩阵有误!"Exit SubEnd If'准备约化过程的变量和数组n = UBound(b) - LBound(b) + 1If n <> Row ThenMsgBox "方程组的系数矩阵与常数项大小不符!"Exit SubEnd IfReDim L(2 To Row) As DoubleDim sumAX As Double, iPos%, temp#'约化过程For iStep = 1 To n - 1'列选主元iPos = 0For iRow = iStep + 1 To nIf Abs(A(iRow, iStep)) > Abs(A(iStep, iStep)) TheniPos = iRowEnd IfNext iRowIf iPos > iStep Then '需要换主元For iCol = iStep To ntemp = A(iStep, iCol)A(iStep, iCol) = A(iPos, iCol)A(iPos, iCol) = tempNext iColtemp = b(iStep)b(iStep) = b(iPos)b(iPos) = tempEnd If'约化过程For iRow = iStep + 1 To nL(iRow) = A(iRow, iStep) / A(iStep, iStep)For iCol = iStep To nA(iRow, iCol) = A(iRow, iCol) - L(iRow) * A(iStep, iCol)Next iColb(iRow) = b(iRow) - L(iRow) * b(iStep)Next iRowShowMatrix ANext iStep'回代过程X(n) = b(n) / A(n, n)For iRow = n - 1 To 1 Step -1sumAX = 0For iCol = n To iRow + 1 Step -1sumAX = sumAX + A(iRow, iCol) * X(iCol)Next iColX(iRow) = (b(iRow) - sumAX) / A(iRow, iRow)Next iRowEnd Sub'Guass-Seidel迭代法求解线性方程组Private Function Seidel(A, b, X, eps#) As BooleanDim i%, j%Dim P#, Q#, s#, t#Dim Row%, Col%, n%Row = UBound(A, 1) - LBound(A, 1) + 1Col = UBound(A, 2) - LBound(A, 2) + 1n = UBound(b) - LBound(b) + 1If n <> Row ThenMsgBox "方程组的系数矩阵与常数项大小不符!"Exit FunctionEnd IfFor i = 1 To nP = 0#X(i) = 0#For j = 1 To nIf i <> j Then P = P + Abs(A(i, j))Next jIf P >= Abs(A(i, i)) ThenSeidel = FalseExit FunctionEnd IfNext iP = eps + 1#While P >= epsP = 0#For i = 1 To nt = X(i)s = 0#For j = 1 To nIf j <> i Then s = s + A(i, j) * X(j)Next jX(i) = (b(i) - s) / (A(i, i))Q = Abs(X(i) - t) '/ (1# + Abs(x(i)))If Q > P Then P = QNext iWendSeidel = TrueEnd FunctionPublic Sub ShowMatrix(tt)Dim i%, j%, n%, m%m = UBound(tt, 1) - LBound(tt, 1) + 1n = UBound(tt, 2) - LBound(tt, 2) + 1For i = 1 To mFor j = 1 To nDebug.Print tt(i, j),Next jDebug.PrintNext iEnd Sub'通用的间接平差解算过程:输入系数矩阵A、权矩阵P、常数向量L和解向量X,求出X,并通过参数传出去Public Sub InAdjust(A, P, L, X)Dim a1%, a2%, p1%, p2%, L1%, x1% '输入矩阵或向量的大小Dim At() As Double, AtP() As Double, Naa#(), W() As Double '几个中间矩阵'计算并检查输入矩阵或向量的大小On Error Resume Nexta1 = UBound(A, 1) - LBound(A, 1) + 1If Err ThenMsgBox "系数矩阵A大小错误!"Exit SubEnd IfOn Error Resume Nexta2 = UBound(A, 2) - LBound(A, 2) + 1If Err ThenMsgBox "系数矩阵A大小错误!"Exit SubEnd IfOn Error Resume NextL1 = UBound(L) - LBound(L) + 1If Err ThenMsgBox "常数向量L大小错误!"Exit SubEnd IfOn Error Resume Nextx1 = UBound(X) - LBound(X) + 1If Err ThenMsgBox "解向量X大小错误!"Exit SubEnd IfOn Error Resume Nextp1 = UBound(P, 1) - LBound(P, 1) + 1If Err ThenMsgBox "权矩阵P大小错误!"Exit SubEnd IfOn Error Resume Nextp2 = UBound(P, 2) - LBound(P, 2) + 1If Err ThenMsgBox "权矩阵P大小错误!"Exit SubEnd IfIf p1 <> p2 ThenMsgBox "权矩阵P不是方阵!"Exit SubEnd IfIf p1 <> a1 Or p2 <> a1 ThenMsgBox "权矩阵P与系数矩阵A大小不符!"Exit SubEnd IfIf a2 <> x1 ThenMsgBox "系数矩阵A大小与解向量X大小不符!" Exit SubEnd IfIf a1 <> L1 ThenMsgBox "系数矩阵A大小与常数向量L大小不符!" Exit SubEnd If'定义中间矩阵的大小ReDim At(1 To a2, 1 To a1), AtP(1 To a2, 1 To a1)ReDim Naa(1 To a2, 1 To a2), W(1 To a2)'组成法方程并计算Debug.Print "The A matrix is:"ShowMatrix AMatrixTrans A, At '求A的转置矩阵Debug.Print "The At matrix is:"ShowMatrix AtDebug.Print "The P matrix is:"ShowMatrix PMatrix_Multy AtP, At, P '求AtPDebug.Print "and The AtP matrix is:"ShowMatrix AtPMatrix_Multy Naa, AtP, A'法方程系数矩阵Debug.Print "the Naa matrix is:"ShowMatrix NaaDebug.Print "the L matrix is:"For x1 = LBound(L) To UBound(L)Debug.Print L(x1)Next x1Matrix_Multy W, AtP, L '法方程常数向量Debug.Print "the W matrix is:"For x1 = LBound(W) To UBound(W)Debug.Print W(x1)Next x1MajorInColGuass Naa, W, XDebug.Print "the X matrix is:"For x1 = LBound(X) To UBound(X)Debug.Print X(x1)Next x1'Seidel Naa, W, x, 0.000001End Sub'通用的条件平差解算过程:输入系数矩阵A、权矩阵P、常数向量L和解向量X,求出X,并通过参数传出去Public Sub CondiAdjust(b, P, W, V)Dim b1%, b2%, p1%, p2%, w1%, v1% '输入矩阵或向量的大小Dim Q#(), Bt#(), QBt#(), Nbb#(), K#(), i% '几个中间矩阵'计算并检查输入矩阵或向量的大小On Error Resume Nextb1 = UBound(b, 1) - LBound(b, 1) + 1If Err ThenMsgBox "系数矩阵B大小错误!"Exit SubEnd IfOn Error Resume Nextb2 = UBound(b, 2) - LBound(b, 2) + 1If Err ThenMsgBox "系数矩阵B大小错误!"Exit SubEnd IfOn Error Resume Nextw1 = UBound(W) - LBound(W) + 1If Err ThenMsgBox "常数向量W大小错误!"Exit SubEnd IfOn Error Resume Nextv1 = UBound(V) - LBound(V) + 1If Err ThenMsgBox "改正数向量V大小错误!"Exit SubEnd IfOn Error Resume Nextp1 = UBound(P, 1) - LBound(P, 1) + 1If Err ThenMsgBox "权矩阵P大小错误!"Exit SubEnd IfOn Error Resume Nextp2 = UBound(P, 2) - LBound(P, 2) + 1If Err ThenMsgBox "权矩阵P大小错误!"Exit SubEnd IfIf p1 <> p2 ThenMsgBox "权矩阵P不是方阵!"Exit SubEnd IfIf p1 <> b2 ThenMsgBox "权矩阵P与系数矩阵A大小不符!"Exit SubEnd IfIf b2 <> v1 ThenMsgBox "系数矩阵B大小与解向量V大小不符!"Exit SubEnd IfIf b1 <> w1 ThenMsgBox "系数矩阵B大小与常数向量W大小不符!"Exit SubEnd If'定义中间矩阵的大小ReDim Bt(1 To b2, 1 To b1), QBt(1 To b2, 1 To b1)ReDim Nbb(1 To b1, 1 To b1), K(1 To b1), Q(1 To p1, 1 To p2)'组成法方程并计算For i = 1 To p1 '求Q矩阵Q(i, i) = 1 / P(i, i)Next iMatrixTrans b, BtMatrix_Multy QBt, Q, BtMatrix_Multy Nbb, b, QBt '法方程系数矩阵ShowMatrix NbbMajorInColGuass Nbb, W, K '解法方程'Seidel Nbb, W, K, 0.0000001Matrix_Multy V, QBt, K '求改正数End Sub。

闭(附)合路线水准测量平差计算表

闭(附)合路线水准测量平差计算表

闭(附)合路线水准测量平差计算表
承包单位:黑龙江龙建路桥有限公司 合同号:HBTJ-02 第 页 共 页
闭(附)合路线水准测量平差计算表
承包单位:黑龙江龙建路桥有限公司 合同号:HBTJ-02 第 页 共 页
闭(附)合路线水准测量平差计算表
承包单位:黑龙江龙建路桥有限公司 合同号:HBTJ-02 第 页 共 页
闭(附)合路线水准测量平差计算表
承包单位:黑龙江龙建路桥有限公司 合同号:HBTJ-02 第 页 共 页
闭(附)合路线水准测量平差计算表
承包单位:黑龙江龙建路桥有限公司 合同号:HBTJ-02 第 页 共 页。

闭 附 合水准路线测量平差计算表

闭 附 合水准路线测量平差计算表

计算: 复核: 技术负责人:
合同号:BGSG
闭(附)合水准路线测量平差计算表
承包人:锡林郭勒汇通路桥有限责任公司省道309宝沽公路
项目部总监办:锡林郭勒盟协力交通监理有限公司省道309线宝沽
计算: 复核: 技术负责人:
闭(附)合水准路线测量平差计算表
合同号:BGSG
承包人:锡林郭勒汇通路桥有限责任公司省道309宝沽公路
项目部总监办:锡林郭勒盟协力交通监理有限公司省道309线宝沽
计算: 复核: 技术负责人:
合同号:BGSG
闭(附)合水准路线测量平差计算表
承包人:锡林郭勒汇通路桥有限责任公司省道309宝沽公路
项目部总监办:锡林郭勒盟协力交通监理有限公司省道309线宝沽
计算: 复核: 技术负责人:
闭(附)合水准路线测量平差计算表
合同号:BGSG
承包人:锡林郭勒汇通路桥有限责任公司省道309宝沽公路
项目部总监办:锡林郭勒盟协力交通监理有限公司省道309线宝沽
闭(附)合水准路线测量平差计算表
合同号:BGSG
承包人:锡林郭勒汇通路桥有限责任公司省道309宝沽公路
项目部总监办:锡林郭勒盟协力交通监理有限公司省道309线宝沽
计算: 复核: 技术负责人:。

(整理)导线测量平差教程—计算方案设置

(整理)导线测量平差教程—计算方案设置

计算方案的设置一、导线类型:1.闭、附合导线(图1)2.无定向导线(图2)3.支导线(图3)4.特殊导线及导线网、高程网(见数据输入一节),该选项适用于所有的导线,但不计算闭合差。

而且该类型不需要填写未知点数目。

当点击表格最后一行时自动添加一行,计算时删除后面的空行。

5.坐标导线。

指使用全站仪直接观测坐标、高程的闭、附合导线。

6.单面单程水准测量记录计算。

指仅进行单面读数且仅进行往测而无返测的水准测量记录计算。

当数据中没有输入“中视”时可以用作五等、等外水准等的记录计算。

当输入了“中视”时可以用作中平测量等的记录计算。

说明:除“单面单程水准测量记录计算”仅用于低等级的水准测量记录计算外,其它类型选项都可以进行平面及高程的平差计算,输入了平面数据则进行平面的平差,输入了高程数据则进行高程的平差,同时输入则同时平差。

如果不需进行平面的平差,仅计算闭、附合高程路线,可以选择类型为“无定向导线”,或者选择类型为“闭附合导线”但表格中第一行及最后一行数据(均为定向点)不必输入,因为高程路线不需定向点。

二、概算1.对方向、边长进行投影改化及边长的高程归化,也可以只选择其中的一项改正。

2.应选择相应的坐标系统,以及Y坐标是否包含500KM。

选择了概算时,Y坐标不应包含带号。

三、等级与限差1.在选择好导线类型后,再选择平面及高程的等级,以便根据《工程测量规范》自动填写限差等设置。

如果填写的值不符合您所使用的规范,则再修改各项值的设置。

比如现行的《公路勘测规范》的三级导线比《工程测量规范》的三级导线要求要低一些。

2.导线测量平差4.2及以前版本没有设置限差,打开4.2及以前版本时请注意重新设置限差。

四、近似平差与严密平差的选择及近似平差的方位角、边长是否反算1.近似平差:程序先分配角度闭合差再分配坐标增量闭合差,即分别平差法。

2.严密平差:按最小二乘法原理平差。

3.《工程测量规范》规定:一级及以上平面控制网的计算,应采用严密平差法,二级及以下平面控制网,可根据需要采用严密或简化方法平差。

四等水准VB实习总结

四等水准VB实习总结

实验报告一一实验内容应用程序进行四等水准的计算二程序界面设计1 程序的设计界面2 程序的运行界面3 程序计算界面三、编写程序Option ExplicitDim startPoint!, endPoint!Private Sub cmdCheckCalc_Click()Dim i%, tDist '距离tDist = 0Dim totalDetH!, closeDetH! '累计高差和高差闭合差For i = 1 To nMarkstDist = tDist + dis(i)Next itotalDetH = 0For i = 1 To nMarks '计算累计高差totalDetH = totalDetH + detH(i)Next i'计算闭合差startPoint = Val(txtStartPoint.Text)endPoint = Val(txtEndPoint.Text)If optAnnex.Value Then '附合水准closeDetH = (endPoint - startPoint) - totalDetHElse '闭合水准和支水准closeDetH = -totalDetHEnd If'检查闭合差是否超限If closeDetH > 0.04 * Sqr(tDist) Then '采用40*Sqr(L)来计算,单位是毫米MsgBox "闭合差超限,测量成果不合格!", , "闭合差超限"txtShowResult.Text = txtShowResult.Text & "闭合差超限,测量成果不合格!"Exit SubElseMsgBox "闭合差合格,继续计算转点高程!", , "闭合差合格"End IfDim temp!temp = startPointtxtShowResult.Text = txtShowResult.Text & "平差后的高程为:" & vbCrLf For i = 0 To nMarkstemp = temp + detH(i) + closeDetH * dis(i) / tDisttxtShowResult.Text = txtShowResult.Text & " (" & Str(i) & "):" & Str(Format(temp, "0.000")) & vbCrLfNext iEnd SubPrivate Sub cmdExit_Click()EndEnd SubPrivate Sub cmdInput_Click()'检查输入的几个文本框:是否已经输入了If txtStartPoint.Text = "0" ThenMsgBox "还没有输入起始点高程!"Exit SubEnd IfIf txtEndPoint.Text = "0" And optAnnex.Value = True Then MsgBox "还没有输入终点高程!"Exit SubEnd IfIf txtBMNum.Text = "0" And optAnnex.Value = True ThenMsgBox "还没有输入测站数!"Exit SubEnd IffrmInput.ShowEnd SubPrivate Sub optAnnex_Click()txtEndPoint.Enabled = optAnnex.ValueEnd SubPrivate Sub optClose_Click()txtEndPoint.Enabled = Not optClose.ValueEnd SubPrivate Sub optSpur_Click()txtEndPoint.Enabled = Not optSpur.ValueEnd SubPrivate Sub Timer1_Timer()Label5.Caption = NowEnd SubPrivate Sub txtStartPoint_LostFocus()If Not IsNumeric(txtStartPoint.Text) ThenMsgBox "输入的高程含有非数字字符!"txtStartPoint.Text = ""txtStartPoint.SetFocusExit SubEnd IfIf Val(txtStartPoint.Text) > 5000 Or Val(txtStartPoint.Text) < -100 ThenMsgBox "输入的高程有误!"txtStartPoint.Text = ""txtStartPoint.SetFocusExit SubEnd IfstartPoint = Val(txtStartPoint.Text)End SubPrivate Sub txtEndPoint_LostFocus()If Not IsNumeric(txtEndPoint.Text) ThenMsgBox "输入的高程含有非数字字符!"txtEndPoint.Text = ""txtEndPoint.SetFocusExit SubEnd IfIf Val(txtEndPoint.Text) > 5000 Or Val(txtEndPoint.Text) < -100 Then MsgBox "输入的高程有误!"txtEndPoint.Text = ""txtEndPoint.SetFocusExit SubEnd IfendPoint = Val(txtEndPoint.Text)End SubPrivate Sub txtBMNum_LostFocus()If Not IsNumeric(txtBMNum.Text) ThenMsgBox "输入的测站数含有非数字字符或尚未输入!"txtBMNum.Text = ""txtBMNum.SetFocusExit SubEnd IfnMarks = Val(txtBMNum.Text)If txtBMNum.Text <> "" And (nMarks > 20 Or nMarks < 2) ThenMsgBox "输入的测站数有误!"txtBMNum.Text = ""txtBMNum.SetFocusExit SubEnd IfReDim dis(nMarks) As Single, detH(nMarks) As SingleEnd Sub四总结通过这次对VB测量程序的学习,让我们认识到了VB在生活中的广泛应用,我们完成了一个个程序的输入,运行,我感慨非常的高兴,更加激发了我对VB 这门课程的学习,让我们在其中学到了许多的知识,增加了我们的视野,为我们以后的工作打下了坚实的基础。

四等水准测量VB 程序 代码

四等水准测量VB 程序 代码

四等水准测量VB 程序Private Sub Command1_Click()Dim BBU As SingleDim BBM As SingleDim BBL As SingleDim BRM As SingleDim BK As SingleDim FBU As SingleDim FBM As SingleDim FBL As SingleDim FRM As SingleDim FK As SingleBBU = Val(ltrim$(rtrim$(Text1.Text) ))BBM = Val(ltrim$(rtrim$(Text2.Text) ))BBL = Val(ltrim$(rtrim$(Text3.Text) ))BRM = Val(ltrim$(rtrim$(Text4.Text) ))BK = Val(ltrim$(rtrim$(Text9.Text) ))FBU = Val(ltrim$(rtrim$(Text5.Text) ))FBM = Val(ltrim$(rtrim$(Text6.Text) ))FBL = Val(ltrim$(rtrim$(Text7.Text) ))FRM = Val(ltrim$(rtrim$(Text8.Text) ))FK = Val(ltrim$(rtrim$(Text10.Text) ))bdh = (BBM - FBM) '黑面高差'fdh = (BRM - FRM) '红面高差'If BK > FK Thenfdh = fdh - 0.1Elsefdh = fdh + 0.1End IfIf Abs((BBU - BBL) - (FBU - FBL)) * 100 > 3 Then MsgBox "前后视距较差超限"Exit Sub '退出程序'ElseIf Abs(BBM + BK - BRM) > 0.003 Then MsgBox "后视黑~红面读数较差超限"Exit Sub '退出程序'ElseIf Abs(FBM + FK - FRM) > 0.003 Then MsgBox "前视黑~红面读数较差超限"Exit Sub '退出程序'ElseIf Abs(bdh - fdh) > 0.005 ThenMsgBox "黑红面所测高差较差超限"Exit Sub '退出程序'Elsedh = Format((bdh + fdh) / 2, "0.0000") '计算高差'MsgBox "测站高差="& Str$(dh) &”m”,vbokonly,”计算结果” End IfDim hsjl As SingleDim qsjl As SingleDim qhsjc As SingleDim qhsjljc As SingleDim hchhmdsc As SingleDim qchhmdsc As SingleDim hmgc As SingleDim hmgc1 As SingleDim hhmgczc As Singlehsjl = (BBU - BBL) * 100qsjl = (FBU - FBL) * 100qhsjc = qsjl - hsjlhchhmdsc = BBU - BRMqchhmdsc = FBU - FRMhmgc = BBM - FBMhmgc1 = BRM - FRMhhmgczc = hmgc - hmgc1Text1.Text = Format(hsjl, "0.0000")Text2.Text = Format(qsjl, "0.0000")Text3.Text = Format(qhsjc, "0.0000")Text4.Text = Format(qhsjljc, "0.0000")Text5.Text = Format(hchhmdsc, "0.0000")Text6.Text = Format(qchhmdsc, "0.0000")Text7.Text = Format(hmgc, "0.0000")Text9.Text = Format(hhmgczc, "0.0000")Text8.Text = Format(hmgc1, "0.0000")End SubDim BBU As SingleDim BBM As SingleDim BBL As SingleDim BRM As SingleDim BK As SingleDim FBU As SingleDim FBM As SingleDim FBL As SingleDim FRM As SingleDim FK As SinglePrivate Sub Combo1_Click()Dim ReTxt As StringReTxt = Combo1.ListIndexBK = Combo1.List(ReTxt)End SubPrivate Sub Combo2_Click()Dim ReTxt As StringReTxt = Combo2.ListIndexFK = Combo2.List(ReTxt)End SubPrivate Sub Command1_Click()BBU = Val(LTrim$(RTrim$(Text1.Text))) BBM = Val(LTrim$(RTrim$(Text2.Text))) BBL = Val(LTrim$(RTrim$(Text3.Text))) BRM = Val(LTrim$(RTrim$(Text4.Text)))FBU = Val(LTrim$(RTrim$(Text5.Text))) FBM = Val(LTrim$(RTrim$(Text6.Text))) FBL = Val(LTrim$(RTrim$(Text7.Text))) FRM = Val(LTrim$(RTrim$(Text8.Text)))Dim BBU As SingleDim BBM As SingleDim BBL As SingleDim BRM As SingleDim BK As SingleDim FBU As SingleDim FBM As SingleDim FBL As SingleDim FRM As SingleDim FK As SinglePrivate Sub Combo1_Click()Dim ReTxt As StringReTxt = Combo1.ListIndexBK = Combo1.List(ReTxt)End SubPrivate Sub Combo2_Click()Dim ReTxt As StringReTxt = Combo2.ListIndexFK = Combo2.List(ReTxt)End SubPrivate Sub Command1_Click()BBU = Val(LTrim$(RTrim$(Text1.Text)))BBM = Val(LTrim$(RTrim$(Text2.Text)))BBL = Val(LTrim$(RTrim$(Text3.Text)))BRM = Val(LTrim$(RTrim$(Text4.Text)))FBU = Val(LTrim$(RTrim$(Text5.Text)))FBM = Val(LTrim$(RTrim$(Text6.Text)))FBL = Val(LTrim$(RTrim$(Text7.Text)))FRM = Val(LTrim$(RTrim$(Text8.Text)))bdh = (BBM - FBM) '黑面高差'fdh = (BRM - FRM) '红面高差'If BK > FK Thenfdh = fdh - 100Elsefdh = fdh + 100End IfIf Abs((BBU - BBL) - (FBU - FBL)) * 0.1 > 3 Then MsgBox "前后视距较差超限"Exit Sub '退出程序'ElseIf Abs(BBM + BK - BRM) > 3 Then MsgBox "后视黑~红面读数较差超限"Exit Sub '退出程序'ElseIf Abs(FBM + FK - FRM) > 3 Then MsgBox "前视黑~红面读数较差超限"Exit Sub '退出程序'ElseIf Abs(bdh - fdh) > 5 ThenMsgBox "黑红面所测高差较差超限"Exit Sub '退出程序'Elsedh = Format((bdh + fdh) / 2, "0.0000") '计算高差' Text10.Text = dh / 1000End IfEnd SubPrivate Sub Command2_Click()Text1.Text = ""Text2.Text = ""Text3.Text = ""Text4.Text = ""Text5.Text = ""Text6.Text = ""Text7.Text = ""Text8.Text = ""Text9.Text = ""Text10.Text = ""Text1.SetFocusEnd Sub。

四等水准附和导线、闭合导线平差VB代码

四等水准附和导线、闭合导线平差VB代码

程序说明:数据录入文件的存储格式为:按每一测站的距离、高差形式存储,平差之前需要输入测站总数,依次点击“平差计算”、“成果分析”、“成果输出“。

Dim ds() As Single, ht() As Single, detht() As Single, zh() As Single 'ht测量高差,deth高差改正数,zh点高程Dim fht As Single, n As Integer, fr As Single, sds As Single 'fht 高差闭合差,n测站数,fr高差闭差合限差,sds线路总长Private Sub Command3_Click()EndEnd SubPrivate Sub Command5_Click()Dim i As Integern = Val(Text3.Text)If n = 0 ThenMsgBox "请输入测站数"Exit SubEnd IfReDim ht(n) As Single, ds(n) As Single, detht(n) As Single, zh(n) As SingleCD.Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*"CD.ShowOpenstrfilename = CD.FileNameOpen strfilename For Input As #1For i = 1 To nInput #1, ds(i), ht(i)If ds(i) > 160 ThenMsgBox "第" & i & "测站视距超限"Exit SubEnd IfNext iClose #1MsgBox "数据已录入"End SubPrivate Sub Command6_Click()Dim i As Integer, sht As Single, x As Single Dim a As Single, b As Singlesds = 0sht = 0For i = 1 To nsds = sds + ds(i)sht = sht + ht(i) Next iIf Option1.Value Thena = Val(Text1.Text)b = Val(Text2.Text) fht = sht - (a - b) ElseIf Option2.Value Then a = Val(Text1.Text) fht = shtEnd IfEnd Ifzh(0) = aFor i = 1 To nx = -fht * ds(i) / sdsdetht(i) = xht(i) = ht(i) + detht(i)zh(i) = zh(i - 1) + ht(i)Next iMsgBox "平差计算已完成"End SubPrivate Sub Command7_Click()Dim x As Singlefr = 40 * Sqr(sds / 1000)x = Abs(fht)If x > fr ThenMsgBox "线路全长高差闭合差超限,但系统已按照平差原理平差,如需保存结果,请点击“成果保存”按钮"Exit SubElseMsgBox "线路全长高差闭合差符合限差要求,如需保存结果,请点击“成果保存”按钮"End IfEnd SubPrivate Sub Command8_Click()Dim i As IntegerCD.Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*"CD.ShowOpenstrfilename = CD.FileNameOpen strfilename For Output As #2For i = 1 To nPrint #2, "第" & i & "测站视线长:" & ds(i) & "m",Print #2, "高差改正数:" & Format(detht(i), "0.000") & "m",Print #2, "改后高差:" & Format(ht(i), "0.000") & "m",Print #2, "高程:" & Format(zh(i), "0.000") & "m"Next iPrint #2, "路线全长:" & Format(sds / 1000, "0.000") & "km"Print #2, "路线全长高差闭合差:" & Format(fht, "0.000") & "m" Print #2, "限差:" & Format(fr / 1000, "0.000") & "m"Print #2, "解算人:×××"Print #2, "时间:" & DateClose #2MsgBox "成果已保存"End Sub。

基于 VB环境下水准网平差 程序设计研究

基于 VB环境下水准网平差 程序设计研究
1,3,4 (已知点个数,未知点个数,观测值个数)
A,P1,P2,P3 (已 知 点 和 未 知 点 点 名 )
64.382
(已知点 A 高程)
A,P1,1.315,2.4 (观测值起点,终点,高差,水平距离)
2.2 未 知 点 近 似 高 程 推 算 观测数据输入 后,程 序 就 通 过 循 环 搜 索 含 有 未
X = (A P A ) A P L m×1

-1 T
n×m n×n n×m
n×m n×n n×1
(6)
其中P 为衡量观测高差之间相对精度的权 阵 ,通 常 由 观 测 高 差 的 水 平 距 离 或 测 站 数 决 定 ,即 :
Pi

1 Si
(7)
熿S11 0 0

P = m·chm

1 Si

图 2 程 序 界 面
3.1 未 知 点 初 始 高 程 推 算 代 码
For i= 1To un //un为未知点个数// For j= 1To hn //hn为已知点个数// If pointbegan(j)= nn + i And pointend(j)< nn + i Then //已 知 点 和 未 知 点 判 断// Hknown(nn+i)= Hknown(en(j))- H(j)//推算未 知 点 近 似 高 程// Exit For End If If pointend(j)= nn + i And pointbegan(j)< nn + i Then Hknown(nn +i)= Hknown(be(j))+ H(j) Exit For End If Next j Next i
间 接 平 差 模 型 是 进 行 水 准 网 平 差 、三 角 网 平 差 、GPS数 据 后 处 理 等 过 程 中 经 常 用 到 的 模 型 。 因 为 简 接 平 差 具 有 参 数 求 解 简 单 、易 于 编 程 实 现 等 优 点 。Visual Basic 语 言 是 一 种 面 向 对 象 的 可 视 化 语 言 ,程 序 界 面 友 好 ,适 合 测 量 程 序 的 编 写 。 因 此 ,本 文 论 述 了 工 程 当 中 经 常 用 到 的 三 四 等 水 准 网 平 差 的 原 理 ,并 着 重 阐 述 了 基 于 VB 环 境 下 程 序 实 现 的 方 法 ,并 用 实 例 验 证 了 可行性。

导线网平差程序源代码

导线网平差程序源代码

程序源代码C语言程序:#include <windows.h>#include <stdarg.h>#include <stdio.h>#include <stdlib.h>#include<math.h>#define PI 3.1415926535898#define p 206264.806247#define MAX 50//矩阵的乘法运算MatrixMutiply(double Matrix1[MAX][MAX],double Matrix2[MAX][MAX],double MatrixResult[MAX][MAX],int m1,int m2,int m3){int i,j,k;double Sum;for(i=0;i<m1;i++){for(j=0;j<m3;j++){/*按照矩阵乘法的规则计算结果矩阵的i*j元素*/Sum=0;for(k=0;k<m2;k++)Sum+=Matrix1[i][k]*Matrix2[k][j];MatrixResult[i][j]=Sum;}}//return MatrixResult;}//矩阵的转置运算MatrixT(double Matrix1[MAX][MAX],double T[MAX][MAX],int m1,int m2) {//m1,m2分别是矩阵的行列数int i,j;//double T[50][50];for(i=0;i<m1;i++){for(j=0;j<m2;j++){T[j][i]=Matrix1[i][j];}}//return T;}//矩阵的逆运算void swap(double a,double b){double c=a;a=b;b=c;}double DinV(double A[50][50],int n) //n代表阶数{int i,j,k;double d;int JS[50],IS[50];for (k=0;k<n;k++){d=0;for (i=k;i<n;i++)for (j=k;j<n;j++){if (fabs(A[i][j])>d){d=fabs(A[i][j]);IS[k]=i;JS[k]=j;}}if (d+1.0==1.0)return 0;if (IS[k]!=k)for (j=0;j<n;j++)swap(A[k][j],A[IS[k]][j]);if (JS[k]!=k)for (i=0;i<n;i++)swap(A[i][k],A[i][JS[k]]);A[k][k]=1/A[k][k];for (j=0;j<n;j++)if (j!=k) A[k][j]=A[k][j]*A[k][k];for (i=0;i<n;i++)if (i!=k)for (j=0;j<n;j++)if (j!=k) A[i][j]=A[i][j]-A[i][k]*A[k][j];for (i=0;i<n;i++)if (i!=k) A[i][k]=-A[i][k]*A[k][k]; }for (k=n-1;k>=0;k--){for (j=0;j<n;j++)if (JS[k]!=k) swap(A[k][j],A[JS[k]][j]);for (i=0;i<n;i++)if (IS[k]!=k)swap(A[i][k],A[i][IS[k]]);}}//将度分秒连写的角度化为弧度值double jd_hd(double D,double F,double M){//int dd=(int)((int)B/10000); //提取度值//int ff=(int)(((int)B-dd*10000)/100); //提取分值//double mm=B-dd*10000-ff*100;//提取秒值double B;B=(D*3600.0+F*60.0+M)/p;//角度化弧度return B;}main(){double D,F,M,sigma_beta=2.0,sigma_s;//scanf("%f%f%f",&D,&F,&M);//printf("%f",jd_hd(D,F,M));doublebeta[50],alf[50],alfo[50],s[50],so[50],Xo[50],Yo[50],B[50][50]={0.0},L[50][50],P[50][50 ]={0.0},c[50][50]={0.0},wx=0.0;//此处为Xo Yo,B矩阵赋初值为零beta代表夹角,alf方位角,alfo方位角近似值,s距离观测值,so距离近似值//Xo Yo坐标近似值,B[50][50]误差矩阵,L[50]为L矩阵,P[50][50]为权阵,c[1][30]代表限制条件的系数阵,w代表限制条件常数项doubleNbb[50][50],Ncc[50][50],W[50][50],Ks,xgu[50][50],Xgu[30][1],Ygu[30][1],V[50][50],sigma_gu,Q[50][50],sigma_xy[50][50];alf[0]=PI;alfo[0]=PI;int i,j,m1,m2,m3;//将测量数据导入,并存入相应数组FILE *fp3;char strline[100]; //读取文件每行的bufferint du[100],fen[100],miao[100];double bian[100];i=0,j=1;if((fp3=fopen("D:\\111\\测量数据.txt","r"))==NULL) //文件位置和文件名{printf("文件不存在!");return 0;}while(!feof(fp3)) //判断文件是否已到末尾{fgets(strline,100,fp3); //读取一行sscanf(strline,"%d %d %d %lf",&du[i],&fen[i],&miao[i],&bian[i]); //从文件读取到的一行数据分别存放在两个数组中i++;}fclose(fp3);while(1){//printf("\n%d\t%d\t%d\t%lf",du[j],fen[j],miao[j],bian[j]);beta[j-1]=jd_hd(du[j],fen[j],miao[j]);s[j-1]=bian[j];j++;if(j>=i){break;}}Xo[0]=5000.0;Yo[0]=5000.0;Xo[15]=5000.0;Yo[15]=5000.0;so[0]=s[0];//用来求未知点坐标近似值for(i=1;i<15;i++){alf[i]=alf[i-1]+beta[i]-PI;if(alf[i]>=(2*PI)){alf[i]=alf[i]-2*PI;}Xo[i]=Xo[i-1]+s[i-1]*cos(alf[i-1]);Yo[i]=Yo[i-1]+s[i-1]*sin(alf[i-1]);//printf("X=%f\t",Xo[i]);}for(i=1;i<15;i++){//求近似距离so[i]=sqrt((Yo[i+1]-Yo[i])*(Yo[i+1]-Yo[i])+(Xo[i+1]-Xo[i])*(Xo[i+1]-Xo[i]));//求近似方位角,分象限进行讨论if((Yo[i+1]-Yo[i])>0&&(Xo[i+1]-Xo[i])>0)//第一象限{alfo[i]=atan((Yo[i+1]-Yo[i])/(Xo[i+1]-Xo[i]));}else if((Yo[i+1]-Yo[i])>0&&(Xo[i+1]-Xo[i])<0)//第二象限{alfo[i]=atan((Yo[i+1]-Yo[i])/(Xo[i+1]-Xo[i]))+PI;}else if((Yo[i+1]-Yo[i])<0&&(Xo[i+1]-Xo[i])>0)//第三象限{alfo[i]=atan((Yo[i+1]-Yo[i])/(Xo[i+1]-Xo[i]))+2*PI;}else //((Yo[i]-Yo[i-1])<0&&(Xo[i]-Xo[i-1])<0)//第四象限{alfo[i]=atan((Yo[i+1]-Yo[i])/(Xo[i+1]-Xo[i]))+PI;}//printf("alf=%f\t",alfo[i]);//printf("so=%f\t",so[i]);}//求B矩阵//将第一个角度的系数单独算出j=0;//B[0][j]=0.0;((Yo[14]-Yo[0])/(so[14]*so[14]))*p/1000.0;//B[0][j+1]=0.0;-1*((Xo[14]-Xo[0])/(so[14]*so[14]))*p/1000.0;B[0][j]=-1*(Yo[1]-Yo[0])/(so[0]*so[0])*p/1000.0;//B[0][j+1]=(Xo[1]-Xo[0])/(so[0]*so[0])*p/1000.0;B[0][26]=((Yo[14]-Yo[0])/(so[14]*so[14]))*p/1000.0;B[0][27]=-1*(Xo[14]-Xo[0])/(so[14]*so[14])*p/1000.0;//将第二个角度的系数单独算出B[1][j]=((Yo[2]-Yo[1])/(so[1]*so[1])-(Yo[0]-Yo[1])/(so[0]*so[0]))*p/1000.0;//B[1][j+1]=-1*((Xo[2]-Xo[1])/(so[1]*so[1])-(Xo[0]-Xo[1])/(so[0]*so[0]))*p/1000.0 ;B[1][j+2]=-1*((Yo[2]-Yo[1])/(so[1]*so[1]))*p/1000.0;B[1][j+3]=((Xo[2]-Xo[1])/(so[1]*so[1]))*p/1000.0;//求其他角度改正的系数for(i=2;i<15;i++){if(i<14){B[i][j]=((Yo[i-1]-Yo[i])/(so[i-1]*so[i-1]))*p/1000.0;B[i][j+1]=-1*((Xo[i-1]-Xo[i])/(so[i-1]*so[i-1]))*p/1000.0;B[i][j+2]=((Yo[i+1]-Yo[i])/(so[i]*so[i])-(Yo[i-1]-Yo[i])/(so[i-1]*so[i-1]))*p/1000.0;B[i][j+3]=-1*((Xo[i+1]-Xo[i])/(so[i]*so[i])-(Xo[i-1]-Xo[i])/(so[i-1]*so[i-1]))*p/1000. 0;B[i][j+4]=-1*((Yo[i+1]-Yo[i])/(so[i]*so[i]))*p/1000.0;B[i][j+5]=(Xo[i+1]-Xo[i])/(so[i]*so[i])*p/1000.0;}else{B[i][j]=(Yo[i-1]-Yo[i])/(so[i-1]*so[i-1])*p/1000.0;B[i][j+1]=-1*((Xo[i-1]-Xo[i])/(so[i-1]*so[i-1]))*p/1000.0;B[i][j+2]=((Yo[i+1]-Yo[i])/(so[i]*so[i])-(Yo[i-1]-Yo[i])/(so[i-1]*so[i-1]))*p/1000.0;B[i][j+3]=-1*((Xo[i+1]-Xo[i])/(so[i]*so[i])-(Xo[i-1]-Xo[i])/(so[i-1]*so[i-1]))*p/1000. 0;}j=j+2;}B[2][1]=0.0;//求边长改正的系数j=0;//将第一个边长的系数单独算出B[i][j]=(Xo[1]-Xo[0])/so[0];//B[i][j+1]=(Yo[1]-Yo[0])/so[0]; //(Yo[1]-Yo[0])/(so[0]*so[0]); i=i+1;for(i;i<30;i++){if(i<29){B[i][j]=-1*(Xo[i-14]-Xo[i-15])/so[i-15];B[i][j+1]=-1*(Yo[i-14]-Yo[i-15])/so[i-15];B[i][j+2]=-1*B[i][j];B[i][j+3]=-1*B[i][j+1];}else{B[i][j]=-1*(Xo[i-14]-Xo[i-15])/so[i-15];B[i][j+1]=-1*(Yo[i-14]-Yo[i-15])/so[i-15];}j=j+2;}B[16][1]=0.0;for(j=1;j<27;j++){for(i=0;i<30;i++){B[i][j]=B[i][j+1];}}//求L矩阵L[0][0]=(beta[0]-(alfo[0]-alfo[14]+PI))*p;for(i=1;i<30;i++){if(i<15){L[i][0]=(beta[i]-(alfo[i]-alfo[i-1]+PI))*p;if(L[i][0]>PI*p){L[i][0]=(L[i][0]-2*PI*p);}L[i][0]=L[i][0];}else{L[i][0]=(s[i-15]-so[i-15])*1000.0;}}//求权阵Pfor(i=0;i<30;i++){if(i<15){P[i][i]=1;}else{sigma_s=5+10*0.000001*s[i-15]*1000; //单位为(''/mm)的平方P[i][i]=sigma_beta*sigma_beta/(sigma_s*sigma_s);}}double Tb[50][50],Tc[50][50],MatrixResult[50][50],TV[50][50];doubletemp1[MAX][MAX],temp2[MAX][MAX],temp3[MAX][MAX],temp4[MAX][MAX],temp5[MAX][MAX];//计算Nbb矩阵,W矩阵m1=30;m2=28;MatrixT(B,Tb,m1,m2);m3=30;MatrixMutiply(Tb,P,temp1,m2,m1,m3);m3=m2;m1=m2;m2=30;MatrixMutiply(temp1,B,Nbb,m1,m2,m3);m1=27;m2=30;m3=1;MatrixMutiply(temp1,L,W,m1,m2,m3);//矩阵输出D:\\111\\导线网输出数据3027.txt文本FILE *fp;fp=fopen("D:\\111\\导线网输出数据3027.txt","w");if(fp!=NULL){fprintf(fp,"距离近似值so(单位:m):\t");fprintf(fp,"方位角近似值alfo(单位:弧度):\n");for(i=0;i<15;i++){fprintf(fp,"%4.12lf\t",so[i]);fprintf(fp,"%.12lf\n",alfo[i]);}fprintf(fp,"Xo(单位:mm):\t");fprintf(fp,"Yo(单位:mm):");fprintf(fp,"\n");for(i=0;i<15;i++){fprintf(fp,"%.6lf\t",Xo[i]);fprintf(fp,"%.6lf",Yo[i]);fprintf(fp,"\n");}fprintf(fp,"B矩阵:");fprintf(fp,"\n");for(i=0;i<30;i++){for(j=0;j<27;j++){fprintf(fp,"%.6f ",B[i][j]);}fprintf(fp,"\n");}fprintf(fp,"L矩阵(单位:秒和mm):"); fprintf(fp,"\n");for(i=0;i<30;i++){fprintf(fp,"%.6lf ",L[i][0]);fprintf(fp,"\n");}fprintf(fp,"P矩阵:");fprintf(fp,"\n");for(i=0;i<30;i++){for(j=0;j<30;j++){fprintf(fp,"%.6f ",P[i][j]);}fprintf(fp,"\n");}fprintf(fp,"Nbb矩阵:");fprintf(fp,"\n");for(i=0;i<27;i++){for(j=0;j<27;j++){fprintf(fp,"%.12f ",Nbb[i][j]);}fprintf(fp,"\n");}fclose(fp); //写入完毕,关闭文件}DinV(Nbb,27); //MatrixResult=c * Nbb的逆,此时Nbb已经变成Nbb的逆//计算x^m1=27;m2=27;m3=1;MatrixMutiply(Nbb,W,xgu,m1,m2,m3);double xgu28[50][50],sigma_xy28[50][50];xgu28[0][0]=xgu[0][0];for(i=1;i<27;i++){xgu28[i+1][0]=xgu[i][0];}xgu28[1][0]=0.0;//计算X^(即Xgu估值)Xgu[0][0]=5000.0;Ygu[0][0]=5000.0;for(i=0;i<14;i++){Xgu[i+1][0]=Xo[i+1]+xgu28[2*i][0]/1000.0;Ygu[i+1][0]=Yo[i+1]+xgu28[2*i+1][0]/1000.0; }//精度评定m1=30;m2=27;m3=1;MatrixMutiply(B,xgu,temp5,m1,m2,m3);for(i=0;i<30;i++){if(i<15){V[i][0]=(temp5[i][0]-L[i][0]);}else{V[i][0]=(temp5[i][0]-L[i][0]);}}m1=30;m2=1;MatrixT(V,TV,m1,m2);m1=1;m2=30;m3=30;MatrixMutiply(TV,P,temp4,m1,m2,m3);m1=1;m2=30;m3=1;MatrixMutiply(temp4,V,temp4,m1,m2,m3);sigma_gu=sqrt(temp4[0][0]/3); //单位权中误差double vv=0.0;for (i=0;i<15;i++){for (j=0;j<1;j++){vv=vv+V[i][j];}//puts("");}printf("%lf\t",vv);for(i=0;i<27;i++){for(j=0;j<27;j++){Q[i][j]=Nbb[i][j];}}for(i=0;i<27;i++){sigma_xy[i][0]=sqrt(Q[i][i])*sigma_gu; //坐标平差值中误差//printf("%lf\n",sigma_xy[i][0]);}sigma_xy28[0][0]=sigma_xy[0][0];for(i=1;i<27;i++){sigma_xy28[i+1][0]=sigma_xy[i][0];}sigma_xy28[1][0]=0.0;//printf("%.10lf\n",Ncc[0][0]);FILE *fp1;fp1=fopen("D:\\111\\导线网输出数据3027.txt","a"); fprintf(fp1,"Nbb的逆:");fprintf(fp1,"\n");for(i=0;i<27;i++){for(j=0;j<27;j++){fprintf(fp1,"%lf ",Nbb[i][j]);}fprintf(fp1,"\n");}fprintf(fp1,"W:");fprintf(fp1,"\n");for(i=0;i<27;i++){for(j=0;j<1;j++){fprintf(fp1,"%.12lf ",W[i][j]);}fprintf(fp1,"\n");}fprintf(fp1,"x^(单位:mm):");fprintf(fp1,"\n");for(i=0;i<28;i++){for(j=0;j<1;j++){fprintf(fp1,"%.10lf ",xgu28[i][j]);}fprintf(fp1,"\n");}fprintf(fp1,"V(单位:秒和mm):");fprintf(fp1,"\n");for(i=0;i<30;i++){for(j=0;j<1;j++){fprintf(fp1,"%.10lf ",V[i][j]);}fprintf(fp1,"\n");}fprintf(fp1,"X^(单位:m):\t");fprintf(fp1,"Y^(单位:m):");fprintf(fp1,"\n");for(i=0;i<15;i++){for(j=0;j<1;j++){fprintf(fp1,"%.6lf\t",Xgu[i][j]);fprintf(fp1,"%.6lf",Ygu[i][j]);}fprintf(fp1,"\n");}fprintf(fp1,"单位权中误差(单位:mm):\n"); fprintf(fp1,"%.10lf\n",sigma_gu);fprintf(fp1,"X坐标平差值中误差(单位:mm):\t");fprintf(fp1,"Y坐标平差值中误差(单位:mm):");fprintf(fp1,"\n");for(i=0;i<13;i++){fprintf(fp1,"%lf\t\t",sigma_xy28[2*i][0]);fprintf(fp1,"%lf",sigma_xy28[2*i+1][0]);fprintf(fp1,"\n");}}C语言画图程序//导线网概略图#include <stdio.h>#include <windows.h>#include <math.h>#define NUM 30LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow){static char szAppName[] = "SineWave" ;HWND hwnd ;MSG msg ;WNDCLASSEX wndclass ;wndclass.cbSize = sizeof (wndclass) ;wndclass.style = CS_HREDRAW | CS_VREDRAW ;wndclass.lpfnWndProc = WndProc ;wndclass.cbClsExtra = 0 ;wndclass.cbWndExtra = 0 ;wndclass.hInstance = hInstance ;wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ; wndclass.lpszMenuName = NULL ;wndclass.lpszClassName = szAppName ;wndclass.hIconSm = LoadIcon (NULL, IDI_APPLICATION) ;RegisterClassEx (&wndclass) ;hwnd = CreateWindow (szAppName, "控制网图",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT, CW_USEDEFAULT,CW_USEDEFAULT, CW_USEDEFAULT,NULL, NULL, hInstance, NULL) ;ShowWindow (hwnd, iCmdShow) ;UpdateWindow (hwnd) ;while (GetMessage (&msg, NULL, 0, 0)){TranslateMessage (&msg) ;DispatchMessage (&msg) ;}return msg.wParam ;}LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam){static int cxClient, cyClient ;HDC hdc ;int i ;PAINTSTRUCT ps ;POINT pt [NUM] ;switch (iMsg){case WM_SIZE:cxClient = LOWORD (lParam) ;cyClient = HIWORD (lParam) ;return 0 ;case WM_PAINT:hdc = BeginPaint (hwnd, &ps) ;doubley[16]={500.0,363.2211,250.8730,245.2811,343.9816,399.8183,506.0272,596.9804,6 90.1846,686.1801,688.9648,550.4837,552.8629,499.4146,497.8342,500.0}; doublex[16]={500.0,500.0,506.038,269.917,264.999,268.990,346.426,388.125,405.382,466. 024,553.062,555.201,651.049,652.317,591.707,500.0};for (i = 0 ; i < 16 ; i++){pt[i].x = x[i];pt[i].y = y[i];}Polyline (hdc, pt, 16);return 0 ;case WM_DESTROY:PostQuitMessage (0) ;return 0 ;}return DefWindowProc (hwnd, iMsg, wParam, lParam) ;}C#程序:Form1:using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using System.IO;using System.Collections.Generic;namespace导线控制网{public partial class Form1 : Form{public Form1(){InitializeComponent();}public string jisuanjieguo;public const double p = 180*3600/Math.PI;//定义角度转弧度的函数public double jiao_hu(double du,double fen,double miao){return (du*3600.0+fen*60.0+miao)/p;}//定义矩阵运算的类(包括矩阵的加、减、乘、转置和求逆)public class matrix_yusuan{//矩阵相加public static double[,] matrix_jia(double[,] Arry, double[,] Arry1) {int m = Arry.GetLength(0);int n = Arry.GetLength(1);int s = Arry1.GetLength(0);int t = Arry1.GetLength(1);double[,] temp = new double[m, n];double[,] tem = {{0}};if (m == s && n == t){for (int i = 0; i < m; i++){for (int j = 0; j < n; j++){temp[i, j] = Arry[i, j] + Arry1[i, j];}}return temp;}else{Console.WriteLine("两个矩阵大小不同");return tem ;}}//矩阵相减public static double[,] matrix_jian(double[,] Arry, double[,] Arry1) {int m = Arry.GetLength(0);int n = Arry.GetLength(1);int s = Arry1.GetLength(0);int t = Arry1.GetLength(1);double[,] temp = new double[m, n];double[,] tem = { { 0 } };if (m == s && n == t){for (int i = 0; i < m; i++){for (int j = 0; j < n; j++){temp[i, j] = Arry[i, j] - Arry1[i, j];}}return temp;}else{Console.WriteLine("两个矩阵大小不同");return tem;}}//矩阵转置public static double[,] matrix_t(double[,] Arry){int m = Arry.GetLength(0);int n = Arry.GetLength(1);double[,] temp = new double[n, m];for (int i = 0; i < n; i++){for (int j = 0; j < m; j++){temp[i,j] = Arry[j,i];}}return temp;}//矩阵相乘public static double[,] matrix_cheng(double[,] Arry, double[,] Arry1) {int m = Arry.GetLength(0);//矩阵Arry的行数int r = Arry.GetLength(1);//矩阵Arry的列数int k = Arry1.GetLength(0);//矩阵Arry的行数int n = Arry1.GetLength(1);//矩阵Arry1的列数double[,] temp = new double[m, n];double[,] tem = { { 0 } };if (r == k){for (int i = 0; i < m; i++){for (int j = 0; j < n; j++){for (int t = 0; t < r; t++){temp[i, j] += Arry[i, t] * Arry1[t, j];}}}return temp;}else{Console.WriteLine("两个矩阵无法相乘");return tem;}}//求矩阵Arry的逆矩阵public static double[,] matrix_ni(double[,] Arryni){int Level = Arryni.GetLength(1);double[,] NArry = new double[Level, Level];double HLS = matrix_yusuan.matrix_hls(Arryni);double[,] BArry = matrix_bansui(Arryni);for (int i = 0; i < Level; i++){for (int j = 0; j < Level; j++){NArry[i, j] = BArry[i, j] / HLS;}}return NArry;}//求矩阵Arry的伴随矩阵public static double[,] matrix_bansui(double[,] Arryni){int Level = Arryni.GetLength(1);double[,] BArry = new double[Level,Level];for (int m = 0; m < Level; m++){for (int n = 0; n < Level; n++){BArry[m, n] = matrix_yusuan.matrix_yuzi(Arryni, n, m);}}return BArry;}//求矩阵Arry的元素Arry[i,j]的余子式public static double matrix_yuzi(double[,] Arryni, int i, int j)//第i行,第j列,起始值为0{int Level = Arryni.GetLength(1);double[,] Arry1 = new double[Level-1,Level-1];for (int m = 0; m < Level - 1; m++){for (int n = 0; n < Level - 1; n++){if (m < i && n < j){Arry1[m, n] = Arryni[m, n];}else if(m < i && n >= j){Arry1[m, n] = Arryni[m, n + 1];}else if (m >= i && n < j){Arry1[m, n] = Arryni[m + 1, n];}else if (m >= i && n >= j){Arry1[m, n] = Arryni[m + 1, n + 1];}}}//根据矩阵元素的不同位置返回不同的值if ((i + j) % 2 != 0){return (-1)*matrix_yusuan.matrix_hls( Arry1);}else{return matrix_yusuan.matrix_hls(Arry1);}}//求行列式public static double matrix_hls(double[,] Arryni){int Level = Arryni.GetLength(1);//简单来说,对于常用的二维数组,取0或者1,分别获取列和行的长度(行数和列数)double[,] dArry = new double[Level, Level];for (int i = 0; i < Level; i++){for (int j = 0; j < Level; j++){dArry[i, j] = Arryni[i, j];}}int sign = 1;for (int i = 0, j = 0; i < Level && j < Level; i++, j++){//判断该行的正对角元素dArry[i,j]是否为0,若为0,则寻找i行以下的行m(m>i,且dArry[m,j]!=0)进行交换if (dArry[i, j] == 0){//判断是否达到了矩阵的最大行if (i == Level - 1){return 0;}int m = i + 1;//获取一个dArry[m,j]不为零的行for (; dArry[m, j] == 0; m++){if (m == Level - 1){return 0;}}//把i行和m行互换double temp;for (int n = j; n < Level; n++){temp = dArry[i, n];dArry[i, n] = dArry[m, n];dArry[m, n] = temp;}sign *= (-1);}//把当前行以下的行所对应的列变成0double tmp;//for (int s = Level - 1; s > i; s--)for (int s = i + 1; s < Level; s++){tmp = dArry[s, j];for (int t = j; t < Level; t++){dArry[s, t] -= dArry[i, t] * (tmp / dArry[i, j]); }}}double result = 1;for (int i = 0; i < Level; i++){if (dArry[i, i] != 0){result *= dArry[i, i];}else{return 0;}}return sign * result;}}public class aa//用于判断文件导入和计算是否完成{public static int panduan1 = 0;//panduan1用来判断是否进行了计算public static int panduan2 = 0;//panduan2用来判断是否导入文件}int i;int j;//定义数组double[,] hudu = new double[30, 1];double[,] bian = new double[30, 1];double[] alf = new double[30];double[] alfo = new double[30];double[] so = new double[30];double[] Xo = new double[30];double[] Yo = new double[30];double[,] B = new double[30, 27];double[,] L = new double[30, 1];double[,] P = new double[30, 30];double[,] W = new double[27, 1];double[,] temp = new double[30, 30];//此处为Xo Yo,B矩阵赋初值为零 hudu代表夹角,alf方位角,alfo方位角近似值,s 距离观测值,so距离近似值//doubleNbb[50][50],xgu[50][50],Xgu[30][1],Ygu[30][1],V[50][50],sigma_gu,Q[50][50],sigma_xy[50] [50];double[,] Nbb = new double[27, 27];double[,] xgu = new double[27, 1];double[,] xgu28 = new double[28, 1];double[,] Xgu = new double[30, 1];double[,] Ygu = new double[30, 1];double[,] V = new double[30, 1];double[,] Q = new double[27, 27];double[,] sigma_xy = new double[30, 30];double[,] sigma_xy28 = new double[30, 30];double sigma_gu;double D, F, M, sigma_hudu = 2.0, sigma_s;//用来求未知点坐标近似值private void toolStripMenuItem7_Click(object sender, EventArgs e) {if (aa.panduan1 == 1){textBox2.Text = "";textBox2.Text = "近似方位角alfo" + "\t\t" + "\r\n";for (i = 0; i < 15; i++){textBox2.Text += Math.Round(alfo[i], 6);textBox2.Text += "\r\n\r\n";}}else{MessageBox.Show("请先进行计算!", "系统提示");}}private void toolStripMenuItem10_Click(object sender, EventArgs e) {if (aa.panduan1 == 1){textBox2.Text = "";textBox2.Text = "P矩阵" + "\t\t" + "\r\n";for (i = 0; i < P.GetLength(0); i++){for (j = 0; j < P.GetLength(1); j++){textBox2.Text += Math.Round(P[i, j], 6) + "\t";}textBox2.Text += "\r\n\r\n";}}else{MessageBox.Show("请先进行计算!", "系统提示");}}private void toolStripMenuItem9_Click(object sender, EventArgs e) {if (aa.panduan1 == 1){textBox2.Text = "B矩阵" + "\t\t" + "\r\n";for (i = 0; i < B.GetLength(0); i++){for (j = 0; j < B.GetLength(1); j++){textBox2.Text += Math.Round(B[i, j], 6) + "\t";}textBox2.Text += "\r\n\r\n";}}else{MessageBox.Show("请先进行计算!", "系统提示");}}private void button15_Click(object sender, EventArgs e){if (aa.panduan2 == 1){alf[0] = Math.PI;alfo[0] = Math.PI;Xo[0] = 5000.0;Yo[0] = 5000.0;Xo[15] = 5000.0;Yo[15] = 5000.0;so[0] = bian[0, 0];for (i = 1; i < 15; i++){alf[i] = alf[i - 1] + hudu[i, 0] - Math.PI;if (alf[i] >= (2 * Math.PI)){alf[i] = alf[i] - 2 * Math.PI;}Xo[i] = Xo[i - 1] + bian[i - 1, 0] * Math.Cos(alf[i - 1]);Yo[i] = Yo[i - 1] + bian[i - 1, 0] * Math.Sin(alf[i - 1]);}jisuanjieguo += "近似距离(单位:m):" + "\r" + "近似方位角(单位:弧度):" + "\r\n";jisuanjieguo += Math.Round(so[0], 3) + "\t\t" + Math.Round(alfo[0], 6) + "\r\n";for (i = 1; i < 15; i++){//求近似距离so[i] = Math.Sqrt((Yo[i + 1] - Yo[i]) * (Yo[i + 1] - Yo[i]) + (Xo[i + 1] - Xo[i]) * (Xo[i + 1] - Xo[i]));//求近似方位角,分象限进行讨论if ((Yo[i + 1] - Yo[i]) > 0 && (Xo[i + 1] - Xo[i]) > 0)//第一象限{alfo[i] = Math.Atan((Yo[i + 1] - Yo[i]) / (Xo[i + 1] - Xo[i])); }else if ((Yo[i + 1] - Yo[i]) > 0 && (Xo[i + 1] - Xo[i]) < 0)//第二象限{alfo[i] = Math.Atan((Yo[i + 1] - Yo[i]) / (Xo[i + 1] - Xo[i])) + Math.PI;}else if ((Yo[i + 1] - Yo[i]) < 0 && (Xo[i + 1] - Xo[i]) > 0)//第三象限{alfo[i] = Math.Atan((Yo[i + 1] - Yo[i]) / (Xo[i + 1] - Xo[i])) + 2 * Math.PI;}else//((Yo[i]-Yo[i-1])<0&&(Xo[i]-Xo[i-1])<0)//第四象限{alfo[i] = Math.Atan((Yo[i + 1] - Yo[i]) / (Xo[i + 1] - Xo[i])) + Math.PI;}jisuanjieguo += Math.Round(so[i], 3) + "\t\t"+ Math.Round(alfo[i], 6) + "\r\n";}//将第一个角度的系数单独算出j = 0;//B[0][j]=0.0;((Yo[14]-Yo[0])/(so[14]*so[14]))*p/1000.0;//B[0][j+1]=0.0;-1*((Xo[14]-Xo[0])/(so[14]*so[14]))*p/1000.0;B[0, j] = -1 * (Yo[1] - Yo[0]) / (so[0] * so[0]) * p / 1000.0;//B[0][j+1]=(Xo[1]-Xo[0])/(so[0]*so[0])*p/1000.0;B[0, 25] = ((Yo[14] - Yo[0]) / (so[14] * so[14])) * p / 1000.0;B[0, 26] = -1 * (Xo[14] - Xo[0]) / (so[14] * so[14]) * p / 1000.0;//将第二个角度的系数单独算出B[1, j] = ((Yo[2] - Yo[1]) / (so[1] * so[1]) - (Yo[0] - Yo[1]) / (so[0] * so[0])) * p / 1000.0;//B[1][j+1]=-1*((Xo[2]-Xo[1])/(so[1]*so[1])-(Xo[0]-Xo[1])/(so[0]*so[0]))*p/1000.0;B[1, j + 1] = -1 * ((Yo[2] - Yo[1]) / (so[1] * so[1])) * p / 1000.0;B[1, j + 2] = ((Xo[2] - Xo[1]) / (so[1] * so[1])) * p / 1000.0;//i = i + 1;//将第三个角度的系数单独算出i = 2;B[i, j] = ((Yo[i - 1] - Yo[i]) / (so[i - 1] * so[i - 1])) * p / 1000.0;//B[i, j + 1] = -1 * ((Xo[i - 1] - Xo[i]) / (so[i - 1] * so[i - 1])) * p / 1000.0;B[i, j + 1] = ((Yo[i + 1] - Yo[i]) / (so[i] * so[i]) - (Yo[i - 1] - Yo[i]) / (so[i - 1] * so[i - 1])) * p / 1000.0;B[i, j + 2] = -1 * ((Xo[i + 1] - Xo[i]) / (so[i] * so[i]) - (Xo[i - 1] - Xo[i]) / (so[i - 1] * so[i - 1])) * p / 1000.0;B[i, j + 3] = -1 * ((Yo[i + 1] - Yo[i]) / (so[i] * so[i])) * p / 1000.0; B[i, j + 4] = (Xo[i + 1] - Xo[i]) / (so[i] * so[i]) * p / 1000.0;//求其他角度改正的系数for (i = 3; i < 15; i++){if (i < 14){B[i, j + 1] = ((Yo[i - 1] - Yo[i]) / (so[i - 1] * so[i - 1])) * p / 1000.0;B[i, j + 2] = -1 * ((Xo[i - 1] - Xo[i]) / (so[i - 1] * so[i - 1])) * p / 1000.0;B[i, j + 3] = ((Yo[i + 1] - Yo[i]) / (so[i] * so[i]) - (Yo[i - 1] - Yo[i]) / (so[i - 1] * so[i - 1])) * p / 1000.0;B[i, j + 4] = -1 * ((Xo[i + 1] - Xo[i]) / (so[i] * so[i]) - (Xo[i - 1] - Xo[i]) / (so[i - 1] * so[i - 1])) * p / 1000.0;B[i, j + 5] = -1 * ((Yo[i + 1] - Yo[i]) / (so[i] * so[i])) * p / 1000.0;B[i, j + 6] = (Xo[i + 1] - Xo[i]) / (so[i] * so[i]) * p / 1000.0; }else{B[i, j + 1] = (Yo[i - 1] - Yo[i]) / (so[i - 1] * so[i - 1]) * p / 1000.0;B[i, j + 2] = -1 * ((Xo[i - 1] - Xo[i]) / (so[i - 1] * so[i - 1])) * p / 1000.0;B[i, j + 3] = ((Yo[i + 1] - Yo[i]) / (so[i] * so[i]) - (Yo[i - 1] - Yo[i]) / (so[i - 1] * so[i - 1])) * p / 1000.0;B[i, j + 4] = -1 * ((Xo[i + 1] - Xo[i]) / (so[i] * so[i]) - (Xo[i - 1] - Xo[i]) / (so[i - 1] * so[i - 1])) * p / 1000.0;}j = j + 2;}//求边长改正的系数j = 0;//将第一个边长的系数单独算出B[i, 0] = (Xo[1] - Xo[0]) / so[0]; //(Xo[1]-Xo[0])/(so[0]*so[0]);i = i + 1;//将第二个边长的系数单独算出B[i, j] = -1 * (Xo[i - 14] - Xo[i - 15]) / so[i - 15];//B[i, j + 1] = -1 * (Yo[i - 14] - Yo[i - 15]) / so[i - 15];B[i, j + 1] = -1 * B[i, j];B[i, j + 2] = (Yo[i - 14] - Yo[i - 15]) / so[i - 15];for (i = i + 1; i < 30; i++){if (i < 29){B[i, j + 1] = -1 * (Xo[i - 14] - Xo[i - 15]) / so[i - 15];B[i, j + 2] = -1 * (Yo[i - 14] - Yo[i - 15]) / so[i - 15];B[i, j + 3] = -1 * B[i, j + 1];B[i, j + 4] = -1 * B[i, j + 2];}else{B[i, j + 1] = -1 * (Xo[i - 14] - Xo[i - 15]) / so[i - 15];B[i, j + 2] = -1 * (Yo[i - 14] - Yo[i - 15]) / so[i - 15];}j = j + 2;}jisuanjieguo += "B矩阵:" + "\r\n";for (i = 0; i < 30; i++){for (j = 0; j < 27; j++){jisuanjieguo += Math.Round(B[i, j], 6) + "\t";}jisuanjieguo += "\r\n";}//求L矩阵,角度和边长分别求解L[0, 0] = (hudu[0, 0] - (alfo[0] - alfo[14] + Math.PI)) * p;for (i = 1; i < 30; i++){if (i < 15){L[i, 0] = (hudu[i, 0] - (alfo[i] - alfo[i - 1] + Math.PI)) * p;if (L[i, 0] > Math.PI * p){L[i, 0] = (L[i, 0] - 2 * Math.PI * p);}else{L[i, 0] = L[i, 0];}}else{L[i, 0] = (bian[i - 15, 0] - so[i - 15]) * 1000.0;}}jisuanjieguo += "L矩阵(单位:秒和mm):" + "\r\n";for (i = 0; i < 30; i++){for (j = 0; j < 1; j++){jisuanjieguo += Math.Round(L[i, j], 6) + "\t\t";}jisuanjieguo += "\r\n";}//求权阵Pfor (i = 0; i < 30; i++){if (i < 15){P[i, i] = 1;}else{sigma_s = 5 + 10 * 0.000001 * bian[i - 15, 0] * 1000; //单位为(''/mm)的平方P[i, i] = sigma_hudu * sigma_hudu / (sigma_s * sigma_s);}}jisuanjieguo += "P矩阵:" + "\r\n";for (i = 0; i < 30; i++){for (j = 0; j < 30; j++){jisuanjieguo += Math.Round(P[i, j], 6) + "\t";}jisuanjieguo += "\r\n";}Nbb =matrix_yusuan.matrix_cheng(matrix_yusuan.matrix_cheng(matrix_yusuan.matrix_t(B), P), B); //计算Nbb矩阵double[,] temp2 = new double[27, 30];。

水准网平差、矩阵运算MFC代码

水准网平差、矩阵运算MFC代码

误差理论与测量平差上机指导书钱建国张恒憬编写辽宁工程技术大学测绘与地理科学学院测绘工程系目录Visual C++平差编程实现 (2)1矩阵加法 (2)2矩阵乘法 (2)3 矩阵转置 (4)4 矩阵求逆 (4)5 水准网间接平差实例(分组选做) (11)Matlab平差编程实现(分组选做) (19)1 间接平差 (19)Visual C++平差编程实现一、实验名称:解算法方程。

二、实验目的和任务:掌握矩阵加法、乘法与求逆的通用程序的编写。

三、实验要求:1每人独立编写出矩阵加法与乘法的程序,并上机调试通过;2采用VC++6.0开发平台,C或者C++语言编写程序;3写出矩阵运算的结果。

四、实验内容:1矩阵加法矩阵加法的示例函数(C语言)void JZjiafa(double a[15][15],double b[15][15],double c[15][15],intm,int n){for (int i=0;i<=m-1;i++)for(int j=0;j<=n-1;j++){c[i][j]=a[i][j]+b[i][j];}return;}2矩阵乘法矩阵乘法的示例程序(C语言)#include "stdafx.h"void matrixMultiply(double a[14][15],double b[15][13], doublec[14][13],long m,long n,long k){for (long i = 0; i<= m-1; i++){for (long j=0; j<=k-1; j++){c[i][j] =0.0;for (long q=0; q<=n-1;q++){c[i][j] = c[i][j] + a[i][q] * b[q][j];}}}return;}int main(int argc, char* argv[]){long n,m,k,i,j;double a[14][15],c[14][13],b[15][13];FILE *stream;stream = fopen("矩阵输入.txt","r");fscanf(stream,"%ld %ld",&n,&m);for (i=0;i<n;i++){for(j=0;j<m;j++){fscanf(stream,"%lf",&a[i][j]);}}fscanf(stream,"%ld %ld",&m,&k);for(i=0;i<m;i++){for(j=0;j<k;j++){fscanf(stream,"%lf",&b[i][j]);}}fclose(stream);matrixMultiply(a,b,c,4,5,3);stream = fopen("矩阵计算结果.txt","w");for (i=0;i<=3;i++){for(j=0;j<=2;j++)fprintf(stream,"%16.7e ",c[i][j]);fprintf(stream,"\n");}fprintf(stream,"\n");fclose(stream);return 0;}3 矩阵转置矩阵的转置示例函数(C语言)double JZzhuanzhi(double a[15][15], double b[15][15], int m,int n) {{for(int i=0;i<m;i++)for(int j=0;j<n;j++)b[j][i]=a[i][j];}return 0.0;}4 矩阵求逆矩阵求逆的示例函数(C语言)int invGJ(double **a,int n){int *is,*js,i,j,k,l,u,v;double d,p;is=(int *)malloc(n*sizeof(int));js=(int *)malloc(n*sizeof(int));for(k=0;k<=n-1;k++){d=0.0;for(i=k;i<=n-1;i++)for(j=k;j<=n-1;j++){l=i*n+j;p=fabs(a[i][j]);if(p>d){d=p;is[k]=i;js[k]=j;}}if(d+1.0==1.0){free(is);free(js);printf("error not inv\n");return (0);}if(is[k]!=k)for(j=0;j<=n-1;j++){u=k*n+j;v=is[k]*n+j;p=a[k][j];a[k][j]=a[is[k]][j];a[is[k]][j]=p;}if(js[k]!=k)for(i=0;i<=n-1;i++){u=i*n+k;v=i*n+js[k];p=a[i][k];a[i][k]=a[i][js[k]];a[i][js[k]]=p;}l=k*n+k;a[k][k]=1.0/a[k][k];for(j=0;j<=n-1;j++)if(j!=k){u=k*n+j;a[k][j]=a[k][j]*a[k][k];}for(i=0;i<=n-1;i++)if(i!=k)for(j=0;j<=n-1;j++)if(j!=k){u=i*n+j;a[i][j]=a[i][j]-a[i][k]*a[k][j];}for(i=0;i<=n-1;i++)if(i!=k){u=i*n+k;a[i][k]=-a[i][k]*a[k][k];}}for(k=n-1;k>=0;k--){if(js[k]!=k)for(j=0;j<=n-1;j++){u=k*n+j;v=js[k]*n+j;p=a[k][j];a[k][j]=a[js[k]][j];a[js[k]][j]=p;}if(is[k]!=k)for(i=0;i<=n-1;i++){u=i*n+k;v=i*n+is[k];p=a[i][k];a[i][k]=a[i][is[k]];a[i][is[k]]=p;}}free(is);free(js);return (1);} int invGJ(double **a,int n){int *is,*js,i,j,k,l,u,v;double d,p;is=(int *)malloc(n*sizeof(int));js=(int *)malloc(n*sizeof(int));for(k=0;k<=n-1;k++){d=0.0;for(i=k;i<=n-1;i++)for(j=k;j<=n-1;j++){l=i*n+j;p=fabs(a[i][j]);if(p>d){d=p;is[k]=i;js[k]=j;}}if(d+1.0==1.0){free(is);free(js);printf("error not inv\n");return (0);}if(is[k]!=k)for(j=0;j<=n-1;j++){u=k*n+j;v=is[k]*n+j;p=a[k][j];a[k][j]=a[is[k]][j];a[is[k]][j]=p;}if(js[k]!=k)for(i=0;i<=n-1;i++){u=i*n+k;v=i*n+js[k];p=a[i][k];a[i][k]=a[i][js[k]];a[i][js[k]]=p;}l=k*n+k;a[k][k]=1.0/a[k][k];for(j=0;j<=n-1;j++)if(j!=k){u=k*n+j;a[k][j]=a[k][j]*a[k][k];}for(i=0;i<=n-1;i++)if(i!=k)for(j=0;j<=n-1;j++)if(j!=k){u=i*n+j;a[i][j]=a[i][j]-a[i][k]*a[k][j];}for(i=0;i<=n-1;i++)if(i!=k){u=i*n+k;a[i][k]=-a[i][k]*a[k][k];}}for(k=n-1;k>=0;k--){if(js[k]!=k)for(j=0;j<=n-1;j++){u=k*n+j;v=js[k]*n+j;p=a[k][j];a[k][j]=a[js[k]][j];a[js[k]][j]=p;}if(is[k]!=k)for(i=0;i<=n-1;i++){u=i*n+k;v=i*n+is[k];p=a[i][k];a[i][k]=a[i][is[k]];a[i][is[k]]=p;}}free(is);free(js);return (1);}矩阵求逆函数的调用(C语言)#include <stdio.h>#include <stdlib.h>#include <math.h>int invGJ(double **a,int n);void main(){int i,j;double **AA;//首先对二维指针Naa分配内存,采用C语言的方法/* AA=(double **)malloc(sizeof(double)*2);for(i=0;i<2;i++){AA[i]=(double *)mallo(sizeof(double)*2);}*///首先对二维指针Naa分配内存,采用C++语言的方法AA=new double * [2];for(i=0;i<2;i++){AA[i]=new double[2];}double BB[2][2]={1,2,3,4};for(i=0;i<2;i++){for(j=0;j<2;j++){AA[i][j]=BB[i][j];}}//调用矩阵求逆函数invGJ(AA,2);printf("矩阵AA的逆阵如下\n");for(i=0;i<2;i++){for(j=0;j<2;j++){printf("%10.4lf",AA[i][j]);}printf("\n");}double CC[2][2];printf("AA与其逆阵的乘积如下(理论上是单位阵)\n"); for(i=0;i<2;i++){for(j=0;j<2;j++){CC[i][j]=0.0;for(int k=0;k<2;k++){CC[i][j]+=AA[i][k]*BB[k][j];}printf("%10.4lf",CC[i][j]);}printf("\n");}//C 语言释放AA 二维指针的方法 /* for(i=0;i<2;i++){free(AA[i]);}free(AA);*/ //C++语言释放AA 二维指针的方法 for(i=0;i<2;i++) { delete AA[i]; } delete AA;}5 水准网间接平差实例(分组选做)例1:在图1所示的水准网中,已知水准点A 的高程为H A =237.483,为求B 、C 、D 三点的高程,进行了水准测量,测得高差5×1L和水准路线的长度5×1S ,其结果见表1,试按间接平差求定B 、C 、D 三点的高程平差值。

VB开发水准测量平差软件的方法

VB开发水准测量平差软件的方法

VB开发水准测量平差软件的方法摘要:本文介绍了应用Visual Basic6.0开发的水准测量平差软件的方法。

通过软件自动生成EXCEL格式的水准测量平差计算表格进行数据处理,快速、准确计算出待求点的高程。

关键词:VB;数据处理;水准测量水准测量平差计算就是对合格的高差予以调整。

将闭合差以相反的符号按与各段水准路线长度(或按测站数)成正比的办法调整到各段高差上,求出改正后的高差再推算高程。

手工计算速度慢、工作效率低,同时易出现计算错误,而Visual Basic6.0是一种简单易学的可视化语言,用其进行编程计算就显得方便灵活。

本文结合作者工作的实践,详细地介绍了用VB开发水准测量平差软件的方法及应用。

1.VB语言的特点(1).面向对象和可视化的程序设计。

(2).事件驱动的运行机制。

(3).结构化的程序设计语言。

(4).多种数据库访问能力。

(5).提供了功能完备的应用程序集成开发环境。

(6).方便使用的联机帮助功能。

2.水准测量平差计算的方法(1).计算高差闭合差fh。

fh=Σh测 -(H终-H始)fh允=±20(按四等水准测量限差)fh≤fh允(合格)fh允—允许闭合差;Σh测—实测的各段高差和;H始—起点高程;H终—终点高程;(2).计算高差改正数Vi。

Σn —总测站数或路线总长度(km);ni —分段测站数或分段路线长度(km);(3).计算改正后高差h改i。

h改i=h测¬ + Vi(4).计算待求点高程Hi。

Hi=Hi-1+ h改i3.软件的开发原理首先在VB中设计了一个固定的界面(图3.1),添加相应功能键及数据输入文本框,通过输入相应的数据,利用VB编程实现自动生成电子表格;通过VB操作电子表格里数据进行平差计算。

根据不同的平差方法,本软件设置按距离进行平差和按测站数进行平差两种计算方法。

图3.1水准测量平差软件界面3.1参数输入方式数据输入设计成两种方式;一种是先建立文本格式(txt)的参数文件,通过编写程序代码实现直接读取数据。

导线坐标平差法的VB程序编制

导线坐标平差法的VB程序编制

Print
For i = 1 To 3
For j = 1 To 3
Print Tab(4 * j); c(i, j);
Next j
Next i
End Sub
b)矩 阵 乘 法 模 块
该模块也是很关键的一部分, 平差过程中会大量用到矩阵乘法。
模块代码:
Option Base 1
Private Sub Form_Click()
For j = 1 To n For k = 1 To n b(j, k) = a(j, k) Next k Next j next_a b(), n - 1, i ' 调用 nexta 函数 sum = sum + sign * a (1, i) * dvalue (b (), n - 1) ' 递归调用 dvalue 函数 sign = (- 1) * sign Next i End If
法为把第 I 行的数组元素赋给第 I 列, 也要一套循环语句。
程序代码:
Option Base 1
Private Sub Form_Click()
Dim m As Integer, n As Integer
Dim i As Integer, j As Integer
ReDim b(3, 3) As Integer
Print Tab(4 * j); b(i, j); ‘显示原数组 b
Next j
Next i
For i = 1 To 3
For j = 1 To 3
c(i, j) = b(j, i)
‘把第 I 行的数组元素赋给第 I 列
Next j
Next i
Print
Print "b 矩阵的转置: "; ‘显示转置后的数组以确认代码的正确性
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

程序说明:
数据录入文件的存储格式为:按每一测站的距离、高差形式存储,平差之前需要输入测站总数,依次点击“平差计算”、“成果分析”、“成果输出“。

Dim ds() As Single, ht() As Single, detht() As Single, zh() As Single 'ht测量高差,deth高差改正数,zh点高程
Dim fht As Single, n As Integer, fr As Single, sds As Single 'fht高差闭合差,n测站数,fr高差闭差合限差,sds线路总长
Private Sub Command3_Click()
End
End Sub
Private Sub Command5_Click()
Dim i As Integer
n = Val
If n = 0 Then
MsgBox "请输入测站数"
Exit Sub
End If
ReDim ht(n) As Single, ds(n) As Single, detht(n) As Single, zh(n) As Single
= "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*"
strfilename =
Open strfilename For Input As #1
For i = 1 To n
Input #1, ds(i), ht(i)
If ds(i) > 160 Then
MsgBox "第" & i & "测站视距超限"
Exit Sub
End If
Next i
Close #1
MsgBox "数据已录入"
End Sub
Private Sub Command6_Click()
Dim i As Integer, sht As Single, x As Single
Dim a As Single, b As Single
sds = 0
sht = 0
For i = 1 To n
sds = sds + ds(i)
sht = sht + ht(i)
Next i
If Then
a = Val
b = Val
fht = sht - (a - b)
Else
If Then
a = Val
fht = sht
End If
End If
zh(0) = a
For i = 1 To n
x = -fht * ds(i) / sds
detht(i) = x
ht(i) = ht(i) + detht(i)
zh(i) = zh(i - 1) + ht(i) Next i
MsgBox "平差计算已完成" End Sub
Private Sub Command7_Click()
Dim x As Single
fr = 40 * Sqr(sds / 1000)
x = Abs(fht)
If x > fr Then
MsgBox "线路全长高差闭合差超限,但系统已按照平差原理平差,如需保存结果,请点击“成果保存”按钮"
Exit Sub
Else
MsgBox "线路全长高差闭合差符合限差要求,如需保存结果,请点击“成果保存”按钮"
End If
End Sub
Private Sub Command8_Click()
Dim i As Integer
= "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*"
strfilename =
Open strfilename For Output As #2
For i = 1 To n
Print #2, "第" & i & "测站视线长:" & ds(i) & "m",
Print #2, "高差改正数:" & Format(detht(i), "") & "m",
Print #2, "改后高差:" & Format(ht(i), "") & "m",
Print #2, "高程:" & Format(zh(i), "") & "m"
Next i
Print #2, "路线全长:" & Format(sds / 1000, "") & "km"
Print #2, "路线全长高差闭合差:" & Format(fht, "") & "m"
Print #2, "限差:" & Format(fr / 1000, "") & "m" Print #2, "解算人:×××"
Print #2, "时间:" & Date
Close #2
MsgBox "成果已保存"
End Sub。

相关文档
最新文档