Projectile Motion Simulator
Build an app that calculates the range, maximum height, and time of flight for a projectile launched at a given angle and velocity. Includes a visual trajectory on Canvas.
🎯 Learning Goals
- ▹ Understand independence of Horizontal and Vertical motion
- ▹ Master kinematic equations for parabolic paths
- ▹ Learn the impact of launch angle on Range and Height
- ▹ Implement Canvas plotting using math simulation loops
🌎 Why This Matters
From sports (bowling a cricket ball or shooting a basketball) to satellites and robotics, predicting where an object will land is vital. This simulator shows you the invisible math that controls everything moving through the air.
📖Understanding Projectile Motion
Theory MasterclassProjectile motion is when an object is launched into the air and follows a curved (parabolic) path under the influence of gravity only. Think of throwing a cricket ball — it goes up, forward, and then comes back down forming a curve. Key Decomposition: The motion is split into TWO independent parts: 1. Horizontal (x-direction): Constant velocity (no acceleration), vₓ = v₀ × cos(θ) 2. Vertical (y-direction): Accelerated by gravity, v_y = v₀ × sin(θ) - g×t Key Variables: v₀ = Initial velocity (how fast you throw) θ = Launch angle (the direction) g = Gravitational acceleration = 9.8 m/s² t = Time Time of Flight: The total time the projectile is in the air. T = 2 × v₀ × sin(θ) / g Maximum Height: The highest point reached. H = v₀² × sin²(θ) / (2g) Range: The horizontal distance traveled. R = v₀² × sin(2θ) / g At θ = 45°, the range is MAXIMUM for a given velocity.
Mathematical Foundation
🎨Part A — Designer View (UI Design)
Open MIT App Inventor → Switch to Designer view. Follow each step below to build the interface.
Set up the screen
Title: "Projectile Motion Simulator" Set ScreenOrientation to Portrait.
Create input section
Add Labels and TextBoxes: - "Initial Velocity (m/s)": TextBox VelocityInput (NumbersOnly) - "Launch Angle (degrees)": TextBox AngleInput (NumbersOnly) - Optional: Slider for angle (MinValue=0, MaxValue=90) for interactive feel
Add Launch button
Add a big Button: "LAUNCH 🚀" Set it to green, bold, full width. This triggers all calculations.
Create results display
Add a Card-like section with Labels: - RangeLabel: "Range: — m" - HeightLabel: "Max Height: — m" - TimeLabel: "Time of Flight: — s" - VxLabel: "Horizontal Velocity: — m/s" - VyLabel: "Initial Vertical Velocity: — m/s"
Add Canvas for trajectory
Add a Canvas component: Width: Fill Parent Height: 250 pixels BackgroundColor: Dark This will show the parabolic path!
Add angle comparison section
Add a Button: "Compare 30° vs 45° vs 60°" Three Labels to show range at each angle for comparison. This demonstrates that 45° gives maximum range.
🧩Part B — Blocks View (Logic & Calculation)
Switch to Blocks view. Now add the logic that makes your app actually work.
Convert angle to radians
MIT App Inventor trigonometry uses DEGREES by default. But just to be safe, create a procedure: toRadians(degrees) = degrees × π / 180 Actually, App Inventor's sin/cos blocks accept degrees directly! So you can use sin(angle) directly where angle is in degrees.
Calculate Time of Flight
When LaunchButton.Click: 1. Read v0 = number(VelocityInput.Text) 2. Read angle = number(AngleInput.Text) 3. T = (2 × v0 × sin(angle)) / 9.8 4. Set TimeLabel.Text = "Time of Flight: " + round(T×100)/100 + " s"
Calculate Maximum Height
H = (v0 × v0 × sin(angle) × sin(angle)) / (2 × 9.8) Set HeightLabel.Text = "Max Height: " + round(H×100)/100 + " m" Note: sin(angle) × sin(angle) = sin²(angle)
Calculate Range
R = (v0 × v0 × sin(2 × angle)) / 9.8 Set RangeLabel.Text = "Range: " + round(R×100)/100 + " m" Note: sin(2×angle) uses the double angle.
Calculate component velocities
vx = v0 × cos(angle) vy = v0 × sin(angle) Set VxLabel.Text = "Horizontal Velocity: " + round(vx×100)/100 + " m/s" Set VyLabel.Text = "Initial Vertical Velocity: " + round(vy×100)/100 + " m/s"
Draw trajectory on Canvas
After calculating, draw the path: 1. Canvas1.Clear 2. Set Canvas paint color to green 3. Loop t from 0 to T in small steps (0.05): x = vx × t y = vy × t - 0.5 × 9.8 × t² Scale x and y to fit Canvas: canvasX = (x / R) × Canvas1.Width canvasY = Canvas1.Height - (y / H) × Canvas1.Height × 0.8 Canvas1.DrawCircle(canvasX, canvasY, 2) This plots dots along the parabolic path!
Build the comparison feature
When CompareButton.Click: Calculate range for 30°, 45°, and 60° with the same v0: R30 = v0² × sin(60°) / 9.8 R45 = v0² × sin(90°) / 9.8 R60 = v0² × sin(120°) / 9.8 Display all three. Students will see that R45 > R30 = R60!
Input validation
Check: velocity must be > 0, angle must be between 0 and 90. Show Notifier alert if values are out of range.
🧪Testing Your App
- ✓v₀=20 m/s, θ=45° → R≈40.8m, H≈10.2m, T≈2.88s
- ✓v₀=10 m/s, θ=30° → R≈8.83m, H≈1.28m, T≈1.02s
- ✓At 90°: Range=0 (goes straight up and comes back)
- ✓At 0°: Range=0 (doesn't go up at all)
- ✓Range at 30° should equal range at 60° (complementary angles)
🚀Bonus Challenges
Extra credit — impress your instructor
- ★Add air resistance effect (simple drag model)
- ★Let users tap the Canvas to set the launch angle visually
- ★Add a 'hit the target' game mode with a target at random distance
- ★Show velocity components as arrows on the Canvas at different time points