📄 plane.cpp
字号:
#include "string.h"
#include "iostream.h"
#include "stdio.h"
#include "matrix.h"
#include "io_matrix.h"
matrix setb(matrix e,int n,double x0,double y0)
{ matrix b(n,3);
int i=0;
for(i=0;i<n;i++)
{
double dx=e.getele(i,0)-x0,dy=e.getele(i,1)-y0;
b.setele(i,0,1.0);
b.setele(i,1,dx);
b.setele(i,2,dy);
}
return b;
}
matrix setl(matrix e,int n)
{ matrix l(n,1);
int i=0;
for(i=0;i<n;i++)
{
double w=e.getele(i,2)-e.getele(i,3);
cout<<"\n l["<<i<<"]="<<w;
l.setele(i,0,w);
}
return l;
}
matrix deal(matrix d,int n,matrix a, double x0,double y0)
{ matrix zh(n,6);
for(int i=0;i<n;i++)
{ double dx=d.getele(i,0)-x0,dy=d.getele(i,1)-y0,H=d.getele(i,2);
zh.setele(i,0,d.getele(i,0));
zh.setele(i,1,d.getele(i,1));
zh.setele(i,2,d.getele(i,2));
double value=a.getele(0,0)+a.getele(1,0)*dx
+a.getele(2,0)*dy;
zh.setele(i,3,H-value);
}
for(i=0;i<n;i++)
{zh.setele(i,4,d.getele(i,3));
zh.setele(i,5,zh.getele(i,3)-d.getele(i,3));
}
return zh;
}
void main()
{
int n=2;
char y='y';
//double x0=4592000,y0=770000,dx=0,dy=0,w=0;
double x0=0,y0=0,dx=0,dy=0,w=0,d0=0;
/* Next input your matrix,
for example:e=inputmatrix(m,n,"01.txt");
the style of 01.txt is a sery number on a line between blank*/
cout<<"\n★★★★★GPS大地高平面拟合水准高程(三参数)\n";
cout<<"\n please input the number of points which are known:\n n=";cin>>n;
matrix l(n,1),b(n,3),e(1),N(3),L(3,3),a(3,3),d(2,3),zh(10),v(n,1);
e=inputmatrix(n,4);
cout<<"\n 已知点信息如下(请核对)";
cout<<"\n x y 大地高 已知海拔高";
e.output();
for(int i=0;i<n;i++)//计算测区中央坐标
{x0+=e.getele(i,0)/n;
y0+=e.getele(i,1)/n;
}
cout<<"\n \n 测区中央坐标大约为:\n";
cout<<"x0="<<x0<<" y0="<<y0;
b=setb(e,n,x0,y0);
cout<<"\n \nmatrix l is(即各已知点处高程异常值): ";
l=setl(e,n); //系数阵
L=b.T()*l;N=b.T()*b; a=~N*L;//求取六参数
cout<<"\n 各参数如下:\n";
a.output();
v=b*a-l; //求得改正数向量
cout<<"\n matrix v is: ";v.output();
for(i=0;i<n;i++)
d0+=v.getele(i,0)*v.getele(i,0);d0=sqrt(d0/(n-1));//计算高程拟合的内符合精度
cout<<"\n \nplease input the number of points are to deal:\n n=";
cin>>n;
d=inputmatrix(n,4,"dnh.txt");
cout<<"\n following is the data to deal:(请核对) ";
cout<<"\n x y 大地高 已知海拔高";
d.output();
zh=deal(d,n,a,x0,y0);//进行高程拟合
cout<<"\n\n 拟合高程如下: \n x y 大地高 拟合高程 已知海拔高 拟合残差:";zh.output();
cout<<"\n 内符合精度d0= "<<d0<<"mm"<<endl;
for(i=0;i<n;i++)
d0+=zh.getele(i,5)*zh.getele(i,5);
d0=sqrt(d0/(n-1));//计算拟合点的外符合精度
cout<<" 外符合精度M= "<<d0<<"mm"<<endl;
cout<<"\n\nDo you want to input the result to the file(y/n)"<<endl;
cin>>y;
if(y=='y')
{
cout<<"★Your result have been saved as a file in output.txt!\n";
outputmatrix(zh);
}
else cout<<"\n Thank you to use this process!\n ";
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -