數(shù)控原理課程設(shè)計:逐點插補(bǔ)法_第1頁
數(shù)控原理課程設(shè)計:逐點插補(bǔ)法_第2頁
數(shù)控原理課程設(shè)計:逐點插補(bǔ)法_第3頁
數(shù)控原理課程設(shè)計:逐點插補(bǔ)法_第4頁
數(shù)控原理課程設(shè)計:逐點插補(bǔ)法_第5頁
已閱讀5頁,還剩12頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、數(shù)控原理課程設(shè)計:逐點插補(bǔ)法四象限直線,四象限圓弧順逆,過象限圓弧順逆 程序以及運行截圖工具:Vb6.0Private Sub Command1_Click()Dim xe%, ye%, a%, b%, f%, l%, m%xe = Val(Text1.Text)ye = Val(Text2.Text)f = 0a = 0b = 0Picture1.ClsPicture1.Scale (-10, 10)-(10, -10)Picture1.Line (-10, 0)-(10, 0)Picture1.Line (0, 10)-(0, -10)Picture1.CurrentX = 0: Pict

2、ure1.CurrentY = 0: Picture1.Print 0For l = -9 To 9 Step 1Picture1.CurrentX = l: Picture1.CurrentY = 0: Picture1.Print lPicture1.CurrentX = 0: Picture1.CurrentY = l: Picture1.Print lNext lPicture1.Line (0, 0)-(xe, ye)直線第一象限If xe > 0 And ye > 0 ThenDo Until a = xe And b = yeIf f >= 0 Thena =

3、a + 1Picture1.Line (a - 1, b)-(a, b), QBColor(1)f = f - Abs(ye)Elseb = b + 1Picture1.Line (a, b - 1)-(a, b), QBColor(1)f = f + Abs(xe)End IfPicture1.PSet (a, b)LoopEnd If直線第二象限If xe < 0 And ye > 0 ThenDo Until a = xe And b = yeIf f >= 0 Thena = a - 1Picture1.Line (a + 1, b)-(a, b), QBColor(

4、1)f = f - Abs(ye)Elseb = b + 1Picture1.Line (a, b - 1)-(a, b), QBColor(1)f = f + Abs(xe)End IfPicture1.PSet (a, b)LoopEnd If直線第三象限If xe < 0 And ye < 0 ThenDo Until a = xe And b = yeIf f >= 0 Thena = a - 1Picture1.Line (a + 1, b)-(a, b), QBColor(1)f = f - Abs(ye)Elseb = b - 1Picture1.Line (a

5、, b + 1)-(a, b), QBColor(1)f = f + Abs(xe)End IfPicture1.PSet (a, b)LoopEnd If直線第四象限If xe > 0 And ye < 0 ThenDo Until a = xe And b = yeIf f >= 0 Thena = a + 1Picture1.Line (a - 1, b)-(a, b), QBColor(1)f = f - Abs(ye)Elseb = b - 1Picture1.Line (a, b + 1)-(a, b), QBColor(1)f = f + Abs(xe)End

6、IfPicture1.PSet (a, b)LoopEnd IfEnd Sub圓弧插補(bǔ)Private Sub Command2_Click()Dim xe%, ye%, a%, b%, f!, x1%, y1%, r!, x!, y!, c!, d!, g%, h%xe = Val(Text1.Text)ye = Val(Text2.Text)x1 = Val(Text3.Text)y1 = Val(Text4.Text)r = Sqr(xe * xe + ye * ye)a = x1b = y1c = Abs(x1)d = Abs(y1)Picture1.ClsPicture1.Scale

7、(-10, 10)-(10, -10)Picture1.Line (-10, 0)-(10, 0)Picture1.Line (0, 10)-(0, -10)Picture1.CurrentX = 0: Picture1.CurrentY = 0: Picture1.Print 0For l = -9 To 9 Step 1Picture1.CurrentX = l: Picture1.CurrentY = 0: Picture1.Print lPicture1.CurrentX = 0: Picture1.CurrentY = l: Picture1.Print lNext l逆圓第一象限I

8、f xe >= 0 And ye >= 0 And x1 >= 0 And y1 >= 0 And xe < x1 ThenFor x = x1 To xe Step -0.0001y = Sqr(r * r - x * x)Picture1.PSet (x, y)Next xDo Until a = xe And b = yeIf f >= 0 Thena = a - 1Picture1.Line (a + 1, b)-(a, b), QBColor(1)f = f - 2 * Abs(c) + 1c = Abs(c) - 1Elseb = b + 1Pi

9、cture1.Line (a, b - 1)-(a, b), QBColor(1)f = f + 2 * Abs(d) + 1d = Abs(d) + 1End IfPicture1.PSet (a, b)LoopEnd If逆圓第二象限If xe <= 0 And ye >= 0 And x1 <= 0 And y1 >= 0 And xe < x1 ThenFor x = x1 To xe Step -0.0001y = Sqr(r * r - x * x)Picture1.PSet (x, y)Next xDo Until a = xe And b = ye

10、If f >= 0 Thenb = b - 1Picture1.Line (a, b + 1)-(a, b), QBColor(1)f = f - 2 * Abs(d) + 1d = Abs(d) - 1Elsea = a - 1Picture1.Line (a + 1, b)-(a, b), QBColor(1)f = f + 2 * Abs(c) + 1c = Abs(c) + 1End IfPicture1.PSet (a, b)LoopEnd If逆圓第三象限If xe <= 0 And ye <= 0 And x1 <= 0 And y1 <= 0 An

11、d xe > x1 ThenFor x = x1 To xe Step 0.0001y = -Sqr(r * r - x * x)Picture1.PSet (x, y)Next xDo Until a = xe And b = yeIf f >= 0 Thena = a + 1Picture1.Line (a - 1, b)-(a, b), QBColor(1)f = f - 2 * Abs(c) + 1c = Abs(c) - 1Elseb = b - 1Picture1.Line (a, b + 1)-(a, b), QBColor(1)f = f + 2 * Abs(d)

12、+ 1d = Abs(d) + 1End IfPicture1.PSet (a, b)LoopEnd If逆圓第四象限If xe >= 0 And ye <= 0 And x1 >= 0 And y1 <= 0 And xe > x1 ThenFor x = x1 To xe Step 0.0001y = -Sqr(r * r - x * x)Picture1.PSet (x, y)Next xDo Until a = xe And b = yeIf f >= 0 Thenb = b + 1Picture1.Line (a, b - 1)-(a, b), Q

13、BColor(1)f = f - 2 * Abs(d) + 1d = Abs(d) - 1Elsea = a + 1Picture1.Line (a - 1, b)-(a, b), QBColor(1)f = f + 2 * Abs(c) + 1c = Abs(c) + 1End IfPicture1.PSet (a, b)LoopEnd If順圓第一象限If xe >= 0 And ye >= 0 And x1 >= 0 And y1 >= 0 And xe > x1 ThenFor x = x1 To xe Step 0.0001y = Sqr(r * r -

14、 x * x)Picture1.PSet (x, y)Next xDo Until a = xe And b = yeIf f >= 0 Thenb = b - 1Picture1.Line (a, b + 1)-(a, b), QBColor(1)f = f - 2 * Abs(d) + 1d = Abs(d) - 1Elsea = a + 1Picture1.Line (a - 1, b)-(a, b), QBColor(1)f = f + 2 * Abs(c) + 1c = Abs(c) + 1End IfPicture1.PSet (a, b)LoopEnd If順圓第二象限If

15、 xe <= 0 And ye >= 0 And x1 <= 0 And y1 >= 0 And xe > x1 ThenFor x = x1 To xe Step 0.0001y = Sqr(r * r - x * x)Picture1.PSet (x, y)Next xDo Until a = xe And b = yeIf f >= 0 Thena = a + 1Picture1.Line (a - 1, b)-(a, b), QBColor(1)f = f - 2 * Abs(c) + 1c = Abs(c) - 1Elseb = b + 1Pict

16、ure1.Line (a, b - 1)-(a, b), QBColor(1)f = f + 2 * Abs(d) + 1d = Abs(d) + 1End IfPicture1.PSet (a, b)LoopEnd If順圓第三象限If xe <= 0 And ye <= 0 And x1 <= 0 And y1 <= 0 And xe < x1 ThenFor x = x1 To xe Step -0.0001y = -Sqr(r * r - x * x)Picture1.PSet (x, y)Next xDo Until a = xe And b = yeI

17、f f >= 0 Thenb = b + 1Picture1.Line (a, b - 1)-(a, b), QBColor(1)f = f - 2 * Abs(d) + 1d = Abs(d) - 1Elsea = a - 1Picture1.Line (a + 1, b)-(a, b), QBColor(1)f = f + 2 * Abs(c) + 1c = Abs(c) + 1End IfPicture1.PSet (a, b)LoopEnd If順圓第四象限If xe >= 0 And ye <= 0 And x1 >= 0 And y1 <= 0 And

18、 xe < x1 ThenFor x = x1 To xe Step -0.0001y = -Sqr(r * r - x * x)Picture1.PSet (x, y)Next xDo Until a = xe And b = yeIf f >= 0 Thena = a - 1Picture1.Line (a + 1, b)-(a, b), QBColor(1)f = f - 2 * Abs(c) + 1c = Abs(c) - 1Elseb = b - 1Picture1.Line (a, b + 1)-(a, b), QBColor(1)f = f + 2 * Abs(d)

19、+ 1d = Abs(d) + 1End IfPicture1.PSet (a, b)LoopEnd If圓弧過象限 過第一第二象限的逆圓If x1 >= 0 And y1 >= 0 And xe <= 0 And ye >= 0 ThenFor x = x1 To xe Step -0.0001y = Sqr(r * r - x * x)Picture1.PSet (x, y)Next xg = 0h = rIf x1 >= 0 And y1 >= 0 And g >= 0 And h >= 0 And g < x1 ThenDo Unt

20、il a = g And b = hIf f >= 0 Thena = a - 1Picture1.Line (a + 1, b)-(a, b), QBColor(1)f = f - 2 * Abs(c) + 1c = Abs(c) - 1Elseb = b + 1Picture1.Line (a, b - 1)-(a, b), QBColor(1)f = f + 2 * Abs(d) + 1d = Abs(d) + 1End IfPicture1.PSet (a, b)LoopEnd IfIf xe <= 0 And ye >= 0 And g <= 0 And h

21、>= 0 And xe < g ThenDo Until a = xe And b = yeIf f >= 0 Thenb = b - 1Picture1.Line (a, b + 1)-(a, b), QBColor(1)f = f - 2 * Abs(d) + 1d = Abs(d) - 1Elsea = a - 1Picture1.Line (a + 1, b)-(a, b), QBColor(1)f = f + 2 * Abs(c) + 1c = Abs(c) + 1End IfPicture1.PSet (a, b)LoopEnd IfEnd If圓弧第二第三象限的

22、逆圓If x1 <= 0 And y1 >= 0 And xe <= 0 And ye <= 0 ThenFor y = y1 To ye Step -0.0001x = -Sqr(r * r - y * y)Picture1.PSet (x, y)Next yg = -1 * rh = 0If x1 <= 0 And y1 >= 0 And g <= 0 And h >= 0 And g < x1 ThenDo Until a = g And b = hIf f >= 0 Thenb = b - 1Picture1.Line (a,

23、 b + 1)-(a, b), QBColor(1)f = f - 2 * Abs(d) + 1d = Abs(d) - 1Elsea = a - 1Picture1.Line (a + 1, b)-(a, b), QBColor(1)f = f + 2 * Abs(c) + 1c = Abs(c) + 1End IfPicture1.PSet (a, b)LoopEnd IfIf xe <= 0 And ye <= 0 And g <= 0 And h <= 0 And xe > g ThenDo Until a = xe And b = yeIf f >

24、= 0 Thena = a + 1Picture1.Line (a - 1, b)-(a, b), QBColor(1)f = f - 2 * Abs(c) + 1c = Abs(c) - 1Elseb = b - 1Picture1.Line (a, b + 1)-(a, b), QBColor(1)f = f + 2 * Abs(d) + 1d = Abs(d) + 1End IfPicture1.PSet (a, b)LoopEnd IfEnd If三四象限逆圓If x1 <= 0 And y1 <= 0 And xe >= 0 And ye <= 0 ThenF

25、or x = x1 To xe Step 0.0001y = -Sqr(r * r - x * x)Picture1.PSet (x, y)Next xg = 0h = -rIf g <= 0 And h <= 0 And x1 <= 0 And y1 <= 0 And g > x1 ThenDo Until a = g And b = hIf f >= 0 Thena = a + 1Picture1.Line (a - 1, b)-(a, b), QBColor(1)f = f - 2 * Abs(c) + 1c = Abs(c) - 1Elseb = b

26、 - 1Picture1.Line (a, b + 1)-(a, b), QBColor(1)f = f + 2 * Abs(d) + 1d = Abs(d) + 1End IfPicture1.PSet (a, b)LoopEnd IfIf xe >= 0 And ye <= 0 And g >= 0 And h <= 0 And xe > g ThenDo Until a = xe And b = yeIf f >= 0 Thenb = b + 1Picture1.Line (a, b - 1)-(a, b), QBColor(1)f = f - 2 *

27、 Abs(d) + 1d = Abs(d) - 1Elsea = a + 1Picture1.Line (a - 1, b)-(a, b), QBColor(1)f = f + 2 * Abs(c) + 1c = Abs(c) + 1End IfPicture1.PSet (a, b)LoopEnd IfEnd If14象限逆圓If x1 >= 0 And y1 <= 0 And xe >= 0 And ye >= 0 ThenFor y = y1 To ye Step 0.0001x = Sqr(r * r - y * y)Picture1.PSet (x, y)Ne

28、xt yg = rh = 0If g >= 0 And h <= 0 And x1 >= 0 And y1 <= 0 And g > x1 ThenDo Until a = g And b = hIf f >= 0 Thenb = b + 1Picture1.Line (a, b - 1)-(a, b), QBColor(1)f = f - 2 * Abs(d) + 1d = Abs(d) - 1Elsea = a + 1Picture1.Line (a - 1, b)-(a, b), QBColor(1)f = f + 2 * Abs(c) + 1c =

29、Abs(c) + 1End IfPicture1.PSet (a, b)LoopEnd IfIf xe >= 0 And ye >= 0 And g >= 0 And h >= 0 And g > xe ThenDo Until a = xe And b = yeIf f >= 0 Thena = a - 1Picture1.Line (a + 1, b)-(a, b), QBColor(1)f = f - 2 * Abs(c) + 1c = Abs(c) - 1Elseb = b + 1Picture1.Line (a, b - 1)-(a, b), QB

30、Color(1)f = f + 2 * Abs(d) + 1d = Abs(d) + 1End IfPicture1.PSet (a, b)LoopEnd IfEnd If12象限順圓If x1 <= 0 And y1 >= 0 And xe > 0 And ye > 0 ThenFor x = x1 To xe Step 0.0001y = Sqr(r * r - x * x)Picture1.PSet (x, y)Next xg = 0h = rIf g <= 0 And h >= 0 And x1 <= 0 And y1 >= 0 And

31、g > x1 ThenDo Until a = g And b = hIf f >= 0 Thena = a + 1Picture1.Line (a - 1, b)-(a, b), QBColor(1)f = f - 2 * Abs(c) + 1c = Abs(c) - 1Elseb = b + 1Picture1.Line (a, b - 1)-(a, b), QBColor(1)f = f + 2 * Abs(d) + 1d = Abs(d) + 1End IfPicture1.PSet (a, b)LoopEnd IfIf xe >= 0 And ye >= 0

32、And g >= 0 And h >= 0 And xe > g ThenDo Until a = xe And b = yeIf f >= 0 Thenb = b - 1Picture1.Line (a, b + 1)-(a, b), QBColor(1)f = f - 2 * Abs(d) + 1d = Abs(d) - 1Elsea = a + 1Picture1.Line (a - 1, b)-(a, b), QBColor(1)f = f + 2 * Abs(c) + 1c = Abs(c) + 1End IfPicture1.PSet (a, b)LoopE

33、nd IfEnd If23象限順圓If x1 <= 0 And y1 <= 0 And xe < 0 And ye > 0 ThenFor y = y1 To ye Step 0.0001x = -Sqr(r * r - y * y)Picture1.PSet (x, y)Next yg = -rh = 0If g <= 0 And h <= 0 And x1 <= 0 And y1 <= 0 And g < x1 ThenDo Until a = g And b = hIf f >= 0 Thenb = b + 1Picture1.

34、Line (a, b - 1)-(a, b), QBColor(1)f = f - 2 * Abs(d) + 1d = Abs(d) - 1Elsea = a - 1Picture1.Line (a + 1, b)-(a, b), QBColor(1)f = f + 2 * Abs(c) + 1c = Abs(c) + 1End IfPicture1.PSet (a, b)LoopEnd IfIf xe <= 0 And ye >= 0 And g <= 0 And h >= 0 And xe > g ThenDo Until a = xe And b = yeI

35、f f >= 0 Thena = a + 1Picture1.Line (a - 1, b)-(a, b), QBColor(1)f = f - 2 * Abs(c) + 1c = Abs(c) - 1Elseb = b + 1Picture1.Line (a, b - 1)-(a, b), QBColor(1)f = f + 2 * Abs(d) + 1d = Abs(d) + 1End IfPicture1.PSet (a, b)LoopEnd IfEnd If34順圓If x1 >= 0 And y1 <= 0 And xe < 0 And ye < 0 T

36、henFor x = x1 To xe Step -0.0001y = -Sqr(r * r - x * x)Picture1.PSet (x, y)Next xg = 0h = -rIf g >= 0 And h <= 0 And x1 >= 0 And y1 <= 0 And g < x1 ThenDo Until a = g And b = hIf f >= 0 Thena = a - 1Picture1.Line (a + 1, b)-(a, b), QBColor(1)f = f - 2 * Abs(c) + 1c = Abs(c) - 1Elseb = b - 1Picture1.Line (a, b + 1)-(a, b), QBColor(1)f = f + 2 * Abs(d) + 1d = Abs(d) + 1End IfPicture1.PSet (a, b)LoopEnd IfIf xe <= 0 And ye <= 0 And g <= 0 And h <= 0 And xe < g ThenDo Until a = xe And b = yeIf f >= 0 Thenb = b

溫馨提示

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

評論

0/150

提交評論