Lesson goal: Projectile Motion & Trajectory

Previous: Newton's cradle and momentum | Home | Next: Conway's Game of Life and emergence

From archers in the ancient world to space rocket launches today, understanding projectile motion is one of the greatest triumphs of physics.

When an object is launched with initial speed $v_0$ at an angle $\theta$ above the horizontal:
  • Horizontal Motion ($x$): In the absence of air friction, no horizontal forces act on the projectile. Its horizontal velocity remains completely constant: $$v_x = v_0 \cos\theta \implies x(t) = x_0 + v_x \cdot t$$
  • Vertical Motion ($y$): Gravity constantly accelerates the projectile downward with acceleration $g$: $$v_y(t) = v_0 \sin\theta - g \cdot t \implies y(t) = y_0 + (v_0 \sin\theta) \cdot t - \frac{1}{2}g t^2$$

The Parabolic Path

Eliminating time $t$ from the equations reveals that the trajectory is a downward-opening parabola: $$y(x) = x \tan\theta - \frac{g}{2 v_0^2 \cos^2\theta} x^2$$

Maximum Range and Complementary Angles

The total horizontal landing distance (range $R$) over flat ground is: $$R = \frac{v_0^2 \sin(2\theta)}{g}$$
  • Because $\sin(2\theta)$ reaches its absolute peak of $1.0$ when $2\theta = 90^\circ$, the angle that produces the maximum possible range is $\theta = 45^\circ$!
  • Two launch angles that sum to $90^\circ$ (called complementary angles, like $30^\circ$ and $60^\circ$, or $25^\circ$ and $65^\circ$) land at the exact same distance because $\sin(2\theta) = \sin(180^\circ - 2\theta)$!
To simulate projectiles in code:
  • add_floor() creates the ground surface.
  • add_box(x, y, w, h, is_static, angle, color) places a rectangular obstacle or wall.
  • launch_ball(x, y, vx, vy, radius, restitution, color) launches a projectile with initial horizontal ($v_x$) and vertical ($v_y$) velocities.
  • physics_world(gx, gy) configures custom world gravity (default is Earth gravity (0, 1)).
add_floor()
speed = 19
angle = 45
rad = math.rad(angle)
vx = speed * math.cos(rad)
vy = -speed * math.sin(rad)

launch_ball(50, 360, vx, vy, 12, 0.6, "#38bdf8")
Move the mouse over a dotted box for more information.

  • Coordinate Signs: Screen pixels measure $y = 0$ at the top of the canvas and $y = 400$ at the bottom. Therefore, launching upward requires a negative vertical velocity ($v_y = -v_0 \sin\theta$).
  • Key Trajectory Formulas:
    • Peak height: $H = \frac{v_0^2 \sin^2\theta}{2g}$
    • Total time of flight: $T = \frac{2 v_0 \sin\theta}{g}$
    • Horizontal range: $R = \frac{v_0^2 \sin(2\theta)}{g}$
  • Interactive Fun: Modify the launch angle and speed in the code editor to lob balls over obstacles or into targets!

Now you try. Adjust angle or speed and click Run to find other trajectory arcs that land in the target basket!

Type your code here:


See your results here: