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

  1. GlowScript 2.7 VPython
  2.  
  3. #Background Screen Color and Size...***DO NOT CHANGE ANY OF THESE VALUES!!
  4. scene.range = 450
  5. scene.center = vector(200,0,0)
  6. scene.width = 1000
  7. scene.height = 400
  8. scene.background = vector(0.7,0.7,0.6)
  9.  
  10. #Definition of objects in the system...***DO NOT CHANGE ANY OF THESE VALUES!!
  11. ground = box(pos=vector(-120,-10,0),length=1200, height=20, width=20,color=color.blue)
  12. redcar = box(pos=vector(-350,10,0), length=40, height=20, width=20, color=color.red)
  13. greentruck = box(pos=vector(450,10,0), length=40, height=20, width=20, color=color.green)
  14.  
  15. #Set the velocity for each vehicle
  16. redcar.velocity = vector(25,0,0)
  17. greentruck.velocity = vector(-40,0,0)
  18.  
  19. #Time and Time step
  20. t=0
  21. tf=25
  22. dt = 0.01
  23.  
  24. #Click Screen to Start
  25. scene.waitfor('click')
  26.  
  27. #Calculation Loop
  28. while greentruck.pos.x > 0:
  29. rate (500)
  30.  
  31. redcar.pos.x = redcar.pos.x + redcar.velocity.x * dt
  32.  
  33. greentruck.pos.x = greentruck.pos.x + greentruck.velocity.x *dt
  34.  
  35. t = t + dt
  36.  
  37. #Text to be displayed on computer screen
  38. print ("Time = ",t)
  39. print ("Car Position x = ",redcar.pos.x)
  40.  
  41. print ("Truck Position x = ",greentruck.pos.x)

Answer Key

Handout

  1. 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)
  2. 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)
  3. We can determine where and when the crash occurs by using the following kinematic equation: $x=x_0 + vt$, where $x$ is the final position, $x_0$ 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 highlighted areas revealing important modifications.

Code

Link

  1. GlowScript 2.7 VPython
  2.  
  3. scene.range = 450
  4. scene.center = vector(200,0,0)
  5. scene.width = 1000
  6. scene.height = 400
  7. scene.background = vector(0.7,0.7,0.6)
  8.  
  9. #define objects in system
  10. ground = box(pos=vector(-120,-10,0),length=1200, height=20, width=20,color=color.blue)
  11. redcar = box(pos=vector(-350,10,0), length=40, height=20, width=20, color=color.red)
  12. greentruck = box(pos=vector(450,10,0), length=40, height=20, width=20, color=color.green)
  13.  
  14. #Set the velocity for each vehicle
  15. redcar.velocity = vector(25,0,0)
  16. greentruck.velocity = vector(-40,0,0)
  17.  
  18.  
  19. #Time and Time step
  20. t=0
  21. tf=25
  22. dt = 0.01
  23.  
  24. #Click Screen to Start
  25. scene.waitfor('click')
  26.  
  27. #Calculation Loop
  28. while greentruck.pos.x > -42.32:
  29. rate (500)
  30.  
  31. redcar.pos.x = redcar.pos.x + redcar.velocity.x * dt
  32.  
  33. greentruck.pos.x = greentruck.pos.x + greentruck.velocity.x *dt
  34.  
  35. t = t + dt
  36.  
  37. #Text to be displayed on computer screen
  38. print ("Time = ",t)
  39. print ("Car Position x = ",redcar.pos.x)
  40.  
  41. print ("Truck Position x = ",greentruck.pos.x)

See Also

  • repository/head-on_collision.txt
  • Last modified: 2021/02/17 18:02
  • by porcaro1