个人代码,请指正
Dim n As Integer, R As Double, AngleInit As Single
Dim BX As Single, BY As Single, AngleBA As Double
Dim CX As Double, CY As Integer
Dim EX As Single, EY As Single
Dim m As Boolean
Const PI = 3.1415926
'方案2
Private Sub Command1_Click()
Timer1.Enabled = Not Timer1.Enabled
End Sub
Private Sub Form_Activate()
'画图在Load加载不了,放在Active里
Pic1.ZOrder
Pic1.Scale (-1500, 2500)-(7500, -1500)
'原点A
End Sub
Private Sub Form_Load()
CY = 200
n = 0: R = 16 * PI / 180: AngleInit = 0
End Sub
Private Sub Timer1_Timer()
Dim HBC As Single, EBH As Single
m = False
n = n + 1
R = R * n
AngleBA = R + AngleInit
If AngleBA >= 2 * PI Then AngleInit = AngleBA - 2 * PI: n = 0: R = 16 * PI / 180: m = ture
If m = True Then AngleInit = 0
BX = 1000 * Cos(AngleBA): BY = 1000 * Sin(AngleBA)
CX = Sqr(3300 ^ 2 - (BY - CY) ^ 2) + BX
For HBC = 0 To 60 Step 0.001 'HBC的角度
If CInt(10 * Sin(HBC * PI / 180)) = CInt(10 * Abs((BY - CY)) / 3300) And CInt(100 * Sin(HBC * PI / 180)) = CInt(100 * Abs((BY - CY)) / 3300) And CInt(1000 * Sin(HBC * PI / 180)) = CInt(1000 * Abs((BY - CY)) / 3300) Then 'sin返回值不会很精确,因为PI有误差
Exit For
End If
Next HBC
If BY >= CY Then
EBH = (60 - HBC) * PI / 180
EX = BX + 2000 * Cos(EBH): EY = BY + 2000 * Sin(EBH)
Else
EBH = (60 + HBC) * PI / 180
EX = BX + 2000 * Cos(EBH): EY = 2000 * Sin(EBH) + BY
End If
Text1 = CStr(Format(EX, "0.00")): Text2 = CStr(Format(EY, "0.00"))
Pic1.Cls
Pic1.Line (-1500, 0)-(7500, 0), vbRed
Pic1.Line (0, 2500)-(0, -1500), vbBlue
Pic1.PSet (BX, BY)
Pic1.Line (0, 0)-(BX, BY)
Pic1.Line (BX, BY)-(CX, CY)
Pic1.Line (BX, BY)-(EX, EY)
Pic1.Line (EX, EY)-(CX, CY)
End Sub