资源描述
机械原理大作业
课
设计题目:连杆机构运动分析
院
5,源代码
’RR I级机构运动分析的源代码
Public Class RR
'定义输入字段
Public rxA As Single
Public ryA As Single
Public vxA As Single
Public vyA As Single
Public axA As Single
Public ayA As Single
Public phii As Single
Public omegai As Single
Public alphai As Single
Public li As Single
'定义输出参数
Private sgl_rxB As Single
Private sgl_ryB As Single
Private sgl_vxB As Single
Private sgl_vyB As Single
Private sgl_axB As Single
Private sgl_ayB As Single
'实例化类并初始化输入字段
Public Sub New(ByVal radiusVector_xA As Single, ByVal radiusVector_yA As Single, ByVal velocity_xA As Single, ByVal velocity_yA As Single, ByVal acceleration_xA As Single, ByVal acceleration_yA As Single, ByVal phi_i As Single, ByVal omega_i As Single, ByVal alpha_i As Single, ByVal length_i As Single)
rxA = radiusVector_xA
ryA = radiusVector_yA
vxA = velocity_xA
vyA = velocity_yA
axA = acceleration_xA
ayA = acceleration_yA
phii = phi_i
omegai = omega_i
alphai = alpha_i
li = length_i
End Sub
'定义输出属性
Public ReadOnly Property rxB As Single
Get
Return sgl_rxB
End Get
End Property
Public ReadOnly Property ryB As Single
Get
Return sgl_ryB
End Get
End Property
Public ReadOnly Property vxB As Single
Get
Return sgl_vxB
End Get
End Property
Public ReadOnly Property vyB As Single
Get
Return sgl_vyB
End Get
End Property
Public ReadOnly Property axB As Single
Get
Return sgl_axB
End Get
End Property
Public ReadOnly Property ayB As Single
Get
Return sgl_ayB
End Get
End Property
'计算输出参数
Public Sub Calculate()
sgl_rxB = rxA + li * Math.Cos(phii)
sgl_ryB = ryA + li * Math.Sin(phii)
sgl_vxB = vxA - omegai * li * Math.Sin(phii)
sgl_vyB = vyA + omegai * li * Math.Cos(phii)
sgl_axB = axA - omegai * omegai * li * Math.Cos(phii) - alphai * li *_ Math.Sin(phii)
sgl_ayB = ayA - omegai * omegai * li * Math.Sin(phii) + alphai * li *_ Math.Cos(phii)
End Sub
End Class
’RPR II级基本组运动分析的源代码
Public Class RPR
'定义杆组模式枚举类型
Public Enum Mode As Integer
ClockWise = 1
AntiClockWise = -1
End Enum
'定义输入字段
Public rxB As Single
Public ryB As Single
Public vxB As Single
Public vyB As Single
Public axB As Single
Public ayB As Single
Public rxD As Single
Public ryD As Single
Public vxD As Single
Public vyD As Single
Public axD As Single
Public ayD As Single
Public li As Single
Public lj As Single
Public lk As Single
Public M As Mode
'定义输出参数
Private sgl_rxC As Single
Private sgl_ryC As Single
Private sgl_vxC As Single
Private sgl_vyC As Single
Private sgl_axC As Single
Private sgl_ayC As Single
Private sgl_rxE As Single
Private sgl_ryE As Single
Private sgl_vxE As Single
Private sgl_vyE As Single
Private sgl_axE As Single
Private sgl_ayE As Single
Private sgl_phij As Double
Private sgl_omegaj As Double
Private sgl_alphaj As Double
'实例化类并初始化输入字段
Public Sub New(ByVal radiusVector_xB As Single, ByVal radiusVector_yB As Single, ByVal velocity_xB As Single, ByVal velocity_yB As Single,ByVal acceleration_xB As Single, ByVal acceleration_yB As Single, ByVal radiusVector_xD As Single, ByVal radiusVector_yD As Single,ByVal velocity_xD As Single, ByVal velocity_yD As Single, ByVal acceleration_xD As Single, ByVal acceleration_yD As Single,ByVal length_i As Single, ByVal length_j As Single, ByVal length_k As Single, ByVal mode As Mode)
rxB = radiusVector_xB
ryB = radiusVector_yB
vxB = velocity_xB
vyB = velocity_yB
axB = acceleration_xB
ayB = acceleration_yB
rxD = radiusVector_xD
ryD = radiusVector_yD
vxD = velocity_xD
vyD = velocity_yD
axD = acceleration_xD
ayD = acceleration_yD
li = length_i
lj = length_j
lk = length_k
M = mode
End Sub
'定义输出属性
Public ReadOnly Property rxC As Single
Get
Return sgl_rxC
End Get
End Property
Public ReadOnly Property ryC As Single
Get
Return sgl_ryC
End Get
End Property
Public ReadOnly Property vxC As Single
Get
Return sgl_vxC
End Get
End Property
Public ReadOnly Property vyC As Single
Get
Return sgl_vyC
End Get
End Property
Public ReadOnly Property axC As Single
Get
Return sgl_axC
End Get
End Property
Public ReadOnly Property ayC As Single
Get
Return sgl_ayC
End Get
End Property
Public ReadOnly Property rxE As Single
Get
Return sgl_rxE
End Get
End Property
Public ReadOnly Property ryE As Single
Get
Return sgl_ryE
End Get
End Property
Public ReadOnly Property vxE As Single
Get
Return sgl_vxE
End Get
End Property
Public ReadOnly Property vyE As Single
Get
Return sgl_vyE
End Get
End Property
Public ReadOnly Property axE As Single
Get
Return sgl_axE
End Get
End Property
Public ReadOnly Property ayE As Single
Get
Return sgl_ayE
End Get
End Property
Public ReadOnly Property phij As Single
Get
Return sgl_phij
End Get
End Property
Public ReadOnly Property omegaj As Single
Get
Return sgl_omegaj
End Get
End Property
Public ReadOnly Property alphaj As Single
Get
Return sgl_alphaj
End Get
End Property
'计算输出参数
Public Sub Calculate()
Dim phii As Double
Dim phik As Double
Dim s As Double
Dim v As Double
Dim a As Double
'计算phij
Dim kDB As Double
Dim phiDB As Double
Dim phi As Double
If rxB <> rxD Then
kDB = (ryB - ryD) / (rxB - rxD)
If rxB > rxD Then
phiDB = Math.Atan(kDB)
Else
phiDB = Math.Atan(kDB) + Math.PI
End If
Else
If ryB > ryD Then
phiDB = Math.PI / 2
Else
phiDB = 3 * Math.PI / 2
End If
End If
phi = Math.Asin((li + lk) / Math.Sqrt((rxB - rxD) * (rxB - rxD) + (ryB - ryD)*_ (ryB - ryD)))
sgl_phij = phiDB + M * phi
If sgl_phij < 0 Then
sgl_phij += 2 * Math.PI
End If
'计算s
If li = 0 And lk = 0 Then
s = Math.Sqrt((rxB - rxD) * (rxB - rxD) + (ryB - ryD) * (ryB - ryD))
Else
s = (li + lk) / Math.Tan(phi)
End If
'计算phii,phik
phii = sgl_phij + M * Math.PI / 2
phik = sgl_phij - M * Math.PI / 2
'计算rC
sgl_rxC = rxB + li * Math.Cos(phii)
sgl_ryC = ryB + li * Math.Sin(phii)
'计算rE
sgl_rxE = rxC + (lj - s) * Math.Cos(sgl_phij)
sgl_ryE = ryC + (lj - s) * Math.Sin(sgl_phij)
'计算omegaj
Dim G4 As Double = (rxB - rxD) * Math.Cos(sgl_phij) + (ryB - ryD) *_ Math.Sin(sgl_phij)
sgl_omegaj = ((vyB - vyD) * Math.Cos(sgl_phij) - (vxB - vxD) *_ Math.Sin(sgl_phij)) / G4
'计算v
v = ((vxB - vxD) * (rxB - rxD) + (vyB - vyD) * (ryB - ryD)) / G4
'计算vC
sgl_vxC = vxB - sgl_omegaj * Math.Sin(phii)
sgl_vyC = vyB + sgl_omegaj * Math.Cos(phii)
'计算alphaj
Dim G5 As Double = axB - ayD + sgl_omegaj * sgl_omegaj * (rxB - rxD) + 2 * v *_ sgl_omegaj * Math.Sin(sgl_phij)
Dim G6 As Double = ayB - ayD + sgl_omegaj * sgl_omegaj * (ryB - ryD) - 2 * v *_ sgl_omegaj * Math.Cos(sgl_phij)
sgl_alphaj = (G6 * Math.Cos(sgl_phij) - G5 * Math.Sin(sgl_phij)) / G4
'计算s
a = (G5 * (rxB - rxD) + G6 * (ryB - ryD)) / G4
'计算vC
sgl_axC = axB - sgl_alphaj * Math.Sin(phii) - sgl_omegaj * sgl_omegaj *_ Math.Cos(phii)
sgl_ayC = ayB + sgl_alphaj * Math.Cos(phii) - sgl_omegaj * sgl_omegaj *_ Math.Sin(phii)
End Sub
End Class
’RRP II级基本组运动分析的源代码
Public Class RRP
'定义杆组模式枚举类型
Public Enum Mode As Integer
ClockWise = 1
AntiClockWise = -1
End Enum
'定义输入字段
Public rxB As Single
Public ryB As Single
Public vxB As Single
Public vyB As Single
Public axB As Single
Public ayB As Single
Public rxK As Single
Public ryK As Single
Public vxK As Single
Public vyK As Single
Public axK As Single
Public ayK As Single
Public phij As Single
Public omegaj As Single
Public alphaj As Single
Public li As Single
Public lj As Single
Public M As Mode
'定义输出参数
Private sgl_rxC As Single
Private sgl_ryC As Single
Private sgl_vxC As Single
Private sgl_vyC As Single
Private sgl_axC As Single
Private sgl_ayC As Single
Private sgl_rxD As Single
Private sgl_ryD As Single
Private sgl_vxD As Single
Private sgl_vyD As Single
Private sgl_axD As Single
Private sgl_ayD As Single
Private sgl_phii As Double
Private sgl_omegai As Double
Private sgl_alphai As Double
'实例化类并初始化输入字段
Public Sub New(ByVal radiusVector_xB As Single, ByVal radiusVector_yB As Single, ByVal velocity_xB As Single, ByVal velocity_yB As Single, ByVal acceleration_xB As Single, ByVal acceleration_yB As Single, ByVal radiusVector_xK As Single, ByVal radiusVector_yK As Single,ByVal velocity_xK As Single, ByVal velocity_yK As Single, ByVal acceleration_xK As Single, ByVal acceleration_yK As Single,ByVal phi_j As Single, ByVal omega_j As Single, ByVal alpha_j As Single, ByVal length_i As Single, ByVal length_j As Single,ByVal mode As Mode)
rxB = radiusVector_xB
ryB = radiusVector_yB
vxB = velocity_xB
vyB = velocity_yB
axB = acceleration_xB
ayB = acceleration_yB
rxK = radiusVector_xK
ryK = radiusVector_yK
vxK = velocity_xK
vyK = velocity_yK
axK = acceleration_xK
ayK = acceleration_yK
phij = phi_j
omegaj = omega_j
alphaj = alpha_j
li = length_i
lj = length_j
M = mode
End Sub
'定义输出属性
Public ReadOnly Property rxC As Single
Get
Return sgl_rxC
End Get
End Property
Public ReadOnly Property ryC As Single
Get
Return sgl_ryC
End Get
End Property
Public ReadOnly Property vxC As Single
Get
Return sgl_vxC
End Get
End Property
Public ReadOnly Property vyC As Single
Get
Return sgl_vyC
End Get
End Property
Public ReadOnly Property axC As Single
Get
Return sgl_axC
End Get
End Property
Public ReadOnly Property ayC As Single
Get
Return sgl_ayC
End Get
End Property
Public ReadOnly Property rxD As Single
Get
Return sgl_rxD
End Get
End Property
Public ReadOnly Property ryD As Single
Get
Return sgl_ryD
End Get
End Property
Public ReadOnly Property vxD As Single
Get
Return sgl_vxD
End Get
End Property
Public ReadOnly Property vyD As Single
Get
Return sgl_vyD
End Get
End Property
Public ReadOnly Property axD As Single
Get
Return sgl_axD
End Get
End Property
Public ReadOnly Property ayD As Single
Get
Return sgl_ayD
End Get
End Property
Public ReadOnly Property phii As Single
Get
Return sgl_phii
End Get
End Property
Public ReadOnly Property omegai As Single
Get
Return sgl_omegai
End Get
End Property
Public ReadOnly Property alphai As Single
Get
Return sgl_alphai
End Get
End Property
'计算输出参数
Public Sub Calculate()
'计算phii
Dim h As Double
If Math.Cos(phij) = 0 Then
h = rxB - rxK
Else
h = Math.Abs(Math.Cos(phij)) * (ryK - ryB - Math.Tan(phij) * (rxK - rxB))
End If
If M = Mode.ClockWise Then
sgl_phii = Math.Asin((h + lj) / li) + phij
Else
sgl_phii = Math.PI - Math.Asin((h + lj) / li) + phij
End If
'计算rC
sgl_rxC = rxB + li * Math.Cos(sgl_phii)
sgl_ryC = ryB + li * Math.Sin(sgl_phii)
'计算rD
Dim s As Double = (sgl_rxC - rxK + lj * Math.Sin(phij)) / Math.Cos(phij)
sgl_rxD = rxK + s * Math.Cos(phij)
sgl_ryD = ryK + s * Math.Sin(phij)
'计算omegai
Dim Q1 As Double = vxK - vxB - omegaj * (s * Math.Sin(phij) + lj *_ Math.Cos(phij))
Dim Q2 As Double = vyK - vyB + omegaj * (s * Math.Cos(phij) - lj *_ Math.Sin(phij))
Dim Q3 As Double = li * Math.Sin(sgl_phii) * Math.Sin(phij) + li *_ Math.Cos(sgl_phii) * Math.Cos(phij)
sgl_omegai = (Q2 * Math.Cos(phij) - Q1 * Math.Sin(phij)) / Q3
'计算vC
sgl_vxC = vxB - sgl_omegai * li * Math.Sin(sgl_phii)
sgl_vyC = vyB + sgl_omegai * li * Math.Cos(sgl_phii)
'计算vD
Dim v As Double = -(Q1 * li * Math.Cos(sgl_phii) + Q2 * li *_ Math.Sin(sgl_phii)) / Q3
sgl_vxD = vxK + v * Math.Cos(phij) - s * omegaj * Math.Sin(phij)
sgl_vyD = vyK + v * Math.Sin(phij) + s * omegaj * Math.Cos(phij)
'计算alphai
Dim Q4 As Double = axK - axB + sgl_omegai * sgl_omegai * li *_ Math.Cos(sgl_phii) - alphaj * (s * Math.Sin(phij) + lj * Math.Cos(phij)) - omegaj *_ omegaj * (s * Math.Cos(phij) - lj * Math.Sin(phij)) - 2 * v * omegaj * Math.Sin(phij)
Dim Q5 As Double = ayK - ayB + sgl_omegai * sgl_omegai * li *_ Math.Sin(sgl_phii) + alphaj * (s * Math.Cos(phij) - lj * Math.Sin(phij)) - omegaj *_ omegaj * (s * Math.Sin(phij) + lj * Math.Cos(phij)) + 2 * v * omegaj * Math.Cos(phij)
sgl_alphai = (Q5 * Math.Cos(phij) - Q4 * Math.Sin(phij)) / Q3
'计算aC
sgl_axC = axB - sgl_alphai * li * Math.Sin(sgl_phii) - sgl_omega
展开阅读全文