




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、单像空间后方交会程序报告指导老师:刘老师班 级:测绘 101姓 名:尚锋学 号: 19 号1、应用程序的主入口部分的代码:using System;using System.Collections.Generic;using System.Linq;using System.Windows.Forms;namespace 单像空间后方交会static class Program/ / 应用程序的主入口点。/ STAThreadstatic void Main()Application .EnableVisualStyles();Application .SetCompatibleTextRen
2、deringDefault( false );Application .Run( new Form1();2、方法解算类(通用)部分的代码:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace 单像空间后方交会class Tongyongstruct image_point / 一个像点结构,包含像点坐标和地面点坐标 public double x;public double y;public double X;public double Y;privatedoub
3、le f;/ 主距privatedouble u;/u 为外方位元素,下面 5个相同privatedouble w;privatedouble k;privatedouble Xs;privatedouble Ys;privatedouble Zs;privateimage_point p =new image_point 4;/ 四个控制点privatedouble R= new double 9; / 旋转矩阵privatedouble a =new double 8;/ 像点坐标近似值privatedouble , A= newdouble 8, 6;/ 误差方程式系数privatedo
4、uble L =new double 8; / 误差方程式常数项privateint count =0; /统计代次数publicmTongyong( double g,double q) / 构造函数,初始化各变= g;for( int i = 0; i 4; i+)int j = i * 5;pi.x =qj;pi.y =qj + 1;pi.X =qj + 2;pi.Y =qj + 3;pi.Z =qj + 4;double ave = 0, sum = 0;/ 求比例尺分母for( int i = 0; i 3; i+)public double Z;for ( int j = i +
5、1; j 4; j+)量, 单位sum +=Math.Sqrt( Math.Pow(pi.X - pj.X, 2) +Math.Sqrt( Math.Pow(pi.x - pj.x, 2)Math.Pow(pi.Y - pj.Y, 2) / + Math.Pow(pi.y - pj.y, 2); ave = sum / 6; u = 0;/ 给定外方位元素的初始值 , 角度均设置为 0w = 0;k = 0;/Xs 为四个控Xs = (p0.X + p1.X + p2.X + p3.X) / 4; 制点X的平均值,Ys类似Ys = (p0.Y + p1.Y + p2.Y + p3.Y) / 4
6、;Zs = (p0.Z + p1.Z + p2.Z + p3.Z) / 4 + ave * f;private double sin( double m) / 正弦,为简化而写 , 下同return Math.Sin(m); private double cos( double m)return Math.Cos(m); private void calcos() / 计算旋转矩阵R0 = cos(u) * cos(k) - sin(u) * sin(w) * sin(k);R1 = -cos(u) * sin(k) - sin(u) * sin(w) * cos(k);R2 = -sin(u
7、) * cos(w);R3 = cos(w) * sin(k);R4 = cos(w) * cos(k);R5 = -sin(w);R6 = sin(u) * cos(k) + cos(u) * sin(w) * sin(k);R7 = cos(u) * sin(w) * cos(k) - sin(u) * sin(k);R8 = cos(u) * cos(w);private void calabout() / 像点坐标的近似值int i;for (i = 0; i 4; i+) a2 * i = -f * (R0 * (pi.X - Xs) + R3 * (pi.Y- Ys) + R6 *
8、 (pi.Z - Zs) / (R2 * (pi.X - Xs) + R5 * (pi.Y- Ys) + R8 * (pi.Z - Zs);a2 * i + 1 = -f * (R1 * (pi.X - Xs) + R4 * (pi.Y - Ys) + R7 * (pi.Z - Zs) / (R2 * (pi.X - Xs) + R5 * (pi.Y- Ys) + R8 * (pi.Z - Zs);private void calxx() / 误差方程式的系数和常数项int i;for (i = 0; i 4; i+)/ 系数double z = R2 * (pi.X - Xs) + R5 *
9、 (pi.Y - Ys)+ R8 * (pi.Z - Zs); int n = i * 2;An, 0 = (R0 * f + R2 * pi.x) / z;An, 1 = (R3 * f + R5 * pi.x) / z;An, 2 = (R6 * f + R8 * pi.x) / z;An, 3 = pi.y * sin(w) - f * cos(w) * cos(k) - pi.x / f * (pi.x * cos(w) * cos(k) - pi.y * cos(w) * sin(k);An, 4 = -f * sin(k) - pi.x / f * (pi.x * sin(k) +
10、 pi.y * cos(k);An, 5 = pi.y;An + 1, 0 = (R1 * f + R2 * pi.y) / z;An + 1, 1 = (R4 * f + R5 * pi.y) / z;An + 1, 2 = (R7 * f + R8 * pi.y) / z;An + 1, 3 = -pi.x * sin(w) + f * cos(w) * sin(k) -pi.x / f * (pi.x * cos(w) * cos(k) - pi.y * sin(k) * cos(w);An + 1, 4 = -f * cos(k) - pi.y / f * (pi.x * sin(k)
11、 + pi.y * cos(k);An + 1, 5 = -pi.x;for (i = 0; i 4; i+) / 常数项L2 * i = pi.x - a2 * i;L2 * i + 1 = pi.y - a2 * i + 1;private double calAdd()double , temp =new double 6, 6;A 的转置与 A相乘的积double , ANew =new double 6, 8;/A 的转置double t =new double 6;/A 的转置与 L相乘的积double X =new double6;/ 改正数int i, j, n;for (i
12、= 0; i 8; i+)/ 求A的转置 ANewfor (j = 0; j 6; j+)ANewj, i = Ai, j;for (i = 0; i 6; i+)/求A的转置与A相乘的积tempfor (j = 0; j 6; j+)tempi, j = 0;for (n = 0; n 8; n+)tempi, j += ANewi, n * An, j;MATINV(temp); /temp 的逆,保存在本身矩阵中 for (i = 0; i 6; i+)/求A的转置与L的乘积tti = 0; for (j = 0; j 8; j+) ti += ANewi, j * Lj;for (i
13、= 0; i 6; i+)/ 求改正数 XXi = 0;for (j = 0; j 0.00001)/ 迭代至最大改正数 =0.00001为止calcos(); calabout();calxx();VALUE = calAdd();count+;private void MATINV(double , c)/ 求6阶矩阵的逆int i, j, h, m;const int n = 6; double l;double , q = new double n, 12;for (i = 0; i n; i+) / 构造高斯矩阵for (j = 0; j n; j+) qi, j = ci, j;f
14、or (i = 0; i n; i+) / 单位矩阵for (j = n; j 12; j+)if (i + 6 = j)qi, j = 1; else qi, j = 0;for (h = 0, m = 0; m n - 1; m+, h+)/ 消去对角线以下的数据for (i = m + 1; i n; i+)if (qi, h = 0d) continue ;l = qm, h / qi, h;for (j = 0; j 0; m-, h-)/ 消去对角线以上的数据for (i = m - 1; i = 0; i-)if (qi, h = 0d) continue ;l = qm, h
15、/ qi, h;for (j = 0; j 12; j+)qi, j *= l;qi, j -= qm, j;for (i = 0; i n; i+)/ 将对角线上数据化为 1l = 1.0 / qi, i;for (j = 0; j 12; j+)qi, j *= l;for (i = 0; i n; i+)/ 提取逆矩阵for (j = 0; j n; j+)ci, j = qi, j + 6;private double maxone(double Arr)/ 返回六个元素中的最大值double ARR = new double 6;for ( int i = 0; i 6; i+)AR
16、Ri = Arri;if (ARRi 0d) / 取正ARRi = -ARRi;Array .Sort(ARR, 0, 6);return ARR5;public int COUNTgetreturn count;public double Ugetu;returnpublicdoubleWgetreturnw;publicdoubleKgetreturnk;publicdoubleXSgetreturnXs;publicdoubleYSgetreturnYs;publicdoubleZSgetreturnZs;3、窗体一部分的代码:using System;using System.Coll
17、ections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Diagnostics;using System.Data.OleDb;using System.IO;namespace 单像空间后方交会public partial class Form1: Formprivate double data = new double 20; /
18、保存表中的数据 private double f = 0; / 主距 public Form1()InitializeComponent();private void Form1_Load( object sender, EventArgs e)/ TODO: 这行代码将数据加载到表“ database1DataSet1.data 中。您可以根据需要移动或移除它。this .dataTableAdapter.Fill( this .database1DataSet1.data); copyFile(); / 复制数据文件tryf = 153.24 / 1000;/ 主距为固定值for ( in
19、t i = 0; i 4; i+)int j = 5 * i;dataj =double .Parse( this .DGV.Rowsi.Cells1.Value.ToString() / 1000; dataj + 1 =double .Parse( this .DGV.Rowsi.Cells2.Value.ToString() / 1000; dataj + 2 =double .Parse( this .DGV.Rowsi.Cells3.Value.ToString();dataj + 3 =double .Parse( this .DGV.Rowsi.Cells4.Value.ToSt
20、ring();dataj + 4 =double .Parse( this .DGV.Rowsi.Cells5.Value.ToString(); catch ( Exception o) / 载入数据出错,程序将无法开始计算 MessageBox.Show(o.Message, 提示 ,MessageBoxButtons.OK, MessageBoxIcon.Information);btnStart.Enabled = false ; this .label2.Text = ;this .textBox1.Text = C:Documents and桌面 RESULT.txt ; / 默认
21、结果保存在桌面this .label2.Text = 准备就绪 ; btnCheck.Enabled = false ; / 查看解算结果不可用 private void btnExit_Click( object sender, EventArgs e)Application .Exit();private void btnFilePath_Click( object sender, EventArgs e) folderBrowserDialog1.ShowNewFolderButton = true ;if (folderBrowserDialog1.ShowDialog() = Dia
22、logResult .OK) string s = folderBrowserDialog1.SelectedPath + + RESULT.txt ;if (s.Contains( ) = true ) / 解决根目录下出现如同 C:RESULT.txt 等不正确路径情况 s = s.Replace( , ); this .textBox1.Text = s;private void btnStart_Click( object sender, EventArgs e) btnCheck.Enabled = false ; / 解算过程中不响应按键btnExit.Enabled = fals
23、e ;false ;程序解算中,请稍等btnStart.Enabled =this .label2.Text = tryTongyong s = new Tongyong(f, data); / 新建实例解算 ,传入数据s.makeSure(); / 迭代解算this .label2.Text = 解算完成 , 迭代次数 : + s.COUNT.ToString(); / 显示状态StreamWriter/ 保存结果文件sw = newStreamWriter (this .textBox1.Text);sw.WriteLine(stringsw.WriteLine(stringsw.Writ
24、eLine(stringsw.WriteLine(stringsw.WriteLine(stringsw.WriteLine(stringsw.Close();.Format( u=0:F9 , s.U);.Format( w=0:F10 , s.W);.Format( k=0:F9 , s.K);.Format( Xs=0:F5 , s.XS);.Format( Ys=0:F5 , s.YS);try / 若成功则解算完成后自动打开结果文档Process p = new Process ();p.StartInfo.FileName =this .textBox1.Text;.Format( Zs=0:F6 , s.ZS);p.Start(); catch ( Exception o)MessageBox.Show(o.Message, 提示,MessageBoxButtons.OK, MessageBoxIcon.Information);catch / 解算失败,报错MessageBox.Show( 解算失败 ! , 提示 btnCheck.Enabled = btnExit.Enabled = btnStart.Enabled =MessageBoxButtons
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025版光伏发电项目钢筋工劳务分包合同规范范本
- 二零二五年度智能家居系统集成装修合同
- 2025版餐饮品牌加盟股份合作合同
- 二零二五年度鲜活农产品运输合同模板
- 二零二五年度冷链物流配送合同模板(肉类产品)
- 二零二五年度文化活动组织与执行合同范本
- 二零二五年度家政服务合同全面服务协议
- 二零二五房地产行业专利保密协议书
- 二零二五年度国际贸易投资实务拟合同
- 2025版智能物流技术合作开发协议书
- 2025年幼儿园指南与评估指南测试题及答案
- 2025年健康杯爱国卫生知识竞赛试题及答案
- 膀胱多处恶性肿瘤的个案护理
- 2025年贵州贵阳市水务环境集团有限公司招聘27人笔试参考题库附带答案详解(10套)
- 2025届中国南方航空“明珠优才管培生”全球招聘30人笔试参考题库附带答案详解(10套)
- 原发性系统性淀粉样变性的护理措施课件
- 2025新疆吐鲁番市法检系统面向社会招聘聘用制书记员23人考前自测高频考点模拟试题参考答案详解
- 《阿房宫赋》课件 统编版高中语文必修下册
- 2025年纪律作风测试题及答案
- 新《治安管理处罚法》培训考试题库附答案
- 银行联网核查管理办法
评论
0/150
提交评论