VB.net 次摆线
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles PictureBox1.Paint
Dim x As Integer
Dim y As Integer
Dim p As Integer
Dim x1 As Integer
Dim y1 As Integer
Dim x2 As Integer
Dim y2 As Integer
Dim _rnd As Random = New Random(Now.Second)
'x = 75
'y = 15
'p = 15
x = Int(_rnd.NextDouble * 100)
y = Int(_rnd.NextDouble * 100)
p = Int(_rnd.NextDouble * 100)
Me.Label1.Text = x & " - " & y & " - " & p
Dim R1 As Long
R1 = (0.5 - _rnd.NextDouble) * 199
Dim L As Long
L = Int(_rnd.NextDouble * 200)
Dim S As Long
S = Int(_rnd.NextDouble * 50)
Dim M As Long
M = Int(_rnd.NextDouble * 100)
x1 = 250 + CInt((x + y) * Math.Cos(0) + p * Math.Cos(0))
y1 = 250 + CInt((x + y) * Math.Sin(0) + p * Math.Sin(0))
For t As Double = 0 To 6.28 * 100 Step 0.1
x2 = 250 + CInt((x + y) * Math.Cos(t) + p * Math.Cos((x + y) * t / y))
y2 = 250 + CInt((x + y) * Math.Sin(t) + p * Math.Sin((x + y) * t / y))
e.Graphics.DrawLine(Pens.Blue, x1, y1, x2, y2)
x1 = x2
y1 = y2
Next
End Sub
End Class
其中picturebox的size要在(500,500)以上