Rocket Program - Translated Origin - Positive Y Direction Changed to Up
Public
Class
Form1
Private Sub
Button1_Click(ByVal sender
As System.Object,
ByVal e As System.EventArgs)
Handles Button1.Click
Me.WindowState =
FormWindowState.Maximized
Dim Velocity
As Integer
'Have user input this
Dim flightTime
As Double
= 10
'Have user input this
Dim launchAngleD
As Integer
= 45
'Have user input this
Dim pi As
Double = 3.1416
Velocity = 100
'Have
user input this
flightTime = 10
'Have user input this
Dim launchAngleR
As Double
= pi * launchAngleD / 180
Dim Graph
As Graphics
Graph = Me.CreateGraphics
Me.Height = 400
'Setting the dimensions of the drawing
window
Me.Width = 400
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)
Graph.DrawLine(pen1, 50, 350, 350, 350)
'300 units long horizontal axis
- velocity, etc, must be consistent with these units
Graph.DrawLine(pen1, 50, 350, 50, 10)
'300 units long vertical axis
For k = 50
To 350 Step 25
'10 to 300 increments of 10
Graph.DrawString("" & k - 50,
drawFont, brush, k, 360.0)
'placing distances along the axis
Next
Graph.TranslateTransform(50, 350)
'move origin to this new location
Graph.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
'Equations - see note below
yPsn = Velocity * Math.Sin(launchAngleR) * time - (1 / 2) * g * time
* time
Graph.DrawEllipse(pen2, xPsn, yPsn, 2, 2)
If (xPsn > 300)
Then
Exit For
End If
Next
End Sub
End
Class
![]() |
![]() |
|
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! |
|