The Rocket Program
![]() |
![]() |
|
Angle = 45 degrees, time 10 sec, velocity = 100 fps |
Angle
= 45 degrees, time = 1 sec, velocity = 100 fps |
![]() |
![]() |
| Angle
= 45 degrees, time = 1 sec, velocity = 200 fps |
Angle = 80
degrees, time = 10 sec, velocity = 100 fps |
![]() |
![]() |
| Angle = 120 degrees, time = 10 sec, velocity = 100 fps | Angle = -20 degrees, time = 10 sec, velocity = 100 fps |
![]() Angle = 45 degrees, time = 10 sec, velocity = 100 fps, repulsive gravity! |
|
Public
Class
Form1
Private Velocity As
Integer
Private flightTime As
Double
Private launchAngleD
As Integer
Private launchAngleR
As Double
Private pi As
Double
Private Sub
Form1_Load(ByVal sender
As System.Object,
ByVal e As System.EventArgs)
Handles MyBase.Load
Velocity = 100
flightTime = 10
launchAngleD = 60
pi = 3.1416
launchAngleR = pi * launchAngleD / 180
End Sub
Protected Overrides
Sub OnPaint(ByVal
e As System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)
Dim GraphicsObject
As Graphics = e.Graphics
Dim brush As
New SolidBrush(Color.Blue)
Dim pen1 As
New Pen(Color.Red)
Dim pen2 As
New Pen(Color.Green)
Dim formSize
As New Form
Dim time As
Double
Dim xPsn As
Integer
Dim yPsn As
Integer
Dim g As
Integer = 32
Dim k As
Double
Dim drawFont
As New Font("Arial",
5)
formSize.Height = 400
formSize.Width = 400
formSize.MaximizeBox = True
GraphicsObject.DrawLine(pen1, 50, 350, 350, 350)
'300 units long horizontal axis
GraphicsObject.DrawLine(pen1, 50, 350, 50, 10)
'300 units long vertical axis
For k = 50 To
350 Step 25 '10 to
300 increments of 10
GraphicsObject.DrawString("" & k -
50, drawFont, brush, k, 360.0)
Next
GraphicsObject.TranslateTransform(50, 350)
'move origin to this new location
GraphicsObject.ScaleTransform(1.0, -1.0) 'up
is now positive y direction
For time = 0
To flightTime Step 0.1
'plot tratectory from new origin
xPsn = Velocity * Math.Cos(launchAngleR) * time
yPsn = Velocity * Math.Sin(launchAngleR) * time - (1 / 2) * g * time *
time
GraphicsObject.DrawEllipse(pen2, xPsn, yPsn, 2, 2)
If (xPsn > 300)
Then
Exit For
End If
Next
End Sub
End Class
The Equations
Note that I am using x for multiplication
V is initial velocity, angle is launch angle, t is total flight time
Simplified equations assume rocket operates only under influnece of
constant gravity
launch angle
initial velocity
Also assume a point mass that does not change, ignores air resistance, decrease in mass due to fuel consumption, rotations, ect.
X = Vxcos(angle)xt 'x indicates multiplication
Y = Vxsin(angle)*t - (1/2)xgxt2