This is an old revision of the document!


Head-On Collision

Activity Information

Learning Goals

*Students will be able to apply the principles of constant velocity motion *Students will be able to create and modify computational models to describe and show a given system

Prior Knowledge Required

  • Units
    • Dimensional analysis
  • 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.

Code

  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.  
  11.  
  12. #Definition of objects in the system...***DO NOT CHANGE ANY OF THESE VALUES!!
  13. ground = box(pos=vector(-120,-10,0),length=1200, height=20, width=20,color=color.blue)
  14. redcar = box(pos=vector(-350,10,0), length=40, height=20, width=20, color=color.red)
  15. greentruck = box(pos=vector(450,10,0), length=40, height=20, width=20, color=color.green)
  16.  
  17. #Set the velocity for each vehicle
  18. greentruck.velocity = vector(0,0,0)
  19. redcar.velocity = vector(0,0,0)
  20.  
  21. #Time and Time step
  22. t=0
  23. tf=25
  24. dt = 0.01
  25.  
  26. #Click Screen to Start
  27. scene.waitfor('click')
  28.  
  29. #Calculation Loop
  30. while greentruck.pos.x > 0:
  31. rate (500)
  32.  
  33. redcar.pos.x = redcar.pos.x + redcar.velocity.x * dt
  34.  
  35. greentruck.pos.x = greentruck.pos.x + greentruck.velocity.x *dt
  36.  
  37.  
  38. t = t + dt
  39.  
  40. #Text to be displayed on computer screen
  41. print ("Time = ",t)
  42. print ("Car Position x = ",redcar.pos.x)
  43.  
  44. print ("Truck Position x = ",greentruck.pos.x)

Answer Key

Handout

Code

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

See Also

  • repository/head-on_collision.1597763659.txt.gz
  • Last modified: 2020/08/18 15:14
  • by porcaro1