导线网平差程序源代码(共46页).docx

上传人:飞****2 文档编号:14339591 上传时间:2022-05-04 格式:DOCX 页数:46 大小:46.93KB
返回 下载 相关 举报
导线网平差程序源代码(共46页).docx_第1页
第1页 / 共46页
导线网平差程序源代码(共46页).docx_第2页
第2页 / 共46页
点击查看更多>>
资源描述

《导线网平差程序源代码(共46页).docx》由会员分享,可在线阅读,更多相关《导线网平差程序源代码(共46页).docx(46页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、精选优质文档-倾情为你奉上程序源代码C语言程序:#include #include #include #include #include#define PI 3.98#define p .#define MAX 50/矩阵的乘法运算 MatrixMutiply(double Matrix1MAXMAX,double Matrix2MAXMAX,double MatrixResultMAXMAX,int m1,int m2,int m3)int i,j,k;double Sum;for(i=0;im1;i+) for(j=0;jm3;j+) /*按照矩阵乘法的规则计算结果矩阵的i*j元素*/ S

2、um=0; for(k=0;km2;k+) Sum+=Matrix1ik*Matrix2kj; MatrixResultij=Sum; /return MatrixResult;/矩阵的转置运算 MatrixT(double Matrix1MAXMAX,double TMAXMAX,int m1,int m2) /m1,m2分别是矩阵的行列数 int i,j;/double T5050; for(i=0;im1;i+) for(j=0;jm2;j+) Tji=Matrix1ij; /return T;/矩阵的逆运算void swap(double a,double b)double c=a;a

3、=b;b=c;double DinV(double A5050,int n) /n代表阶数 int i,j,k; double d; int JS50,IS50; for (k=0;kn;k+) d=0; for (i=k;in;i+) for (j=k;jd) d=fabs(Aij); ISk=i; JSk=j; if (d+1.0=1.0) return 0; if (ISk!=k) for (j=0;jn;j+) swap(Akj,AISkj); if (JSk!=k) for (i=0;in;i+) swap(Aik,AiJSk); Akk=1/Akk; for (j=0;jn;j+)

4、 if (j!=k) Akj=Akj*Akk; for (i=0;in;i+) if (i!=k) for (j=0;jn;j+) if (j!=k) Aij=Aij-Aik*Akj; for (i=0;i=0;k-) for (j=0;jn;j+) if (JSk!=k) swap(Akj,AJSkj); for (i=0;i=i) break; Xo0=5000.0;Yo0=5000.0; Xo15=5000.0;Yo15=5000.0;so0=s0; /用来求未知点坐标近似值for(i=1;i=(2*PI)alfi=alfi-2*PI;Xoi=Xoi-1+si-1*cos(alfi-1)

5、;Yoi=Yoi-1+si-1*sin(alfi-1);/printf(X=%ft,Xoi);for(i=1;i0&(Xoi+1-Xoi)0)/第一象限 alfoi=atan(Yoi+1-Yoi)/(Xoi+1-Xoi);else if(Yoi+1-Yoi)0&(Xoi+1-Xoi)0)/第二象限 alfoi=atan(Yoi+1-Yoi)/(Xoi+1-Xoi)+PI;else if(Yoi+1-Yoi)0)/第三象限 alfoi=atan(Yoi+1-Yoi)/(Xoi+1-Xoi)+2*PI;else /(Yoi-Yoi-1)0&(Xoi-Xoi-1)0)/第四象限 alfoi=atan

6、(Yoi+1-Yoi)/(Xoi+1-Xoi)+PI;/printf(alf=%ft,alfoi);/printf(so=%ft,soi);/求B矩阵/将第一个角度的系数单独算出j=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*(Xo

7、14-Xo0)/(so14*so14)*p/1000.0;/将第二个角度的系数单独算出B1j=(Yo2-Yo1)/(so1*so1)-(Yo0-Yo1)/(so0*so0)*p/1000.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;/求其他角度改正的系数 for(i=2;i15;i+)if(i14)Bij=(Yoi-1-Yoi)/(soi-1*soi-1)*p/1000.0

8、;Bij+1=-1*(Xoi-1-Xoi)/(soi-1*soi-1)*p/1000.0;Bij+2=(Yoi+1-Yoi)/(soi*soi)-(Yoi-1-Yoi)/(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=

9、-1*(Xoi-1-Xoi)/(soi-1*soi-1)*p/1000.0;Bij+2=(Yoi+1-Yoi)/(soi*soi)-(Yoi-1-Yoi)/(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;j=j+2;B21=0.0;/求边长改正的系数 j=0;/将第一个边长的系数单独算出Bij=(Xo1-Xo0)/so0; /Bij+1=(Yo1-Yo0)/so0; /(Yo1-Yo0)/(so0*so0);i=i+1; for(i;i30;i+)if(i29)Bi

10、j=-1*(Xoi-14-Xoi-15)/soi-15;Bij+1=-1*(Yoi-14-Yoi-15)/soi-15;Bij+2=-1*Bij;Bij+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;j27;j+)for(i=0;i30;i+)Bij=Bij+1;/求L矩阵 L00=(beta0-(alfo0-alfo14+PI)*p;for(i=1;i30;i+)if(iPI*p)Li0=(Li0-2*PI*p); Li0=Li0;

11、elseLi0=(si-15-soi-15)*1000.0; /求权阵P for(i=0;i30;i+)if(i15)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; /计算Nbb矩阵,W矩阵 m1=30;m2=28; Matrix

12、T(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(

13、单位:弧度):n);for(i=0;i15;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;i15;i+) fprintf(fp,%.6lft,Xoi); fprintf(fp,%.6lf,Yoi);fprintf(fp,n);fprintf(fp,B矩阵:);fprintf(fp,n);for(i=0;i30;i+)for(j=0;j27;j+)fprintf(fp,%.6f ,Bij);fpr

14、intf(fp,n);fprintf(fp,L矩阵(单位:秒和mm):);fprintf(fp,n);for(i=0;i30;i+) fprintf(fp,%.6lf ,Li0);fprintf(fp,n);fprintf(fp,P矩阵:);fprintf(fp,n);for(i=0;i30;i+)for(j=0;j30;j+)fprintf(fp,%.6f ,Pij);fprintf(fp,n);fprintf(fp,Nbb矩阵:);fprintf(fp,n);for(i=0;i27;i+)for(j=0;j27;j+)fprintf(fp,%.12f ,Nbbij);fprintf(fp,

15、n);fclose(fp); /写入完毕,关闭文件 DinV(Nbb,27); /MatrixResult=c * Nbb的逆 ,此时 Nbb已经变成Nbb的逆 /计算xm1=27;m2=27;m3=1; MatrixMutiply(Nbb,W,xgu,m1,m2,m3);double xgu285050,sigma_xy285050;xgu2800=xgu00; for(i=1;i27;i+) xgu28i+10=xgui0; xgu2810=0.0; /计算X(即Xgu估值) Xgu00=5000.0; Ygu00=5000.0; for(i=0;i14;i+) Xgui+10=Xoi+1

16、+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;i30;i+)if(i15)Vi0=(temp5i0-Li0);elseVi0=(temp5i0-Li0); 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,te

17、mp4,m1,m2,m3);sigma_gu=sqrt(temp400/3); /单位权中误差 double vv=0.0; for (i=0;i15;i+) for (j=0;j1;j+) vv=vv+Vij; /puts(); printf(%lft,vv); for(i=0;i27;i+) for(j=0;j27;j+) Qij=Nbbij; for(i=0;i27;i+) sigma_xyi0=sqrt(Qii)*sigma_gu; /坐标平差值中误差 /printf(%lfn,sigma_xyi0); sigma_xy2800=sigma_xy00; for(i=1;i27;i+)

18、sigma_xy28i+10=sigma_xyi0; sigma_xy2810=0.0; /printf(%.10lfn,Ncc00); FILE *fp1;fp1=fopen(D:111导线网输出数据3027.txt,a);fprintf(fp1,Nbb的逆:);fprintf(fp1,n);for(i=0;i27;i+)for(j=0;j27;j+) fprintf(fp1,%lf ,Nbbij);fprintf(fp1,n);fprintf(fp1,W:);fprintf(fp1,n);for(i=0;i27;i+)for(j=0;j1;j+) fprintf(fp1,%.12lf ,W

19、ij);fprintf(fp1,n);fprintf(fp1,x(单位:mm):);fprintf(fp1,n);for(i=0;i28;i+)for(j=0;j1;j+) fprintf(fp1,%.10lf ,xgu28ij);fprintf(fp1,n);fprintf(fp1,V(单位:秒和mm):);fprintf(fp1,n);for(i=0;i30;i+)for(j=0;j1;j+) fprintf(fp1,%.10lf ,Vij);fprintf(fp1,n);fprintf(fp1,X(单位:m):t);fprintf(fp1,Y(单位:m):);fprintf(fp1,n)

20、;for(i=0;i15;i+)for(j=0;j1;j+) fprintf(fp1,%.6lft,Xguij); fprintf(fp1,%.6lf,Yguij);fprintf(fp1,n);fprintf(fp1,单位权中误差(单位:mm):n);fprintf(fp1,%.10lfn,sigma_gu);fprintf(fp1,X坐标平差值中误差(单位:mm):t);fprintf(fp1,Y坐标平差值中误差(单位:mm):);fprintf(fp1,n);for(i=0;i13;i+) fprintf(fp1,%lftt,sigma_xy282*i0); fprintf(fp1,%l

21、f,sigma_xy282*i+10);fprintf(fp1,n);C语言画图程序/导线网概略图 #include #include #include #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 ;WNDCLA

22、SSEX 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_

23、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_USEDE

24、FAULT,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)stat

25、ic 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 y16=500.0,363.2211,250.8730,245.2811,343.9816,399.8183,506.0272,596.9804,690.1846,6

26、86.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+)pti.x = xi;pti.y = yi;Polyline (hdc, pt, 16);return 0 ;case WM_DESTROY:PostQuitMessag

27、e (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;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using System.IO;

28、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; /定义矩阵

29、运算的类(包括矩阵的加、减、乘、转置和求逆) 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 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(double, Arry, double, Arry1) int m = Arry.GetLength(0); int n = Arry.GetLength(1);

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 教案示例

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁