VB坐標(biāo)轉(zhuǎn)換程序設(shè)計(jì)_第1頁(yè)
VB坐標(biāo)轉(zhuǎn)換程序設(shè)計(jì)_第2頁(yè)
VB坐標(biāo)轉(zhuǎn)換程序設(shè)計(jì)_第3頁(yè)
VB坐標(biāo)轉(zhuǎn)換程序設(shè)計(jì)_第4頁(yè)
VB坐標(biāo)轉(zhuǎn)換程序設(shè)計(jì)_第5頁(yè)
已閱讀5頁(yè),還剩15頁(yè)未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、option explicitdim k2#, e2#, dx2#, dy2# dim x2#, xx2#, y2#, yy2# dim k3#, ex#, ey#, ez#, dx3#, dy3#, dz3# dim x3#, y3#, z3#, xx3#, yy3#, zz3# const pi = 3.14159265358979private sub check1_click() if check1.value = 1 then frmcoortrans.height = 5175 elseif check1.value = 0 then frmcoortrans.height = 4

2、440 end ifend subprivate sub cmdbrowfile_click() cdg1.filter = 控制點(diǎn)文件 (*.gcp)|*.gcp|所有文件 (*.*)|*.* cdg1.action = 1 txtfilename.text = cdg1.filenameend subprivate sub cmdcalc_click() dim s as string, ipos%, i%, icent! dim n%, x1#(), y1#(), x2#(), y2#() dim a() as double, l() as double, x(1 to 4) as do

3、uble dim at#(), naa#(), w#() open txtfilename.text for input as #1 line input #1, s n = val(s) redim x1#(n), y1#(n), x2#(n), y2#(n) for i = 1 to n line input #1, s ipos = 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 +

4、 1) ipos = instr(s, ,) x2(i) = val(left(s, ipos - 1) s = mid(s, ipos + 1) y2(i) = val(s) next i close #1 計(jì)算轉(zhuǎn)換參數(shù) redim a(1 to 2 * n, 1 to 4) as double, l(1 to 2 * n) as double redim at(1 to 4, 1 to 2 * n), naa(1 to 4, 1 to 4), w(1 to 4) debug.print 系數(shù)矩陣a:for i = 1 to n a(2 * i - 1, 1) = 1: a(2 * i -

5、1, 2) = 0: a(2 * i - 1, 3) = x1(i): a(2 * i - 1, 4) = y1(i) debug.print a(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.print a(2 * i, 1), a(2 * i, 2), a(2 * i, 3), a(2 * i, 4) l(2 * i - 1) = x2(i):

6、l(2 * i) = y2(i) next i debug.print 常數(shù)向量l: for i = 1 to 2 * n debug.print l(i) next i matrixtrans a, at debug.print a的轉(zhuǎn)置矩陣: showmatrix at matrix_multy naa, at, a debug.print naa: showmatrix naa matrix_multy w, at, l debug.print w: for i = 1 to 4 debug.print w(i) next i majorincolguass naa, w, x debu

7、g.print x for i = 1 to 4 debug.print x(i) next i 分離旋轉(zhuǎn)和尺度參數(shù) if abs(x(3) 0 then e2 = pi / 2 else e2 = pi * 3 / 2 end if else e2 = atn(x(4) / x(3) 得到的是弧度 if x(3) 0 then e2 = pi - e2 elseif x(3) 0 and x(4) 0 and x(4) 0 then e2 = pi * 2 + e2 end if end if k2 = x(3) / cos(e2) 將轉(zhuǎn)換參數(shù)寫(xiě)入相應(yīng)文本框 txtk2 = str(k2 -

8、 1) e2 = e2 * 180 / pi dim du%, fen% du = int(e2): e2 = (e2 - du) * 60 fen = int(e2): e2 = (e2 - fen) * 60 e2 = val(format(e2, 0.00) e2 = du + fen / 100# + e2 / 10000 txte2 = str(e2) txtdx2.text = str(x(1) txtdy2.text = str(x(2)end subprivate sub cmdcalc2_click() k2 = val(txtk2.text) e2 = val(txte2.

9、text) e2 = dotohu(e2) dx2 = val(txtdx2.text) dy2 = val(txtdy2.text) x2 = val(txtx2.text) y2 = val(txty2.text) xx2 = (k2 + 1) * (x2 * cos(e2) + y2 * sin(e2) + dx2 yy2 = (k2 + 1) * (y2 * cos(e2) - x2 * sin(e2) + dy2 txtxx2.text = format(xx2, 0.0000) txtyy2.text = format(yy2, 0.0000)end subprivate sub

10、cmdcalc3_click() k3 = val(txtk3.text) ex = val(txtex.text) ex = dotohu(ex) ey = val(txtey.text) ey = dotohu(ey) ez = val(txtez.text) ez = dotohu(ez) dx3 = val(txtdx3.text) dy3 = val(txtdy3.text) dz3 = val(txtdz3.text) x3 = val(txtx3.text) y3 = val(txty3.text) z3 = val(txtz3.text) xx3 = (k3 + 1) * (x

11、3 * cos(ey) * cos(ez) + y3 * cos(ey) * sin(ez) - z3 * sin(ey) + dx3 yy3 = (k3 + 1) * (x3 * (-cos(ex) * sin(ez) + sin(ex) * sin(ey) * cos(ez) + y3 * (cos(ex) * cos(ez) + sin(ex) * sin(ey) * sin(ez) + z3 * (sin(ex) * cos(ey) + dy3 zz3 = (k3 + 1) * (x3 * (sin(ex) * sin(ez) + cos(ex) * sin(ey) * cos(ez)

12、 + y3 * (-sin(ex) * cos(ez) + cos(ex) * sin(ey) * sin(ez) + z3 * (cos(ex) * cos(ey) + dz3 txtxx3.text = format(xx3, 0.0000) txtyy3.text = format(yy3, 0.0000) txtzz3.text = format(zz3, 0.0000)end subprivate sub cmdclear2_click() txtx2.text = txty2.text = txtxx2.text = txtyy2.text = end subprivate sub

13、 cmdclear3_click() txtx3.text = txty3.text = txtz3.text = txtxx3.text = txtyy3.text = txtzz3.text = end subprivate sub cmdconcalc2_click() k2 = val(txtk2.text) e2 = val(txte2.text) e2 = dotohu(e2) dx2 = val(txtdx2.text) dy2 = val(txtdy2.text) xx2 = val(txtxx2.text) yy2 = val(txtyy2.text) x2 = (xx2 -

14、 dx2) * cos(e2) - (yy2 - dy2) * sin(e2) / (k2 + 1) y2 = (yy2 - dy2) * cos(e2) + (xx2 - dx2) * sin(e2) / (k2 + 1) txtx2.text = format(x2, 0.0000) txty2.text = format(y2, 0.0000)end subprivate sub cmdconcalc3_click() k3 = val(txtk3.text) ex = val(txtex.text) ex = dotohu(ex) ey = val(txtey.text) ey = d

15、otohu(ey) ez = val(txtez.text) ez = dotohu(ez) dx3 = val(txtdx3.text) dy3 = val(txtdy3.text) dz3 = val(txtdz3.text) xx3 = val(txtxx3.text) yy3 = val(txtyy3.text) zz3 = val(txtzz3.text) x3 = (xx3 - dx3) * cos(ey) * cos(ez) + (yy3 - dy3) * (-cos(ex) * sin(ez) + sin(ex) * sin(ey) * cos(ez) + (zz3 - dz3

16、) * (sin(ex) * sin(ez) + cos(ex) * sin(ey) * cos(ez) / (k3 + 1) y3 = (xx3 - dx3) * cos(ey) * sin(ez) + (yy3 - dy3) * (sin(ex) * sin(ey) * sin(ez) + cos(ex) * cos(ez) + (zz3 - dz3) * (-sin(ex) * cos(ez) + cos(ex) * sin(ey) * sin(ez) / (k3 + 1) z3 = (xx3 - dx3) * (-sin(ey) + (yy3 - dy3) * sin(ex) * co

17、s(ey) + (zz3 - dz3) * (cos(ex) * cos(ey) / (k3 + 1) txtx3.text = format(x3, 0.0000) txty3.text = format(y3, 0.0000) txtz3.text = format(z3, 0.0000)end subprivate sub cmdexit_click() endend subprivate sub form_load() frmcoortrans.height = 4440end sub弧度化為度.分秒的形式:輸入弧度值,輸出度.分秒(各占兩位)public function hutod

18、o(byval hu as double) as single dim du%, fen%, miao% hu = hu * 180 / pi du = fix(hu) hu = (hu - du) * 60 fen = fix(hu) hu = (hu - fen) * 60 miao = fix(hu + 0.5) if miao = 60 then fen = fen + 1 miao = 0 end if hutodo = du + fen / 100 + miao / 10000end function將度.分秒形式化為弧度:輸入為度.分秒形式,輸出為弧度public functio

19、n dotohu(byval dofenmiao as double) as single dim du%, fen%, miao%, angle# du = fix(dofenmiao) dofenmiao = (dofenmiao - du) * 100 fen = fix(dofenmiao) miao = (dofenmiao - fen) * 100 angle = du + fen / 60 + miao / 3600 dotohu = angle * pi / 180end function矩陣轉(zhuǎn)置的通用過(guò)程public sub matrixtrans(a, at) dim i%

20、, j% dim r1%, c1% on error resume next c1 = ubound(a, 2) - lbound(a, 2) + 1 if err then msgbox 輸入的矩陣維數(shù)不對(duì)! exit sub end if r1 = ubound(a, 1) - lbound(a, 1) + 1 redim c(1 to c1, 1 to r1) for i = 1 to r1 for j = 1 to c1 at(j, i) = a(i, j) next j next iend sub矩陣相乘:輸入矩陣或數(shù)qa、qb,自動(dòng)識(shí)別它們的維數(shù),并輸出它們的乘積qnpublic

21、sub matrix_multy(qn, qa, qb) dim ia%, ib%, ic% dim ai%, bi%, ci% dim e1 as boolean, e2 as boolean, e3 as boolean, e4 as boolean, e5 as boolean, e6 as boolean, e7 as boolean on error resume next 看qa是不是一維數(shù)組 ic = ubound(qa, 2) - lbound(qa, 2) if err then e1 = true on error resume next 看qa是不是一維數(shù)組 ib = u

22、bound(qb, 2) - lbound(qb, 2) if err then e2 = true if e1 = false and e2 = false then 二維矩陣相乘 for ai = lbound(qa, 1) to ubound(qa, 1) for bi = lbound(qb, 2) to ubound(qb, 2) for ci = lbound(qa, 2) to ubound(qa, 2) qn(ai, bi) = qn(ai, bi) + qa(ai, ci) * qb(ci, bi) next ci next bi next ai elseif e1 = tr

23、ue and e2 = false then on error resume next ia = ubound(qa) - lbound(qa) if err then e6 = true if e6 then 數(shù)乘以二維矩陣 for ai = lbound(qb, 1) to ubound(qb, 1) for bi = lbound(qb, 2) to ubound(qb, 2) qn(ai, bi) = qa * qb(ai, bi) next bi next ai else 一維矩陣乘以二維矩陣 for ci = lbound(qb, 2) to ubound(qb, 2) for a

24、i = lbound(qa, 1) to ubound(qa, 1) qn(ci) = qn(ci) + qa(ai) * qb(ai, ci) next ai next ci end if elseif e1 = false and e2 = true then on error resume next ic = ubound(qb) - lbound(qb) if err then e7 = true if e7 then 二維矩陣乘以數(shù) for ai = lbound(qa, 1) to ubound(qa, 1) for bi = lbound(qa, 2) to ubound(qa,

25、 2) qn(ai, bi) = qa(ai, bi) * qb next bi next ai else 二維矩陣乘以一維矩陣 for ai = lbound(qa, 1) to ubound(qa, 1) for bi = lbound(qa, 2) to ubound(qa, 2) qn(ai) = qn(ai) + qa(ai, bi) * qb(bi) next bi next ai end if else dim errt as integer on error resume next 結(jié)果是否是一個(gè)數(shù) errt = ubound(qn) if err then e3 = true

26、 if e3 then 一維矩陣乘以一維矩陣得一個(gè)數(shù) for ai = lbound(qa, 1) to ubound(qa, 1) for bi = lbound(qa, 2) to ubound(qa, 2) qn = qn + qa(ai) * qb(bi) next bi next ai exit sub end if on error resume next 是否是數(shù)乘一維矩陣 ia = ubound(qa) - lbound(qa) if err then e4 = true if e4 then for bi = lbound(qa, 2) to ubound(qa, 2) qn

27、(bi) = qa * qb(bi) next bi exit sub end if on error resume next 是否是一維矩陣乘數(shù) ib = ubound(qb) - lbound(qb) if err then e5 = true if e5 then for ai = lbound(qa, 1) to ubound(qa, 1) qn(ai) = qa(ai) * qb next ai exit sub end if 一維矩陣相乘結(jié)果是二維矩陣 for ai = lbound(qa, 1) to ubound(qa, 1) for bi = lbound(qa, 2) to

28、 ubound(qa, 2) qn(ai, bi) = qa(ai) * qb(bi) next bi next ai end ifend subpublic sub showmatrix(tt) dim i%, j%, n%, m% m = ubound(tt, 1) - lbound(tt, 1) + 1 n = ubound(tt, 2) - lbound(tt, 2) + 1 for i = 1 to m for j = 1 to n debug.print tt(i, j), next j debug.print next iend sub列選主元法guass約化求解線性方程組pub

29、lic sub majorincolguass(a, b, x) dim row%, col%, n% 矩陣大小 dim istep%, irow%, icol% 循環(huán)變量 dim l() as double 各行的約化系數(shù) 計(jì)算并檢查矩陣的大小 row = ubound(a, 1) - lbound(a, 1) + 1 col = ubound(a, 2) - lbound(a, 2) + 1 if row col then msgbox 方程組的系數(shù)矩陣有誤! exit sub end if 準(zhǔn)備約化過(guò)程的變量和數(shù)組 n = ubound(b) - lbound(b) + 1 if n r

30、ow then msgbox 方程組的系數(shù)矩陣與常數(shù)項(xiàng)大小不符! exit sub end if redim l(2 to row) as double dim sumax as double, ipos%, temp# 約化過(guò)程 for istep = 1 to n - 1 列選主元 ipos = 0 for irow = istep + 1 to n if abs(a(irow, istep) abs(a(istep, istep) then ipos = irow end if next irow if ipos istep then 需要換主元 for icol = istep to

31、n temp = a(istep, icol) a(istep, icol) = a(ipos, icol) a(ipos, icol) = temp next icol temp = b(istep) b(istep) = b(ipos) b(ipos) = temp end if 約化過(guò)程 for irow = istep + 1 to n l(irow) = a(irow, istep) / a(istep, istep) for icol = istep to n a(irow, icol) = a(irow, icol) - l(irow) * a(istep, icol) next

32、 icol b(irow) = b(irow) - l(irow) * b(istep) next irow next istep 回代過(guò)程 x(n) = b(n) / a(n, n) for irow = n - 1 to 1 step -1 sumax = 0 for icol = n to irow + 1 step -1 sumax = sumax + a(irow, icol) * x(icol) next icol x(irow) = (b(irow) - sumax) / a(irow, irow) next irowend suboption explicitdim imark

33、% 測(cè)站計(jì)數(shù)器dim dist!, dh!private sub cmdcancel_click() 清除已經(jīng)傳給主窗體的數(shù)據(jù) dim i% for i = 1 to imark dis(i) = 0 deth(i) = 0 next i 清除主窗體的顯示 frmmain.txtshowresult.text = 水準(zhǔn)計(jì)算結(jié)果: 卸載輸入窗體 unload meend subprivate sub cmdok_click() dist = val(txtdist.text) dh = val(txtdeth.text) call adddata(imark, dist, dh) 在主窗體顯示本

34、站數(shù)據(jù) frmmain.txtshowresult = frmmain.txtshowresult & 第 & str(imark) & 站: & vbcrlf frmmain.txtshowresult = frmmain.txtshowresult & 距離: & dis(imark) & 高差中數(shù): & deth(imark) & vbcrlf if imark = nmarks then 如果已經(jīng)輸入完所有的測(cè)站觀測(cè)值 frminput.hide else 若還沒(méi)有輸完,初始化輸入界面輸入下一個(gè)測(cè)站 txtdist.text = txtdeth.text = txtdist.setfo

35、cus end if frminput.caption = 觀測(cè)數(shù)據(jù)輸入:第 & trim(str(imark) & 站 imark = imark + 1 測(cè)站數(shù)加1end subprivate sub form_load() imark = 1end suboption explicitdim imark% 測(cè)站計(jì)數(shù)器dim dist!, dh!private sub cmdcancel_click() 清除已經(jīng)傳給主窗體的數(shù)據(jù) dim i% for i = 1 to imark dis(i) = 0 deth(i) = 0 next i 清除主窗體的顯示 frmmain.txtshowr

36、esult.text = 水準(zhǔn)計(jì)算結(jié)果: 卸載輸入窗體 unload meend subprivate sub cmdok_click() dist = val(txtdist.text) dh = val(txtdeth.text) call adddata(imark, dist, dh) 在主窗體顯示本站數(shù)據(jù) frmmain.txtshowresult = frmmain.txtshowresult & 第 & str(imark) & 站: & vbcrlf frmmain.txtshowresult = frmmain.txtshowresult & 距離: & dis(imark)

37、 & 高差中數(shù): & deth(imark) & vbcrlf if imark = nmarks then 如果已經(jīng)輸入完所有的測(cè)站觀測(cè)值 frminput.hide else 若還沒(méi)有輸完,初始化輸入界面輸入下一個(gè)測(cè)站 txtdist.text = txtdeth.text = txtdist.setfocus end if frminput.caption = 觀測(cè)數(shù)據(jù)輸入:第 & trim(str(imark) & 站 imark = imark + 1 測(cè)站數(shù)加1end subprivate sub form_load() imark = 1end suboption explici

38、toption base 1 dim sangle() as double, sdangle() as double, sedge() as double dim detx() as double, dety() as double, rex() as double, rey() as double dim strfilename as string dim itype%, xa#, ya#, xb#, yb#, xc#, yc#, xd#, yd# dim istation as integer dim deta as double 角度閉合差 dim dettx#, detty#, det

39、tt#, tedge# x坐標(biāo)閉合差、y坐標(biāo)閉合差、總體閉合差、路線長(zhǎng) const pi = 3.141592653 private sub mnuabout_click() form2.show 1end subprivate sub mnucalc_click() 計(jì)算坐標(biāo)方位角 dim aab#, adc# dim i% aab = directab(xa, ya, xb, yb) txtshow.text = txtshow.text & vbcrlf & 起始坐標(biāo)方位角 & format(hutodo(aab), 0.0000) if itype = 1 then adc = dir

40、ectab(xc, yc, xd, yd) txtshow.text = txtshow.text & vbcrlf & 終止坐標(biāo)方位角 & format(hutodo(adc), 0.0000) else txtshow.text = txtshow.text & vbcrlf & 終止坐標(biāo)方位角 & format(hutodo(aab), 0.0000) end if 推算坐標(biāo)方位角,把推算得到的方位角初值給sdangle數(shù)組 sdangle(1) = aab txtshow.text = txtshow.text & vbcrlf & 方位角初值: & vbcrlf for i = 1

41、to istation sdangle(i + 1) = sdangle(i) + pi - sangle(i) txtshow.text = txtshow.text & format(hutodo(sdangle(i), 0.0000) & , next i txtshow.text = txtshow.text & format(hutodo(sdangle(i), 0.0000) & vbcrlf 計(jì)算角度閉合差 if itype = 1 then deta = sdangle(i) - adc else deta = sdangle(i) - aab end if txtshow.t

42、ext = txtshow.text & format(hutodo(deta), 0.0000) & vbcrlf 判斷是否附合限差要求 if deta int(40 * sqr(istation) then msgbox 角度閉合差超限!, , 計(jì)算終止 txtshow.text = txtshow.text & vbcrlf & 角度閉合差超限,計(jì)算終止! exit sub end if 若沒(méi)有超限,則分配角度閉合差,重新計(jì)算角度值和推算坐標(biāo)方位角 deta = deta / istation 簡(jiǎn)單地平均分配角度值了,后面對(duì)秒進(jìn)行四舍五入處理 txtshow.text = txtshow

43、.text & 改正后的角度: & vbcrlf for i = 1 to istation sangle(i) = sangle(i) + deta txtshow.text = txtshow.text & format(hutodo(sangle(i), 0.0000) & , sdangle(i) = sdangle(i) + deta * (i - 1) next i txtshow.text = txtshow.text & vbcrlf & 改正后的方位角: & vbcrlf for i = 1 to istation txtshow.text = txtshow.text &

44、format(hutodo(sdangle(i), 0.0000) & , next i txtshow.text = txtshow.text & vbcrlf 計(jì)算初始坐標(biāo)增量 txtshow.text = txtshow.text & 坐標(biāo)增量初值: & vbcrlf for i = 2 to istation detx(i - 1) = sedge(i - 1) * cos(sdangle(i) txtshow.text = txtshow.text & format(detx(i - 1), 0.000) & , dety(i - 1) = sedge(i - 1) * sin(sdangle(i) txtshow.text = txtshow.text & format(dety(i - 1), 0.000) & ; next i txtshow.text = txtshow.text & vbcrlf 計(jì)算坐標(biāo)閉合差 rex(1) = xb: rey(1) = yb: tedge = 0 for i = 2 to ist

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論