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.
1. Screen & Canvas Setup
• Set **Screen1** title to "Projectile Simulator". • Go to **Palette** -> **Drawing and Animation**. • Drag a **Canvas** onto the screen. Set **Width** to 'Fill Parent' and **Height** to '300 pixels'. • Drag a **Ball** from the same palette onto the Canvas. Rename to 'ProjectileBall'.
2. Input Fields
• Drag a **HorizontalArrangement** (Layout). • Inside, drag 2 **TextBoxes** (User Interface). • Rename them: 'VelocityTxt' and 'AngleTxt'. • Set both to **NumbersOnly**.
3. The Clock (Brain)
• Go to **Palette** -> **Sensors**. • Drag a **Clock** onto the screen (it will be invisible at the bottom). • Rename it to 'SimClock'. • In Properties, uncheck **TimerEnabled** (we only want it to run when we click START).
4. Launch Button
• Drag a **Button** renamed 'LaunchBtn'. Set text to "FIRE!". • Change **BackgroundColor** to Orange.
🧩Part B — Blocks View (Logic & Calculation)
Switch to Blocks view. Now add the logic that makes your app actually work.
1. Switch to Blocks
• Click the **Blocks** button at the top right of the screen.
2. Starting the Launch
• Click **LaunchBtn** (Gold). Drag out 'when LaunchBtn.Click'. • Click **Variables** (Orange). Drag 'set global Vx to'. • Go to **Math** (Blue). Drag out 'cosine' and multiplication '*'. • Logic: [set global Vx] to [VelocityTxt.Text] * [cos(AngleTxt.Text)].
3. Enabling the Clock
• Click **SimClock**. Drag 'set SimClock.TimerEnabled to'. • Go to the **Logic** drawer (Green). Drag a 'true' block and snap it in.
4. Moving the Ball
• Click **SimClock**. Drag 'when SimClock.Timer' (Gold). • This block runs every 10 milliseconds. • [set ProjectileBall.X to] [ProjectileBall.X] + [get global Vx]. • [set global Vy to] [get global Vy] - [0.5] (this simulates gravity).
🧪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