CAD原理實驗報告_第1頁
CAD原理實驗報告_第2頁
CAD原理實驗報告_第3頁
已閱讀5頁,還剩27頁未讀 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、服裝 CAD 原理與應用實驗報告目錄實驗報告一三點畫圓弧 實驗報告二兩點畫圓弧 實驗報告三Bezier曲線的繪制 02-07 08-12 13-17 18-22 實驗報告四 Hermite 曲線的繪制 實驗報告五B樣條曲線的繪制23-27 實驗報告一一、實驗題目使用 VB 軟件實現三點畫圓弧二、實驗目的1 了解服裝 CAD 中的常用曲線,靈活運用理論知識加以運 用,實現操作;2掌握三點畫圓弧的根本原理和繪制方法;3 運用 Visual Basic 6.0 軟件編寫程序實現通過三點的控 制成功繪制圓弧。三、實驗目的三個點 Ax1 ,y1 ,Bx2,y2Cx3 ,y3 的坐 標 根據中垂線相交于圓

2、心可以求出圓心x , y丨的坐標以及半徑 r 根據圓心以及三點的坐標, 判斷出所畫圓弧的起始角, 終止角和中間角的正切角度值, 進而求出這三個角的角度。 比較起始角,終止角和中間角這三點的角度大小,判斷出 所畫圓弧的方向。2源代碼Begin VB.Form Form1Caption = " 三點畫圓弧 "ClientHeight = 5835ClientLeft = 120ClientTop = 450ClientWidth = 8280LinkTopic = "Form1"ScaleHeight = 5835ScaleWidth = 8280Start

3、UpPosition = 3 '窗口缺省Begin VB.CommandButton Command3Caption = "退出 "Height = 615Left = 6000TabIndex = 3Top= 4800Width= 1455EndBegin VB.CommandButton Command2 Caption= "取消 "Height= 615Left = 3360TabIndex = 2Top= 4800Width= 1455EndBegin VB.CommandButton Command1Caption= "畫弧

4、"Height= 615Left = 720TabIndex = 1Top= 4800Width= 1455EndBegin VB.PictureBox Picture1Height = 4335Left = 360ScaleHeight = 4275ScaleWidth = 7515TabIndex = 0Top= 240Width= 7575EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB

5、_PredeclaredId = TrueAttribute VB_Exposed = FalsePrivate pt() As mypointPrivate Sub Form_Load()ReDim pt(1)End Subx AsPrivate Sub Picture1_MouseDown(Button As Integer, Shift As Integer, Single, y As Single)Dim s As Integerpt(UBound(pt).x = xpt(UBound(pt).y = yPicture1.Circle (x, y), 15s = Val(UBound(

6、pt)Select Case sCase 1Picture1.Print "A"Case 2Picture1.Print "B"Case 3Picture1.Print "C"End SelectIf UBound(pt) > 1 Thenpt(UBound(pt)Picture1.Line (pt(UBound(pt) - 1).x, 1).y)-(pt(UBound(pt).x, pt(UBound(pt).y)End IfReDim Preserve pt(UBound(pt) + 1)End SubPrivate Sub

7、 Command1_Click()Dim A1, A2, B1, B2, C1, C2 As SingleDim X0, Y0, r, PI As DoubleDim t1, t2, t3 As DoubleDim t As DoubleA1 = pt(1).x A 2 + pt(1).y A 2 - pt(3).x A 2 - pt(3).y A 2A2 = pt( 2).x a 2 + pt(2).y a 2 - pt(3).x a 2 - pt(3).y a 2B1 = 2 * pt(3).x - 2 * pt(1).xB2 = 2 * pt(3).x - 2 * pt(2).xC1 =

8、 2 * pt(1).y - 2 * pt(3).yC2 = 2 * pt(2).y - 2 * pt(3).yX0 = (A1 * C2 - A2 * C1) / (B2 * C1 - B1 * C2)Y0 = (A1 * B2 - A2 * B1) / (B2 * C1 - B1 * C2)r = Sqr(pt(1).x - X0) * (pt(1).x - X0) + (pt(1).y - Y0) * (pt(1).y - Y0)PI = 4 * Atn(1)t1 = Atn(pt(1).y - Y0) / (pt(1).x - X0)If pt(1).x - X0 > 0 And

9、 pt(1).y - Y0 > 0 Thent1 = t1ElseIf pt(1).x - X0 < 0 And pt(1).y - Y0 > 0 Thent1 = t1 + PIElseIf pt(1).x - X0 < 0 And pt(1).y - Y0 < 0 Thent1 = t1 + PIElset1 = t1 + 2 * PIEnd IfEnd IfEnd Ift2 = Atn(pt(2).y - Y0) / (pt(2).x - X0)If pt(2).x - X0 > 0 And pt(2).y - Y0 > 0 Thent2 = t

10、2ElseIf pt(2).x - X0 < 0 And pt(2).y - Y0 > 0 Thent2 = t2 + PIElseIf pt(2).x - X0 < 0 And pt(2).y - Y0 < 0 Then t2 = t2 + PIElset2 = t2 + 2 * PIEnd IfEnd IfEnd IfIf t1 < t3 < t2 Thenx = X0 + r * Cos(t)y = Y0 + r * Sin(t)Picture1.PSet (x, y)Next tElseIf t2 < t1 < t3 Then t2 =

11、t2 + 2 * PIx = X0 + r * Cos(t) y = Y0 + r * Sin(t) Picture1.PSet (x, y)Next tElseIf t3 < t2 < t1 Then t2 = t2 + 2 * PIx = X0 + r * Cos(t)y = Y0 + r * Sin(t) Picture1.PSet (x, y) Next tElseIf t1 < t2 < t3 Then t1 = t1 + 2 * PIx = X0 + r * Cos(t)y = Y0 + r * Sin(t) Picture1.PSet (x, y) Nex

12、t tElseIf t3 < t1 < t2 Then t1 = t1 + 2 * PIx = X0 + r * Cos(t)y = Y0 + r * Sin(t) Picture1.PSet (x, y) Next tElseIf t2 < t3 < t1 Thenx = X0 + r * Cos(t) y = Y0 + r * Sin(t)Picture1.PSet (x, y)Next tEnd IfEnd SubPrivate Sub Command2_Click()ReDim pt(1)End SubPrivate Sub Command3_Click()En

13、dEnd Sub四 實驗結果實驗報告實驗題目使用 VB 軟件實現兩點畫圓弧、 實驗目的1 了解服裝 CAD 中的常用曲線,靈活運用理論知識加以運 用,實現操作;2 掌握使用兩端點, 以及其中一端點切線畫圓弧的根本原理 和繪制方法;3 運用 Visual Basic 6.0 軟件編寫程序實現通過兩端點, 以及其中一端點切線成功繪制圓弧。、 實驗內容1、實驗原理一圓弧兩端點A , B和A端點切線的方向數L 根據向量的知識,由一圓弧兩端點A , B和A端點切線的方向數 L 求出圓心的坐標和半徑大小; 計算在圓心為原點的新坐標系下初始角和終止角的正切 值,進而求出對應的角度; 判斷 L 和半徑向量的乘

14、積,假設大于 0,那么為逆時針方向 畫圓弧,小于 0,那么為順時針方向畫圓弧; 根據圓的參數方程表達式,利用 VB繪制圓弧。2、源代碼Begin VB.Form Form1AutoRedraw = -1 'TrueCaption = " 兩點加切線畫圓弧 "ClientHeight = 6810ClientLeft = 120ClientTop = 450ClientWidth = 8340LinkTopic = "Form1"ScaleHeight = 6810ScaleWidth = 8340StartUpPosition = 3 '

15、窗口缺省Begin VB.CommandButton Command3Caption = "退出 "Height = 615Left = 6240TabIndex = 3Top= 6000Width= 1575EndBegin VB.CommandButton Command2Caption= "取消 "Height= 615Left = 3360TabIndex = 2Top= 6000Width= 1575EndBegin VB.CommandButton Command1Caption= "畫弧 "Height= 615Left

16、 = 480TabIndex = 1Top= 6000Width= 1575EndBegin VB.PictureBox Picture1AutoRedraw = -1 'TrueHeight = 5175Left = 360ScaleHeight = 5115ScaleWidth = 7515TabIndex = 0Top = 480Width = 7575EndEndAttribute VB_Name = "Form1"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttrib

17、ute VB_PredeclaredId = TrueAttribute VB_Exposed = FalsePrivate pt() As mypointPrivate Sub Form_Load()ReDim pt(1)End Subx AsPrivate Sub Picture1_MouseDown(Button As Integer, Shift As Integer, Single, y As Single)Dim s As Integer pt(UBound(pt).x = x pt(UBound(pt).y = yPicture1.Circle (x, y), 1s = Val(

18、UBound(pt)Select Case sCase 1Picture1.Print "A"Case 2Picture1.Print "B"Case 3Picture1.Print "L" ' 曲線在 A 點處的切線矢量 Picture1.Line (pt(1).x, pt(1).y)-(pt(3).x, pt(3).y)End SelectReDim Preserve pt(UBound(pt) + 1)End SubPrivate Sub Command1_Click()Dim X0, Y0, r As DoubleDi

19、m a1, a2, b1, b2, c1, c2 As DoubleDim t, t1, t2, i, j, k, m, n As DoubleDim pi As Singlepi = 4 * Atn(1)a1 = 2 * pt(1).x - 2 * pt(2).xa2 = pt(3).x - pt(1).xb1 = 2 * pt(1).y - 2 * pt(2).yb2 = pt(3).y - pt(1).ycl = pt(1).x A 2 - pt (2) .x A 2 + pt(1).y A 2 - pt (2) .y A 2c2 = (pt(1).x - pt(3).x) * pt(1

20、).x + (pt(1).y - pt(3).y) * pt(1).yX0 = (b2 * c1 - b1 * c2) / (a1 * b2 - a2 * b1)Y0 = (a1 * c2 - a2 * c1) / (a1 * b2 - a2 * b1)r = Sqr(pt.x - XO) A 2 + (pt.y - YO) A 2)k = (pt(3).y - pt(1).y) * (pt(1).x - X0) - (pt(3).x - pt(1).x) (pt(1).y - YO)m = pt(1).x - XOn = pt(1).y - YOt1 = Atn(Abs(n / m)If m

21、 > O And n > O Thent1 = t1ElseIf m < O And n > O Thent1 = pi - t1ElseIf m < O And n < O Thent1 = pi + t1ElseIf m > O And n < O Thent1 = 2 * pi - t1End Ifi = pt(2).x - XOj = pt(2).y - YOt2 = Atn(Abs(j / i)If i > O And j > O Thent2 = t2ElseIf i < O And j > O Thent2

22、= pi - t2ElseIf i < O And j < O Thent2 = pi + t2ElseIf i > O And j < O Thent2 = 2 * pi - t2End IfIf k > O ThenIf t1 < t2 Thenx = XO + r * Cos(t) y = YO + r * Sin(t) Picture1.PSet (x, y)Next tElse: t2 = t2 + 2 * pix = XO + r * Cos(t) y = YO + r * Sin(t) Picture1.PSet (x, y)Next tEnd

23、 IfElseIf t1 > t2 Thenx = XO + r * Cos(t)y = YO + r * Si n(t)Picturel.PSet (x, y)Next tElse: t1 = t1 + 2 * pix = X0 + r * Cos(t) y = YO + r * Si n(t) Picturel.PSet (x, y)Next tEnd IfEnd IfEnd SubPrivate Sub Comma nd2_Click()ReDim pt(1)End SubPrivate Sub Comma nd3_Click() EndEnd Sub四、實驗結果實驗報告、實驗題目

24、運用VB軟件繪制Bezier曲線、實驗目的1、了解服裝CAD中的常用曲線,通過實際操作加以深入認識;2、了解Bezier曲線的特點,根據 Bezier曲線的根本原理, 推斷出繪制方法并進行操作;3、運用Visual Basic 6.0軟件編寫程序實現曲線的成功繪、實驗內容1、實驗原理設空間有n+1個點P0, P1 , P2 ,Pn,那么稱以下函數所決定的參數曲線為Bezier曲線:nQ(t)PBi(t)(O t 1)i 0式(1-1)中,B,n(t) cn(1 t)niti(i 0,1,n)在給定幾個點時,可在t 0 , 1區間取一系列值,相應的計 算一系列的x(t) , y(t) , z(t

25、)的值,由此可確定空間曲線上各 點的位置,連接后即得該空間曲線。2、源代碼Begin VB.Form BezierCaption= "Bezier 曲線 "ClientHeight= 7575ClientLeft= 60ClientTop= 450ClientWidth= 9255LinkTopic= "Form1"ScaleHeight = 7575ScaleWidth = 9255StartUpPosition = 3 '窗口缺省Begin VB.CommandButton Command2 Caption = "取 消 "

26、;Height = 495Left = 3840TabIndex = 3Top= 6600Width= 1455EndBegin VB.CommandButton Command3 Caption= "退 出 "Height= 495Left = 6720TabIndex = 2Top= 6600Width= 1455EndBegin VB.CommandButton Command1 Caption= "畫 弧 "Height= 495Left = 1080TabIndex = 1Top= 6600Width= 1455EndBegin VB.Pict

27、ureBox Picture1Height = 5655Left = 600ScaleHeight = 5595ScaleWidth = 7995TabIndex = 0Top= 480Width= 8055EndEndAttribute VB_Name = "Bezier"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = True Attribute VB_Exposed = FalsePrivate pt() As mypointP

28、rivate Sub Form_Load()ReDim pt(1)x AsEnd SubPrivate Sub Picture1_MouseDown(Button As Integer, Shift As Integer, Single, y As Single)Dim s As Integer pt(UBound(pt).x = x pt(UBound(pt).y = yPicture1.Circle (x, y), 15s = Val(UBound(pt)Select Case sCase 1 Picture1.Print "P0"Case 2 Picture1.Pri

29、nt "P1"Case 3 Picture1.Print "P2"Case 4Picture1.Print "P3"Case 5Picture1.Print "P4"Case 6Picture1.Print "P5"Case 7 Picture1.Print "P6"Case 8Picture1.Print "P7"Case 9Picture1.Print "P8"Case 10Picture1.Print "P9"

30、Case 11Picture1.Print "P10"End SelectIf UBound(pt) > 1 Thenpt(UBound(pt)Picture1.Line (pt(UBound(pt) - 1).x, 1).y)-(pt(UBound(pt).x, pt(UBound(pt).y)End IfReDim Preserve pt(UBound(pt) + 1)End SubPrivate Sub Command1_Click()Dim i%, t#Dim j, n As IntegerDim s, x, y As Singlen = UBound(pt)

31、 - 1 - 1For j = 1 To 1000x = 0y = 0For i = 0 To nt = j / 1000x = x + pt(i + 1).x * B(i, n, t)y = y + pt(i + 1).y * B(i, n, t)Next iPicture1.PSet (x, y)Next jEnd SubPrivate Function fact(n As Integer)Dim i As IntegerDim s As Longs = 1For i = 1 To ns = s * iNext ifact = sEnd FunctionPrivate Function B

32、(i%, n%, t#) As SingleB = (fact (n) * t A i * (1 - t) A (n - i) / (fact(i) * fact(n - i) End FunctionPrivate Sub Command2_Click()ReDim pt(1)'pt(1)為第一個點 P0End SubPrivate Sub Comma nd3_Click() EndEnd Sub四、實驗結果實驗報告四、 實驗題目運用 VB 軟件繪制三次 Hermite 曲線、 實驗目的1 、了解服裝 CAD 中的常用曲線,通過實際操作加以深入認 識;2 、了解 Hermite 曲線

33、的特點,根據 Hermite 曲線的根本 原理,推斷出繪制方法并進行操作;3 、運用 Visual Basic 6.0 軟件編寫程序實現 Hermite 曲線 的成功繪制。、 實驗內容1、實驗原理三次 Hermite 樣條曲線的一般表達式為:Q(t)=At 3 Bt2 Ct D 0 t 1( 2-1)上式中A、B、C、D四個系數矢量可以根據具體條件來確定。曲線端點 P0(t 0),P1(t 1 )和該曲線在兩個端點的切線矢量,P0'(t 0), P1'(t 1 ),那么可得下面結果:Q(0)=D=P 0Q(1) A B C D P1Q ' (0) C P0'Q&

34、#39;(1)=3A+2B+C=P 1'解上面 的方程組得:A=2( P0 P1) P0' P1'B 3(P1 P0) 2P0' P1'C P0'D P0將上面結果中的系數A、B、C、D代入式(2-1)中,并整理成下面的表達式:323232'32'Q(t)=(2t 3t 1)Po ( 2t 3t )P (t 2t t)F0 (t t )P上式即為三次 Hermite 曲線表達式。當給定P°(x,y,z), R(x,y,z), P°(x, y,z), R(x, y, z)時,可在t 0,1區間中取一系列值,相應的

35、計算 一系列的 x(t),y(t),z(t)的值,由此可確定空間曲線上各點的位置,連接后即得該空間曲線。2、源代碼Beg in VB.Form HermiteCaption= "三次 Hermite 曲線 "ClientHeight = 7575ClientLeft= 60ClientTop= 450ClientWidth = 9255LinkTopic= "Form1"ScaleHeight = 7575ScaleWidth = 9255StartUpPosition = 3 ' 窗口缺省Begin VB.PictureBox Picture1

36、Height = 5655Left = 600ScaleHeight = 5595ScaleWidth = 7995TabIndex = 3Top= 480Width = 8055EndBegin VB.CommandButton Command1Caption = "畫 弧"Height = 495Left = 1200TabIndex = 2Top= 6600Width= 1455EndBegin VB.CommandButton Command3 Caption= "退 出 "Height= 495Left = 6600TabIndex = 1To

37、p= 6600Width= 1455EndBegin VB.CommandButton Command2 Caption= "取 消 "Height= 495Left = 3960TabIndex = 0Top= 6600Width= 1455EndEndAttribute VB_Name = "Hermite"Attribute VB_GlobalNameSpace = FalseAttribute VB_Creatable = FalseAttribute VB_PredeclaredId = TrueAttribute VB_Exposed = F

38、alsePrivate pt() As mypointPrivate Sub Form_Load()ReDim pt(1)x AsEnd SubPrivate Sub Picture1_MouseDown(Button As Integer, Shift As Integer, Single, y As Single)Dim s As Integer pt(UBound(pt).x = x pt(UBound(pt).y = yPicture1.Circle (x, y), 1s = Val(UBound(pt)Select Case sCase 1 Picture1.Print "

39、P0"Case 2Picture1.Print "P1"Case 3Picture1.Print "P01" ' 曲線在 P0 點處的切線矢量Picture1.Line (pt(1).x, pt(1).y)-(pt(3).x, pt(3).y)Case 4Picture1.Print "P11" ' 曲線在 P1 點處的切線矢量Picture1.Line (pt(2).x, pt(2).y)-(pt(4).x, pt(4).y)End SelectReDim Preserve pt(UBound(pt) +

40、1)End SubPrivate Sub Command1_Click()Dim Ax, Bx, Cx, Dx, Ay, By, Cy, Dy As SingleDim P01x!, P11y!Dim j%, t As SingleP01x = 2 * (pt(3).x - pt(1).x)P01y = 2 * (pt(3).y - pt(1).y)P11x = 2 * (pt(2).x - pt(UBound(pt) - 1).x)P11y = 2 * (pt(2).y - pt(UBound(pt) - 1).y)Ax = 2 * (pt(1).x - pt(2).x) + P01x +

41、P11xAy = 2 * (pt(1).y - pt(2).y) + P01y + P11yBx = 3 * (pt(2).x - pt(1).x) - 2 * P01x - P11xBy = 3 * (pt(2).y - pt(1).y) - 2 * P01y - P11yCx = P01xCy = P01yDx = pt(1).xDy = pt(1).yFor j = 1 To 1000t = j / 1000x = Ax * t A 3 + Bx * t A 2 + Cx * t + Dxy = Ay * t a 3 + By * t a 2 + Cy * t + DyPicture1.

42、PSet (x, y)Next jEnd SubPrivate Sub Command2_Click()ReDim pt(1) 'pt(1) 為第一個點 P0 End SubPrivate Sub Command3_Click()EndEnd SubPrivate Sub Form_Activate()Picture1.Scale (0, 500)-(500, 0)End Sub四、 實驗結果實驗報告五實驗題目用VB繪制三次B樣條曲線實驗目的1、了解服裝CAD中的常用曲線。2、掌握B樣條曲線的根本原理和方法,了解 B樣條曲線的特點。、實驗內容1、實驗原理B樣條曲線的數學模型:設空間有n

43、+k+1 個點P°,R,RPki,Pk n,稱以下函數所決定的參數曲線為第i段B樣條曲線:kQi(t)P jFj,k(t)(O t 1,i j oO,1,2,n)其中:1 k jFj,k(t)-( 1)ck 1(tt! i ok jl)k(O t 1,j O,1,2,,k)為基函數。p ,Pi 1 ,P+k為Qi(t)的控制頂點,折線PP 1,P+k為Qi(t)的控制多邊形。k=3時,稱為三次B樣條曲線根據上式可得:132"(t3 3t2 3t 1)6F,3(t)2(3t3 6t24)6132F2,3(t)( 3t3 3t2 3t 1)613F3,3(t) -t36代入前面

44、的式中,第i段三次B樣條曲線表達式為:Qj(t)= Fo,3(t)RF1,3(t)R 1 F2,3(t)R 2F3,3(t)R 3根據給定四個點的,可在t 0 , 1區間取一系列值,相應的 計算一系列的x(t),y(t),z(t)的值,由此可確定空間曲線上 各點的位置,連接后即得該空間曲線。2、源代碼Begi n VB.Form Form1Caption="三次B樣條曲線"Clie ntHeight = 6240Clie ntLeft = 120Clie ntTop= 450Clie ntWidth = 9030Lin kTopic= "Form1"Sc

45、aleHeight = 6240ScaleWidth = 9030StartUpPosition = 3 '窗口缺省Beg in VB.Comma ndButt on Comma nd3Caption="退出"Height = 615Left = 6840Tabln dex= 3Top=54001575WidthEndBeg in VB.Comma ndButt on Comma nd2Cap ti on="取消"Height = 615Left = 3720TabIndex = 2Top= 5400Width= 1575EndBegin VB.CommandButton

溫馨提示

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

評論

0/150

提交評論