作业帮 > 综合 > 作业

怎样用VB制作一个线段围绕一点旋转?

来源:学生作业帮 编辑:拍题作业网作业帮 分类:综合作业 时间:2024/04/28 21:53:54
怎样用VB制作一个线段围绕一点旋转?
不明白,
试试这个

Dim run As Boolean
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Const Pi As Double = 3.1415936
Private Sub Form_Load()
Dim x As Long, y As Long
Dim x1 As Long, y1 As Long
Dim x2 As Long, y2 As Long
x = 610
y = 610
x1 = 100: y1 = 200
x2 = 360: y2 = 140



Dim l1 As Double, l2 As Double, l3 As Double, a As Double, b As Double
l3 = Sqr((x2 - x1) ^ 2 + (y2 - y1) ^ 2)
l1 = Sqr((x - x1) ^ 2 + (y - y1) ^ 2)
l2 = Sqr((x - x2) ^ 2 + (y - y2) ^ 2)
a = IIf(y < y1, 1, -1) * Arccos((x - x1) / l1)
b = Arccos((l1 ^ 2 + l2 ^ 2 - l3 ^ 2) / (2 * l1 * l2))
run = True
Show
Do While run
Cls
a = a + (0.1 * 2 / Pi)
x1 = l1 * Cos(a) + x
y1 = l1 * Sin(a) + y
x2 = l2 * Cos(a + b) + x
y2 = l2 * Sin(a + b) + y
PSet (x, y)
Line (x1, y1)-(x2, y2)
Sleep 10
DoEvents
Loop
End Sub
Private Function Arccos(x As Double) As Double
If x = 1 Then
Arccos = 0
ElseIf x = -1 Then
Arccos = Pi
Else
Arccos = Atn(-x / Sqr(-x * x + 1)) + 2 * Atn(1)
End If
End Function
Private Sub Form_Unload(Cancel As Integer)
run = False
End Sub
再问: 能不能拜托帮我实现一个构件的旋转运动,老师让我们课程设计做这个,一点不会,很是苦恼!实在不行, 您教教我也行,在网上找不到相关的资料,学校图书馆也没有!拜托了。。。我QQ1430439593,若答应帮我 加我QQ,万分感谢!