導(dǎo)線網(wǎng)平差程序源代碼_第1頁
導(dǎo)線網(wǎng)平差程序源代碼_第2頁
導(dǎo)線網(wǎng)平差程序源代碼_第3頁
導(dǎo)線網(wǎng)平差程序源代碼_第4頁
導(dǎo)線網(wǎng)平差程序源代碼_第5頁
已閱讀5頁,還剩41頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、精選優(yōu)質(zhì)文檔-傾情為你奉上程序源代碼C語言程序:#include <windows.h>#include <stdarg.h>#include <stdio.h>#include <stdlib.h>#include<math.h>#define PI 3.98#define p .#define MAX 50/矩陣的乘法運(yùn)算 MatrixMutiply(double Matrix1MAXMAX,double Matrix2MAXMAX,double MatrixResultMAXMAX,int m1,int m2,int m3)in

2、t i,j,k;double Sum;for(i=0;i<m1;i+) for(j=0;j<m3;j+) /*按照矩陣乘法的規(guī)則計(jì)算結(jié)果矩陣的i*j元素*/ Sum=0; for(k=0;k<m2;k+) Sum+=Matrix1ik*Matrix2kj; MatrixResultij=Sum; /return MatrixResult;/矩陣的轉(zhuǎn)置運(yùn)算 MatrixT(double Matrix1MAXMAX,double TMAXMAX,int m1,int m2) /m1,m2分別是矩陣的行列數(shù) int i,j;/double T5050; for(i=0;i<m

3、1;i+) for(j=0;j<m2;j+) Tji=Matrix1ij; /return T;/矩陣的逆運(yùn)算void swap(double a,double b)double c=a;a=b;b=c;double DinV(double A5050,int n) /n代表階數(shù) int i,j,k; double d; int JS50,IS50; for (k=0;k<n;k+) d=0; for (i=k;i<n;i+) for (j=k;j<n;j+) if (fabs(Aij)>d) d=fabs(Aij); ISk=i; JSk=j; if (d+1.

4、0=1.0) return 0; if (ISk!=k) for (j=0;j<n;j+) swap(Akj,AISkj); if (JSk!=k) for (i=0;i<n;i+) swap(Aik,AiJSk); Akk=1/Akk; for (j=0;j<n;j+) if (j!=k) Akj=Akj*Akk; for (i=0;i<n;i+) if (i!=k) for (j=0;j<n;j+) if (j!=k) Aij=Aij-Aik*Akj; for (i=0;i<n;i+) if (i!=k) Aik=-Aik*Akk; for (k=n-1

5、;k>=0;k-) for (j=0;j<n;j+) if (JSk!=k) swap(Akj,AJSkj); for (i=0;i<n;i+) if (ISk!=k) swap(Aik,AiISk); /將度分秒連寫的角度化為弧度值 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*6

6、0.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);double beta50,alf50,alfo50,s50,so50,Xo50,Yo50,B5050=0.0,L5050,P5050=0.0,c5050=0.0,wx=0.0;/此處為Xo Yo,B矩陣賦初值為零 beta代表夾角,alf方位角,alfo方位角近似值,s距離觀測值,so距離近似

7、值/Xo Yo坐標(biāo)近似值,B5050誤差矩陣,L50為L矩陣,P5050為權(quán)陣 ,c130代表限制條件的系數(shù)陣 ,w代表限制條件常數(shù)項(xiàng) double Nbb5050,Ncc5050,W5050,Ks,xgu5050,Xgu301,Ygu301,V5050,sigma_gu,Q5050,sigma_xy5050;alf0=PI;alfo0=PI;int i,j,m1,m2,m3;/將測量數(shù)據(jù)導(dǎo)入,并存入相應(yīng)數(shù)組 FILE *fp3; char strline100; /讀取文件每行的buffer int du100,fen100,miao100; double bian100; i=0,j=1;

8、 if(fp3=fopen("D:111測量數(shù)據(jù).txt","r")=NULL) /文件位置和文件名 printf("文件不存在!"); return 0; while(!feof(fp3) /判斷文件是否已到末尾 fgets(strline,100,fp3); /讀取一行 sscanf(strline,"%d %d %d %lf",&dui,&feni,&miaoi,&biani); /從文件讀取到的一行數(shù)據(jù)分別存放在兩個數(shù)組中 i+; fclose(fp3); while(1)

9、/printf("n%dt%dt%dt%lf",duj,fenj,miaoj,bianj); betaj-1=jd_hd(duj,fenj,miaoj); sj-1=bianj; j+; if(j>=i) break; Xo0=5000.0;Yo0=5000.0; Xo15=5000.0;Yo15=5000.0;so0=s0; /用來求未知點(diǎn)坐標(biāo)近似值for(i=1;i<15;i+) alfi=alfi-1+betai-PI;if(alfi>=(2*PI)alfi=alfi-2*PI;Xoi=Xoi-1+si-1*cos(alfi-1);Yoi=Yoi-1

10、+si-1*sin(alfi-1);/printf("X=%ft",Xoi);for(i=1;i<15;i+)/求近似距離 soi=sqrt(Yoi+1-Yoi)*(Yoi+1-Yoi)+(Xoi+1-Xoi)*(Xoi+1-Xoi);/求近似方位角,分象限進(jìn)行討論 if(Yoi+1-Yoi)>0&&(Xoi+1-Xoi)>0)/第一象限 alfoi=atan(Yoi+1-Yoi)/(Xoi+1-Xoi);else if(Yoi+1-Yoi)>0&&(Xoi+1-Xoi)<0)/第二象限 alfoi=atan(Y

11、oi+1-Yoi)/(Xoi+1-Xoi)+PI;else if(Yoi+1-Yoi)<0&&(Xoi+1-Xoi)>0)/第三象限 alfoi=atan(Yoi+1-Yoi)/(Xoi+1-Xoi)+2*PI;else /(Yoi-Yoi-1)<0&&(Xoi-Xoi-1)<0)/第四象限 alfoi=atan(Yoi+1-Yoi)/(Xoi+1-Xoi)+PI;/printf("alf=%ft",alfoi);/printf("so=%ft",soi);/求B矩陣/將第一個角度的系數(shù)單獨(dú)算出j=

12、0;/B0j=0.0;(Yo14-Yo0)/(so14*so14)*p/1000.0;/B0j+1=0.0;-1*(Xo14-Xo0)/(so14*so14)*p/1000.0;B0j=-1*(Yo1-Yo0)/(so0*so0)*p/1000.0;/B0j+1=(Xo1-Xo0)/(so0*so0)*p/1000.0;B026=(Yo14-Yo0)/(so14*so14)*p/1000.0;B027=-1*(Xo14-Xo0)/(so14*so14)*p/1000.0;/將第二個角度的系數(shù)單獨(dú)算出B1j=(Yo2-Yo1)/(so1*so1)-(Yo0-Yo1)/(so0*so0)*p/10

13、00.0;/B1j+1=-1*(Xo2-Xo1)/(so1*so1)-(Xo0-Xo1)/(so0*so0)*p/1000.0;B1j+2=-1*(Yo2-Yo1)/(so1*so1)*p/1000.0;B1j+3=(Xo2-Xo1)/(so1*so1)*p/1000.0;/求其他角度改正的系數(shù) for(i=2;i<15;i+)if(i<14)Bij=(Yoi-1-Yoi)/(soi-1*soi-1)*p/1000.0;Bij+1=-1*(Xoi-1-Xoi)/(soi-1*soi-1)*p/1000.0;Bij+2=(Yoi+1-Yoi)/(soi*soi)-(Yoi-1-Yoi

14、)/(soi-1*soi-1)*p/1000.0;Bij+3=-1*(Xoi+1-Xoi)/(soi*soi)-(Xoi-1-Xoi)/(soi-1*soi-1)*p/1000.0;Bij+4=-1*(Yoi+1-Yoi)/(soi*soi)*p/1000.0;Bij+5=(Xoi+1-Xoi)/(soi*soi)*p/1000.0;elseBij=(Yoi-1-Yoi)/(soi-1*soi-1)*p/1000.0;Bij+1=-1*(Xoi-1-Xoi)/(soi-1*soi-1)*p/1000.0;Bij+2=(Yoi+1-Yoi)/(soi*soi)-(Yoi-1-Yoi)/(soi-

15、1*soi-1)*p/1000.0;Bij+3=-1*(Xoi+1-Xoi)/(soi*soi)-(Xoi-1-Xoi)/(soi-1*soi-1)*p/1000.0;j=j+2;B21=0.0;/求邊長改正的系數(shù) j=0;/將第一個邊長的系數(shù)單獨(dú)算出Bij=(Xo1-Xo0)/so0; /Bij+1=(Yo1-Yo0)/so0; /(Yo1-Yo0)/(so0*so0);i=i+1; for(i;i<30;i+)if(i<29)Bij=-1*(Xoi-14-Xoi-15)/soi-15;Bij+1=-1*(Yoi-14-Yoi-15)/soi-15;Bij+2=-1*Bij;Bi

16、j+3=-1*Bij+1; elseBij=-1*(Xoi-14-Xoi-15)/soi-15;Bij+1=-1*(Yoi-14-Yoi-15)/soi-15; j=j+2; B161=0.0;for(j=1;j<27;j+)for(i=0;i<30;i+)Bij=Bij+1;/求L矩陣 L00=(beta0-(alfo0-alfo14+PI)*p;for(i=1;i<30;i+)if(i<15)Li0=(betai-(alfoi-alfoi-1+PI)*p;if(Li0>PI*p)Li0=(Li0-2*PI*p); Li0=Li0; elseLi0=(si-15

17、-soi-15)*1000.0; /求權(quán)陣P for(i=0;i<30;i+)if(i<15)Pii=1;elsesigma_s=5+10*0.*si-15*1000; /單位為(''/mm)的平方 Pii=sigma_beta*sigma_beta/(sigma_s*sigma_s); double Tb5050,Tc5050,MatrixResult5050,TV5050;double temp1MAXMAX,temp2MAXMAX,temp3MAXMAX,temp4MAXMAX,temp5MAXMAX; /計(jì)算Nbb矩陣,W矩陣 m1=30;m2=28; Ma

18、trixT(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導(dǎo)線網(wǎng)輸出數(shù)據(jù)3027.txt文本 FILE *fp;fp=fopen("D:111導(dǎo)線網(wǎng)輸出數(shù)據(jù)3027.txt","w");if(fp!=NULL)fprintf(fp,"距離近似值

19、so(單位:m):t");fprintf(fp,"方位角近似值alfo(單位:弧度):n");for(i=0;i<15;i+) fprintf(fp,"%4.12lft",soi);fprintf(fp,"%.12lfn",alfoi);fprintf(fp,"Xo(單位:mm):t");fprintf(fp,"Yo(單位:mm):");fprintf(fp,"n");for(i=0;i<15;i+) fprintf(fp,"%.6lft&qu

20、ot;,Xoi); fprintf(fp,"%.6lf",Yoi);fprintf(fp,"n");fprintf(fp,"B矩陣:");fprintf(fp,"n");for(i=0;i<30;i+)for(j=0;j<27;j+)fprintf(fp,"%.6f ",Bij);fprintf(fp,"n");fprintf(fp,"L矩陣(單位:秒和mm):");fprintf(fp,"n");for(i=0;i<

21、30;i+) fprintf(fp,"%.6lf ",Li0);fprintf(fp,"n");fprintf(fp,"P矩陣:");fprintf(fp,"n");for(i=0;i<30;i+)for(j=0;j<30;j+)fprintf(fp,"%.6f ",Pij);fprintf(fp,"n");fprintf(fp,"Nbb矩陣:");fprintf(fp,"n");for(i=0;i<27;i+)for

22、(j=0;j<27;j+)fprintf(fp,"%.12f ",Nbbij);fprintf(fp,"n");fclose(fp); /寫入完畢,關(guān)閉文件 DinV(Nbb,27); /MatrixResult=c * Nbb的逆 ,此時 Nbb已經(jīng)變成Nbb的逆 /計(jì)算xm1=27;m2=27;m3=1; MatrixMutiply(Nbb,W,xgu,m1,m2,m3);double xgu285050,sigma_xy285050;xgu2800=xgu00; for(i=1;i<27;i+) xgu28i+10=xgui0; xgu

23、2810=0.0; /計(jì)算X(即Xgu估值) Xgu00=5000.0; Ygu00=5000.0; for(i=0;i<14;i+) Xgui+10=Xoi+1+xgu282*i0/1000.0; Ygui+10=Yoi+1+xgu282*i+10/1000.0; /精度評定 m1=30;m2=27;m3=1; MatrixMutiply(B,xgu,temp5,m1,m2,m3);for(i=0;i<30;i+)if(i<15)Vi0=(temp5i0-Li0);elseVi0=(temp5i0-Li0); m1=30;m2=1;MatrixT(V,TV,m1,m2);m

24、1=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(temp400/3); /單位權(quán)中誤差 double vv=0.0; for (i=0;i<15;i+) for (j=0;j<1;j+) vv=vv+Vij; /puts(""); printf("%lft",vv); for(i=0;i<27;i+) for(j=0;j<27;j+) Qij

25、=Nbbij; for(i=0;i<27;i+) sigma_xyi0=sqrt(Qii)*sigma_gu; /坐標(biāo)平差值中誤差 /printf("%lfn",sigma_xyi0); sigma_xy2800=sigma_xy00; for(i=1;i<27;i+) sigma_xy28i+10=sigma_xyi0; sigma_xy2810=0.0; /printf("%.10lfn",Ncc00); FILE *fp1;fp1=fopen("D:111導(dǎo)線網(wǎng)輸出數(shù)據(jù)3027.txt","a")

26、;fprintf(fp1,"Nbb的逆:");fprintf(fp1,"n");for(i=0;i<27;i+)for(j=0;j<27;j+) fprintf(fp1,"%lf ",Nbbij);fprintf(fp1,"n");fprintf(fp1,"W:");fprintf(fp1,"n");for(i=0;i<27;i+)for(j=0;j<1;j+) fprintf(fp1,"%.12lf ",Wij);fprintf(

27、fp1,"n");fprintf(fp1,"x(單位:mm):");fprintf(fp1,"n");for(i=0;i<28;i+)for(j=0;j<1;j+) fprintf(fp1,"%.10lf ",xgu28ij);fprintf(fp1,"n");fprintf(fp1,"V(單位:秒和mm):");fprintf(fp1,"n");for(i=0;i<30;i+)for(j=0;j<1;j+) fprintf(fp1

28、,"%.10lf ",Vij);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,"%.6lft",Xguij); fprintf(fp1,"%.6lf",Yguij);fprintf(fp1,"n");fprintf(fp

29、1,"單位權(quán)中誤差(單位:mm):n");fprintf(fp1,"%.10lfn",sigma_gu);fprintf(fp1,"X坐標(biāo)平差值中誤差(單位:mm):t");fprintf(fp1,"Y坐標(biāo)平差值中誤差(單位:mm):");fprintf(fp1,"n");for(i=0;i<13;i+) fprintf(fp1,"%lftt",sigma_xy282*i0); fprintf(fp1,"%lf",sigma_xy282*i+10);

30、fprintf(fp1,"n");C語言畫圖程序/導(dǎo)線網(wǎng)概略圖 #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

31、= "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_APPLI

32、CATION) ;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 (szApp

33、Name, "控制網(wǎng)圖",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 ;LRE

34、SULT 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) ; double y

35、16=500.0,363.2211,250.8730,245.2811,343.9816,399.8183,506.0272,596.9804,690.1846,686.1801,688.9648,550.4837,552.8629,499.4146,497.8342,500.0;double x16=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

36、+)pti.x = xi;pti.y = yi;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 System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;usi

37、ng System.Text;using System.Threading.Tasks;using System.Windows.Forms;using System.IO;using System.Collections.Generic;namespace 導(dǎo)線控制網(wǎng) public partial class Form1 : Form public Form1() InitializeComponent(); public string jisuanjieguo; public const double p = 180*3600/Math.PI; /定義角度轉(zhuǎn)弧度的函數(shù) public dou

38、ble jiao_hu(double du,double fen,double miao) return (du*3600.0+fen*60.0+miao)/p; /定義矩陣運(yùn)算的類(包括矩陣的加、減、乘、轉(zhuǎn)置和求逆) 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

39、.GetLength(1); double, temp = new doublem, n; double, tem = 0; if (m = s && n = t) for (int i = 0; i < m; i+) for (int j = 0; j < n; j+) tempi, j = Arryi, j + Arry1i, j; return temp; else Console.WriteLine("兩個矩陣大小不同"); return tem ; /矩陣相減 public static double, matrix_jian(doub

40、le, 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 doublem, n; double, tem = 0 ; if (m = s && n = t) for (int i = 0; i < m; i+) for (int j = 0; j < n; j+) tempi, j = Arryi, j - Arry1i

41、, j; return temp; else Console.WriteLine("兩個矩陣大小不同"); return tem; /矩陣轉(zhuǎn)置 public static double, matrix_t(double, Arry) int m = Arry.GetLength(0); int n = Arry.GetLength(1); double, temp = new doublen, m; for (int i = 0; i < n; i+) for (int j = 0; j < m; j+) tempi,j = Arryj,i; return te

42、mp; /矩陣相乘 public static double, matrix_cheng(double, Arry, double, Arry1) int m = Arry.GetLength(0);/矩陣Arry的行數(shù) int r = Arry.GetLength(1);/矩陣Arry的列數(shù) int k = Arry1.GetLength(0);/矩陣Arry的行數(shù) int n = Arry1.GetLength(1);/矩陣Arry1的列數(shù) double, temp = new doublem, n; double, tem = 0 ; if (r = k) for (int i = 0;

43、 i < m; i+) for (int j = 0; j < n; j+) for (int t = 0; t < r; t+) tempi, j += Arryi, t * Arry1t, j; return temp; else Console.WriteLine("兩個矩陣無法相乘"); return tem; /求矩陣Arry的逆矩陣 public static double, matrix_ni(double, Arryni) int Level = Arryni.GetLength(1); double, NArry = new doubleLevel, Level; double HLS = matrix_yusuan.matrix_hls(Arryni); doubl

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論