完整word版单像空间后方交会程序报告.docx
- 文档编号:8092632
- 上传时间:2023-01-28
- 格式:DOCX
- 页数:18
- 大小:107.23KB
完整word版单像空间后方交会程序报告.docx
《完整word版单像空间后方交会程序报告.docx》由会员分享,可在线阅读,更多相关《完整word版单像空间后方交会程序报告.docx(18页珍藏版)》请在冰豆网上搜索。
完整word版单像空间后方交会程序报告
单像空间后方交会程序报告
指导老师:
刘老师
班级:
测绘101
姓名:
尚锋
学号:
19号
1、应用程序的主入口部分的代码:
usingSystem;
usingSystem。
Collections.Generic;
usingSystem.Linq;
usingSystem。
Windows。
Forms;
namespace单像空间后方交会
{
staticclassProgram
{
/// ///应用程序的主入口点。 ///
[STAThread]
staticvoidMain()
{
Application.EnableVisualStyles();
Application。
SetCompatibleTextRenderingDefault(false);
Application。
Run(newForm1());
}
}
}
2、方法解算类(通用)部分的代码:
usingSystem;
usingSystem.Collections。
Generic;
usingSystem.Linq;
usingSystem。
Text;
namespace单像空间后方交会
{
classTongyong
{
structimage_point//一个像点结构,包含像点坐标和地面点坐标
{
publicdoublex;
publicdoubley;
publicdoubleX;
publicdoubleY;
publicdoubleZ;
}
privatedoublef;//主距
privatedoubleu;//u为外方位元素,下面5个相同
privatedoublew;
privatedoublek;
privatedoubleXs;
privatedoubleYs;
privatedoubleZs;
privateimage_point[]p=newimage_point[4];//四个控制点
privatedouble[]R=newdouble[9];//旋转矩阵
privatedouble[]a=newdouble[8];//像点坐标近似值
privatedouble[,]A=newdouble[8,6];//误差方程式系数
privatedouble[]L=newdouble[8];//误差方程式常数项
privateintcount=0;//统计代次数
publicTongyong(doubleg,double[]q)//构造函数,初始化各变量,单位m
{
f=g;
for(inti=0;i〈4;i++)
{
intj=i*5;
p[i]。
x=q[j];
p[i].y=q[j+1];
p[i].X=q[j+2];
p[i].Y=q[j+3];
p[i]。
Z=q[j+4];
}
doubleave=0,sum=0;//求比例尺分母
for(inti=0;i<3;i++)
{
for(intj=i+1;j〈4;j++)
{
sum+=Math.Sqrt(Math。
Pow(p[i]。
X-p[j]。
X,2)+Math。
Pow(p[i]。
Y-p[j].Y,2))/Math。
Sqrt(Math。
Pow(p[i]。
x—p[j]。
x,2)+Math。
Pow(p[i]。
y-p[j].y,2));
}
}
ave=sum/6;
u=0;//给定外方位元素的初始值,角度均设置为0
w=0;
k=0;
Xs=(p[0]。
X+p[1].X+p[2]。
X+p[3].X)/4;//Xs为四个控制点X的平均值,Ys类似
Ys=(p[0]。
Y+p[1]。
Y+p[2].Y+p[3]。
Y)/4;
Zs=(p[0].Z+p[1].Z+p[2]。
Z+p[3].Z)/4+ave*f;
}
privatedoublesin(doublem)//正弦,为简化而写,下同
{
returnMath.Sin(m);
}
privatedoublecos(doublem)
{
returnMath。
Cos(m);
}
privatevoidcalcos()//计算旋转矩阵
{
R[0]=cos(u)*cos(k)—sin(u)*sin(w)*sin(k);
R[1]=-cos(u)*sin(k)—sin(u)*sin(w)*cos(k);
R[2]=-sin(u)*cos(w);
R[3]=cos(w)*sin(k);
R[4]=cos(w)*cos(k);
R[5]=-sin(w);
R[6]=sin(u)*cos(k)+cos(u)*sin(w)*sin(k);
R[7]=cos(u)*sin(w)*cos(k)—sin(u)*sin(k);
R[8]=cos(u)*cos(w);
}
privatevoidcalabout()//像点坐标的近似值
{
inti;
for(i=0;i<4;i++)
{
a[2*i]=—f*(R[0]*(p[i].X—Xs)+R[3]*(p[i]。
Y-Ys)+R[6]*(p[i]。
Z—Zs))/(R[2]*(p[i]。
X—Xs)+R[5]*(p[i].Y—Ys)+R[8]*(p[i]。
Z—Zs));
a[2*i+1]=—f*(R[1]*(p[i].X-Xs)+R[4]*(p[i]。
Y—Ys)+R[7]*(p[i]。
Z-Zs))/(R[2]*(p[i].X-Xs)+R[5]*(p[i]。
Y-Ys)+R[8]*(p[i]。
Z—Zs));
}
}
privatevoidcalxx()//误差方程式的系数和常数项
{
inti;
for(i=0;i〈4;i++)//系数
{
doublez=R[2]*(p[i].X-Xs)+R[5]*(p[i]。
Y—Ys)+R[8]*(p[i]。
Z-Zs);
intn=i*2;
A[n,0]=(R[0]*f+R[2]*p[i].x)/z;
A[n,1]=(R[3]*f+R[5]*p[i].x)/z;
A[n,2]=(R[6]*f+R[8]*p[i].x)/z;
A[n,3]=p[i]。
y*sin(w)—f*cos(w)*cos(k)—p[i]。
x/f*(p[i].x*cos(w)*cos(k)-p[i]。
y*cos(w)*sin(k));
A[n,4]=—f*sin(k)—p[i]。
x/f*(p[i].x*sin(k)+p[i].y*cos(k));
A[n,5]=p[i]。
y;
A[n+1,0]=(R[1]*f+R[2]*p[i].y)/z;
A[n+1,1]=(R[4]*f+R[5]*p[i].y)/z;
A[n+1,2]=(R[7]*f+R[8]*p[i].y)/z;
A[n+1,3]=—p[i].x*sin(w)+f*cos(w)*sin(k)-p[i].x/f*(p[i]。
x*cos(w)*cos(k)—p[i]。
y*sin(k)*cos(w));
A[n+1,4]=-f*cos(k)—p[i].y/f*(p[i].x*sin(k)+p[i].y*cos(k));
A[n+1,5]=-p[i].x;
}
for(i=0;i〈4;i++)//常数项
{
L[2*i]=p[i].x-a[2*i];
L[2*i+1]=p[i].y-a[2*i+1];
}
}
privatedoublecalAdd()
{
double[,]temp=newdouble[6,6];//A的转置与A相乘的积
double[,]ANew=newdouble[6,8];//A的转置
double[]t=newdouble[6];//A的转置与L相乘的积
double[]X=newdouble[6];//改正数
inti,j,n;
for(i=0;i<8;i++)//求A的转置ANew
{
for(j=0;j〈6;j++)
{
ANew[j,i]=A[i,j];
}
}
for(i=0;i〈6;i++)//求A的转置与A相乘的积temp
{
for(j=0;j〈6;j++)
{
temp[i,j]=0;
for(n=0;n<8;n++)
{
temp[i,j]+=ANew[i,n]*A[n,j];
}
}
}
MATINV(temp);//temp的逆,保存在本身矩阵中
for(i=0;i<6;i++)//求A的转置与L的乘积t
{
t[i]=0;
for(j=0;j〈8;j++)
{
t[i]+=ANew[i,j]*L[j];
}
}
for(i=0;i<6;i++)//求改正数X
{
X[i]=0;
for(j=0;j〈6;j++)
{
X[i]+=temp[i,j]*t[j];
}
}
Xs+=X[0];//外方位元素初始值加上改正数
Ys+=X[1];
Zs+=X[2];
u+=X[3];
w+=X[4];
k+=X[5];
returnmaxone(X);//返回判断条件,最大的改正数的值
}
publicvoidmakeSure()//计算流程控制函数
{
calcos();
calabout();
calxx();
doubleVALUE=calAdd();
count++;
while(VALUE〉0。
00001)//迭代至最大改正数〈=0。
00001为止
{
calcos();
calabout();
calxx();
VALUE=calAdd();
count++;
}
}
privatevoidMATINV(double[,]c)//求6阶矩阵的逆
{
inti,j,h,m;
constintn=6;
doublel;
double[,]q=newdouble[n,12];
for(i=0;i〈n;i++)//构造高斯矩阵
{
for(j=0;j { q[i,j]=c[i,j]; } } for(i=0;i〈n;i++)//单位矩阵 { for(j=n;j〈12;j++) { if(i+6==j) q[i,j]=1; else q[i,j]=0; } } for(h=0,m=0;m〈n—1;m++,h++)//消去对角线以下的数据 { for(i=m+1;i { if(q[i,h]==0d) continue; l=q[m,h]/q[i,h]; for(j=0;j〈12;j++) { q[i,j]*=l; q[i,j]-=q[m,j]; } } } for(h=n—1,m=n—1;m>0;m—-,h--)//消去对角线以上的数据 { for(i=m—1;i〉=0;i——) { if(q[i,h]==0d) continue; l=q[m,h]/q[i,h]; for(j=0;j〈12;j++) { q[i,j]*=l; q[i,j]—=q[m,j]; } } } for(i=0;i { l=1。 0/q[i,i]; for(j=0;j〈12;j++) { q[i,j]*=l; } } for(i=0;i〈n;i++)//提取逆矩阵 { for(j=0;j〈n;j++) { c[i,j]=q[i,j+6]; } } } privatedoublemaxone(double[]Arr)//返回六个元素中的最大值 { double[]ARR=newdouble[6]; for(inti=0;i<6;i++) { ARR[i]=Arr[i]; if(ARR[i]〈0d)//取正 ARR[i]=—ARR[i]; } Array.Sort(ARR,0,6); returnARR[5]; } publicintCOUNT { get { returncount; } } publicdoubleU { get { returnu; } } publicdoubleW { get { returnw; } } publicdoubleK { get { returnk; } } publicdoubleXS { get { returnXs; } } publicdoubleYS { get { returnYs; } } publicdoubleZS { get { returnZs; } } } 3、窗体一部分的代码: usingSystem; usingSystem.Collections.Generic; usingSystem。 ComponentModel; usingSystem.Data; usingSystem.Drawing; usingSystem。 Linq; usingSystem。 Text; usingSystem.Windows.Forms; usingSystem.Diagnostics; usingSystem.Data。 OleDb; usingSystem.IO; namespace单像空间后方交会 { publicpartialclassForm1: Form { privatedouble[]data=newdouble[20];//保存表中的数据 privatedoublef=0;//主距 publicForm1() { InitializeComponent(); } privatevoidForm1_Load(objectsender,EventArgse) { //TODO: 这行代码将数据加载到表“database1DataSet1。 data”中。 您可以根据需要移动或移除它. this.dataTableAdapter.Fill(this.database1DataSet1。 data); copyFile();//复制数据文件 try { f=153.24/1000;//主距为固定值 for(inti=0;i〈4;i++) { intj=5*i; data[j]=double。 Parse(this。 DGV。 Rows[i]。 Cells[1].Value.ToString())/1000; data[j+1]=double。 Parse(this。 DGV。 Rows[i]。 Cells[2].Value。 ToString())/1000; data[j+2]=double。 Parse(this.DGV。 Rows[i]。 Cells[3].Value.ToString()); data[j+3]=double。 Parse(this.DGV.Rows[i].Cells[4].Value。 ToString()); data[j+4]=double.Parse(this。 DGV.Rows[i].Cells[5]。 Value。 ToString()); } } catch(Exceptiono)//载入数据出错,程序将无法开始计算 { MessageBox。 Show(o。 Message,”提示”,MessageBoxButtons.OK,MessageBoxIcon。 Information); btnStart。 Enabled=false; } this。 label2.Text=""; this。 textBox1.Text=@”C: \DocumentsandSettings\Administrator\桌面\RESULT.txt”;//默认结果保存在桌面 this。 label2。 Text="准备就绪"; btnCheck。 Enabled=false;//查看解算结果不可用 } privatevoidbtnExit_Click(objectsender,EventArgse) { Application。 Exit(); } privatevoidbtnFilePath_Click(objectsender,EventArgse) { folderBrowserDialog1.ShowNewFolderButton=true; if(folderBrowserDialog1。 ShowDialog()==DialogResult.OK) { strings=folderBrowserDialog1。 SelectedPath+"\\"+”RESULT.txt”; if(s.Contains(@”\\”)==true)//解决根目录下出现如同C: \\RESULT.txt等不正确路径情况 { s=s。 Replace(@”\\",@”\"); } this。 textBox1。 Text=s; } } privatevoidbtnStart_Click(objectsender,EventArgse) { btnCheck。 Enabled=false;//解算过程中不响应按键 btnExit.Enabled=false; btnStart.Enabled=false; this.label2。 Text=”程序解算中,请稍等..。 。 。 .”; try { Tongyongs=newTongyong(f,data);//新建实例解算,传入数据 s.makeSure();//迭代解算 this.label2。 Text=”解算完成,迭代次数: "+s。 COUNT.ToString();//显示状态 StreamWritersw=newStreamWriter(this.textBox1。 Text);//保存结果文件 sw。 WriteLine(string.Format("u={0: F9}",s。 U)); sw.WriteLine(string。 Format(”w={0: F10}",s.W)); sw.WriteLine(string.Format("k={0: F9}",s。 K)); sw。 WriteLine(string。 Format(”Xs={0: F5}",s。 XS)); sw。 WriteLine(string。 Format(”Ys={0: F5}",s.YS)); sw.WriteLine(string.Format(”Zs={0: F6}",s。 ZS)); sw。 Close(); try//若成功则解算完成后自动打开结果文档 { Processp=newProcess(); p.StartInfo。 FileName=this。 textBox1。 Text; p.Start(); } catch(Exceptiono) { MessageBox。 Show(o.Message,"提示”,MessageBoxButtons。 OK,MessageBoxIcon.Information); } } catch//解算失败,报错 { MessageBox。 Show(”解算失败! ”,"提示”,MessageBoxButtons.OK,MessageBoxIcon。 Information); this。 label2。 Text=”解算失败”; } btnCheck。 Enabled=true;//解算结束后响应按键 btnExit.Enabled=true; btnStart.Enabled=true; } privatevoidbtnCheck_Click(objectsender,EventArgse) { try
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 完整 word 版单像 空间 后方 交会 程序 报告
![提示](https://static.bdocx.com/images/bang_tan.gif)