enter image description here
Don’t know how to solve this problem.
Just doing simulation of four-stroke cycle, when debugging a “System.ArgumentException” occurs.
Private Sub Animation(q2)
Dim MyGraphics As Graphics
MyGraphics = Me.CreateGraphics
Dim Mycolor As Color = Color.FromArgb(0, 255, 0)
Dim MyPen As New Pen(Color.Green, 1)
Dim ox, oy, ax, ay, bx, by, crank_length, conrod_length
Dim k
Dim q, r As Integer
MyGraphics.Clear(Color.WhiteSmoke)
Call position_analysis(q2)
k = 800
crank_length = r2 * k
conrod_length = r3 * k
'------------------
ox = 150
oy = 300
ax = ox + crank_length * Math.Cos(q2)
ay = oy - crank_length * Math.Sin(q2)
bx = ax + conrod_length * Math.Cos(q3)
by = oy
'------------------
r = crank_length
q = q2 * 180 / pi
If q > 360 Then q = q - 360
q = 360 - q
MyGraphics.DrawArc(MyPen, ox - r, oy - r, 2 * r, 2 * r, q, 90)
'-------------------
LineShape1.X1 = ox
LineShape1.Y1 = oy
LineShape1.X2 = ox + crank_length + conrod_length + 100
LineShape1.Y2 = oy
LineShape2.X1 = ox
LineShape2.Y1 = ox
LineShape2.X2 = ax
LineShape2.Y2 = ay
LineShape3.X1 = ax
LineShape3.Y1 = ay
LineShape3.X2 = bx
LineShape3.Y2 = by
OvalShape1.Location = New Point(ox - OvalShape1.Width / 2, oy - OvalShape1.Height / 2)
OvalShape2.Location = New Point(ax - OvalShape2.Width / 2, ay - OvalShape2.Height / 2)
OvalShape3.Location = New Point(bx - OvalShape3.Width / 2, by - OvalShape3.Height / 2)
RectangleShape1.Location = New Point(bx - RectangleShape1.Width / 2, by - RectangleShape1.Height / 2)
End Sub
enter image description here
Change $exception
into Mygraphics
New contributor
IJH is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.