Head-on Collision

Activity Information

Learning Goals

  • Students will be able to apply the principles of constant velocity motion ( HS-PS2-1)
  • Students will be able to create and modify computational models to describe and show a given system

Prior Knowledge Required

  • Units
  • Constant velocity equation (kinematics)
  • Vector and scalar quantities

Code Manipulation

  • Copying/pasting code
  • Creating/using while loops
  • Converting mathematical equations into code

Activity

Handout – Head-on Collision

You are part of a team that has been directed to film a head-on car crash for an action movie. You only have the funding for one take! So you must calculate where the crash will occur so that you can determine where to place the camera to get the shot. Look over the code (provided below) and determine:

  1. The initial positions of the vehicles
  2. The velocities of the vehicles
  3. Where and when the crash will occur

Once you have answered these questions, modify the code to test your answers.

Note: When conducting this activity with students, the initial positions and velocities of the vehicles can be provided by the instructor, but for demonstration purposes they have been included in the code below.

Code

Link

GlowScript 2.7 VPython

#Background Screen Color and Size...***DO NOT CHANGE ANY OF THESE VALUES!!
scene.range = 450
scene.center = vector(200,0,0)
scene.width = 1000
scene.height = 400
scene.background = vector(0.7,0.7,0.6)
 
#Definition of objects in the system...***DO NOT CHANGE ANY OF THESE VALUES!!
ground = box(pos=vector(-120,-10,0),length=1200, height=20, width=20,color=color.blue)
redcar = box(pos=vector(-350,10,0), length=40, height=20, width=20, color=color.red)
greentruck = box(pos=vector(450,10,0), length=40, height=20, width=20, color=color.green)
 
#Set the velocity for each vehicle
redcar.velocity = vector(25,0,0)
greentruck.velocity  = vector(-40,0,0)
 
#Time and Time step
t=0
tf=25
dt = 0.01
 
#Click Screen to Start
scene.waitfor('click')
 
#Calculation Loop
while greentruck.pos.x > 0:
    rate (500)
 
    redcar.pos.x = redcar.pos.x + redcar.velocity.x * dt
 
    greentruck.pos.x = greentruck.pos.x + greentruck.velocity.x *dt
 
    t = t + dt
 
#Text to be displayed on computer screen    
print ("Time = ",t)
print ("Car Position x = ",redcar.pos.x)
 
print ("Truck Position x = ",greentruck.pos.x)

Answer Key

Handout

The initial position of the red car is 350 feet to the left of the origin (line 11) and the initial position of the green truck is 450 feet to the right of the origin (line 12) The velocity of the red car is 25 ft/s in the positive x-direction (line 15) and the velocity of the green truck is -40 ft/s in the negative x-direction (line 16) We can determine where and when the crash occurs by using the following kinematic equation: x=x0+vt, where x is the final position, x0 is the initial position, v is the velocity, and t is the time. We can create an equation for the red car (x=−350+25t) and the green truck (x=450−40t). Since we want to know where and when the vehicles are when they collide, we can set these two equations equal to each other to solve for the unknowns (x and t):

−350 + 25t = 450 − 40t 

Using algebra, we can solve for t: 65t=800, therefore t=12.3 s. We can plug this into either of the two equations we created to find out the position where the vehicles collide: x=−350+25∗12.3=−42.5 ft. In other words, the vehicles will collide 42.5 ft to the left of the origin after 12.3 seconds.

The correctly modified code is shown below, with bolded areas revealing important modifications.

Code

Link

GlowScript 2.7 VPython

scene.range = 450
scene.center = vector(200,0,0)
scene.width = 1000
scene.height = 400
scene.background = vector(0.7,0.7,0.6)
 
#define objects in system
ground = box(pos=vector(-120,-10,0),length=1200, height=20, width=20,color=color.blue)
redcar = box(pos=vector(-350,10,0), length=40, height=20, width=20, color=color.red)
greentruck = box(pos=vector(450,10,0), length=40, height=20, width=20, color=color.green)
 
#Set the velocity for each vehicle
redcar.velocity = vector(25,0,0)
greentruck.velocity  = vector(-40,0,0)
 
 
#Time and Time step
t=0
tf=25
dt = 0.01
 
#Click Screen to Start
scene.waitfor('click')
 
#Calculation Loop
while greentruck.pos.x > -42.32:
    rate (500)
 
    redcar.pos.x = redcar.pos.x + redcar.velocity.x * dt
 
    greentruck.pos.x = greentruck.pos.x + greentruck.velocity.x *dt
 
    t = t + dt
 
#Text to be displayed on computer screen    
print ("Time = ",t)
print ("Car Position x = ",redcar.pos.x)
 
print ("Truck Position x = ",greentruck.pos.x)