资源描述:
《vb坐标转换程序设计》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、OptionExplicitDimk2#,e2#,dX2#,dY2#Dimx2#,Xx2#,y2#,Yy2#Dimk3#,Ex#,Ey#,Ez#,dX3#,dY3#,dZ3#DimX3#,Y3#,Z3#,Xx3#,Yy3#,Zz3#ConstPI=3.14159265358979PrivateSubCheck1_Click()IfCheck1.Value=1ThenfrmCoorTrans.Height=5175ElseIfCheck1.Value=0ThenfrmCoorTrans.Height=4440EndIfEndSubPrivateSubcmdBrowFile_Click()CDg
2、1.Filter="控制点文件(*.gcp)
3、*.gcp
4、所有文件(*.*)
5、*.*"CDg1.Action=1txtFileName.Text=CDg1.FileNameEndSubPrivateSubcmdCalc_Click()DimsAsString,iPos%,i%,iCent!Dimn%,x1#(),y1#(),x2#(),y2#()DimA()AsDouble,L()AsDouble,x(1To4)AsDoubleDimAt#(),Naa#(),W#()OpentxtFileName.TextForInputAs#1LineInput#1,sn=Val(s)ReDimx1#(n
6、),y1#(n),x2#(n),y2#(n)Fori=1TonLineInput#1,siPos=InStr(s,",")x1(i)=Val(Left(s,iPos-1))s=Mid(s,iPos+1)iPos=InStr(s,",")y1(i)=Val(Left(s,iPos-1))s=Mid(s,iPos+1)iPos=InStr(s,",")x2(i)=Val(Left(s,iPos-1))s=Mid(s,iPos+1)y2(i)=Val(s)NextiClose#1'计算转换参数ReDimA(1To2*n,1To4)AsDouble,L(1To2*n)AsDoubleReDimAt(
7、1To4,1To2*n),Naa(1To4,1To4),W(1To4)Debug.Print"系数矩阵A:"Fori=1TonA(2*i-1,1)=1:A(2*i-1,2)=0:A(2*i-1,3)=x1(i):A(2*i-1,4)=y1(i)Debug.PrintA(2*i-1,1),A(2*i-1,2),A(2*i-1,3),A(2*i-1,4)A(2*i,1)=0:A(2*i,2)=1:A(2*i,3)=y1(i):A(2*i,4)=-x1(i)Debug.PrintA(2*i,1),A(2*i,2),A(2*i,3),A(2*i,4)L(2*i-1)=x2(i):L(2*i)=y2(
8、i)NextiDebug.Print"常数向量L:"Fori=1To2*nDebug.PrintL(i)NextiMatrixTransA,AtDebug.Print"A的转置矩阵:"ShowMatrixAtMatrix_MultyNaa,At,ADebug.Print"Naa:"ShowMatrixNaaMatrix_MultyW,At,LDebug.Print"W:"Fori=1To4Debug.PrintW(i)NextiMajorInColGuassNaa,W,xDebug.Print"X"Fori=1To4Debug.Printx(i)Nexti'分离旋转和尺度参数IfAbs(x(
9、3))<0.00000001ThenIfx(4)>0Thene2=PI/2Elsee2=PI*3/2EndIfElsee2=Atn(x(4)/x(3))'得到的是弧度Ifx(3)<0Andx(4)>0Thene2=PI-e2ElseIfx(3)<0Andx(4)<0Thene2=PI+e2ElseIfx(3)>0Andx(4)<0Thene2=PI*2+e2EndIfEndIfk2=x(3)/Cos(e2)'将转换参数写入相应文本框txtK2=Str(k2-1)e2=e2*180/PIDimdu%,fen%du=Int(e2):e2=(e2-du)*60fen=Int(e2):e2=(e2-
10、fen)*60e2=Val(Format(e2,"0.00"))e2=du+fen/100#+e2/10000txtE2=Str(e2)txtdX2.Text=Str(x(1))txtdY2.Text=Str(x(2))EndSubPrivateSubcmdCalc2_Click()k2=Val(txtK2.Text)e2=Val(txtE2.Text)e2=DoToHu(e2)dX2=Val(txtdX2.