This is an old revision of the document!


Phineas & Ferb

Activity Information

Learning Goals

  • Apply the principles of constant velocity and uniformly accelerated motion in 1D
  • Create and modify computational models to describe/show a given system

Prior Knowledge Required

  • 1-Dimensional Kinematics
    • The relationship between position, distance, displacement, speed, and velocity
    • Position vs. time and velocity vs. time graphs
  • Scalar and vector quantities

Code Manipulation

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

—-

Activity

Handout

Phineas & Ferb Phineas and Ferb just invented hovercraft skateboards, and Candace, being Candace, needs to take of picture of them to prove, once and for all to their mom, that Phineas and Ferb are still up to their crazy and dangerous shenanigans. Candace sees Phineas and Ferb riding their hoverboards 20 meters behind her, travelling at a constant velocity. She realizes that this is her opportunity; it takes her 20 seconds to grab her camera, bag, and hop on her electric scooter to chase them. She starts from rest and continues (miraculously) with constant acceleration.

  1. Assuming Phineas and Ferb are travelling at 4 meters per second and Candace's scooter is capable of accelerating at 2 meters per second per second, where and when will Candace be able to take a photo of the boys?
  2. What will Candace's final velocity be?
  3. Use the “print” function to show the following:
    1. Phineas, Ferb, and Candace's final position
    2. Phineas and Ferb's final velocity
    3. Candace's final velocity
    4. Candace's acceleration
    5. Final time

Code

Link

  1. GlowScript 2.7 VPython
  2. get_library('https://rawgit.com/perlatmsu/physutil/master/js/physutil.js')
  3. #Window setup
  4. scene.width = 800
  5. scene.height = 150
  6. scene.center = vec(50,5,0)
  7. scene.background = color.white*0.5
  8.  
  9. #Objects (DO NOT ALTER THESE)
  10. floor = box(pos=vector(50,0,0), size=vec(160,1,2))
  11. P_F = box(pos=vector(-20,5,0), size=vec(10,9,2), shininess=0, texture="https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/35ed113d-7deb-48b6-ae95-3ec3e049e23c/dcnmrib-7cc0dedb-e2d9-471a-8d5e-8f1634228201.png?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1cm46YXBwOjdlMGQxODg5ODIyNjQzNzNhNWYwZDQxNWVhMGQyNmUwIiwiaXNzIjoidXJuOmFwcDo3ZTBkMTg4OTgyMjY0MzczYTVmMGQ0MTVlYTBkMjZlMCIsIm9iaiI6W1t7InBhdGgiOiJcL2ZcLzM1ZWQxMTNkLTdkZWItNDhiNi1hZTk1LTNlYzNlMDQ5ZTIzY1wvZGNubXJpYi03Y2MwZGVkYi1lMmQ5LTQ3MWEtOGQ1ZS04ZjE2MzQyMjgyMDEucG5nIn1dXSwiYXVkIjpbInVybjpzZXJ2aWNlOmZpbGUuZG93bmxvYWQiXX0.0YjSs0Ccip92vyd7ngwzW8OhkWw3U8SLSK6O3Y19LT8") #Phineas and Ferb on their hoverboard
  12. Candace = box(pos=vector(0,5,0), size=vec(4,9,2.1), shininess=0, texture="https://vignette.wikia.nocookie.net/phineasandferb/images/8/82/Candace_Flynn2.png/revision/latest?cb=20110624122230") #Candace on her scooter
  13.  
  14. #position labels
  15. L_start= label(pos=floor.pos, text='0', offset=0, yoffset=-10, space=10, height=16, border=4, font='sans')
  16. L_P_F = label(pos=L_start.pos + vec(5,0,0), text='5', offset=0, yoffset=-10, space=10, height=16, border=4, font='sans')
  17.  
  18. #Time for Candace to get her camera
  19. t_CandaceDelay = 20
  20.  
  21. #Parameters and Initial Conditions
  22. P_F_v = vector(4,0,0)
  23. P_F_a = vector(0,0,0)
  24. Cand_v = vector(0,0,0)
  25. Cand_a = vector(2,0,0)
  26.  
  27. #Time and time step
  28. t=0
  29. dt = 0.01
  30.  
  31. #MotionMaps for P_F and Candace
  32. P_F_MotionMap = MotionMap(P_F, 1, 0.5, markerScale=0.75, labelMarkerOrder=False)
  33. Candace_MotionMap = MotionMap(Candace, 1, 0.5, markerScale=0.75, labelMarkerOrder=False, markerColor=color.cyan)
  34.  
  35. #tells scene to wait for a click before while loop runs (DO NOT ALTER)
  36. scene.waitfor ('click')
  37.  
  38. #Calculation Loops
  39. #Motion of P_F before Candace starts moving
  40. while t < t_CandaceDelay:
  41. rate(500)
  42.  
  43.  
  44. P_F_MotionMap.update(t, P_F.vel) #Update Phineas and Ferb MotionMap
  45.  
  46.  
  47. #motion of P_F and Candace once Candace starts moving
  48. while t >= t_CandaceDelay:
  49. rate(500)
  50.  
  51.  
  52. P_F_MotionMap.update(t, P_F.vel)
  53.  
  54.  
  55.  
  56. Candace_MotionMap.update(t, Candace.vel) #Update Candace MotionMap
  57.  
  58. if Candace.pos.x >= P_F.pos.x: #Stop the program
  59. print_options(height=120) #Sets the height of our print box
  60.  
  61.  
  62.  
  63.  
  64.  
  65. label_PFfinal = label(pos=vec(P_F.pos.x,0,0), text=P_F.pos.x, yoffset=-10, border=1, box=False)
  66. scene.pause()
  67.  
  68. t = t + dt

Answer Key

Handout

Code

  1. GlowScript 2.7 VPython
  2. get_library('https://rawgit.com/perlatmsu/physutil/master/js/physutil.js')
  3. #Window setup
  4. scene.width = 800
  5. scene.height = 150
  6. scene.center = vec(50,5,0)
  7. scene.background = color.white*0.5
  8.  
  9. #Objects
  10. floor = box(pos=vector(50,0,0), size=vec(160,1,2))
  11. P_F = box(pos=vector(-20,5,0), size=vec(10,9,2), shininess=0, texture="https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/35ed113d-7deb-48b6-ae95-3ec3e049e23c/dcnmrib-7cc0dedb-e2d9-471a-8d5e-8f1634228201.png?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1cm46YXBwOjdlMGQxODg5ODIyNjQzNzNhNWYwZDQxNWVhMGQyNmUwIiwiaXNzIjoidXJuOmFwcDo3ZTBkMTg4OTgyMjY0MzczYTVmMGQ0MTVlYTBkMjZlMCIsIm9iaiI6W1t7InBhdGgiOiJcL2ZcLzM1ZWQxMTNkLTdkZWItNDhiNi1hZTk1LTNlYzNlMDQ5ZTIzY1wvZGNubXJpYi03Y2MwZGVkYi1lMmQ5LTQ3MWEtOGQ1ZS04ZjE2MzQyMjgyMDEucG5nIn1dXSwiYXVkIjpbInVybjpzZXJ2aWNlOmZpbGUuZG93bmxvYWQiXX0.0YjSs0Ccip92vyd7ngwzW8OhkWw3U8SLSK6O3Y19LT8")
  12. Candace = box(pos=vector(0,5,0), size=vec(4,9,2.1), shininess=0, texture="https://vignette.wikia.nocookie.net/phineasandferb/images/8/82/Candace_Flynn2.png/revision/latest?cb=20110624122230")
  13.  
  14. #position labels
  15. label_PFstart = label(pos=vec(P_F.pos.x,0,0), text='-20', yoffset=-10, border=1, box=False)
  16. label_0 = label(pos=vec(0,0,0), text='0', yoffset=-10, border=1, box=False)
  17.  
  18. #Time for Candace to get her camera
  19. t_CandaceDelay = 20
  20.  
  21. #Parameters and initial conditions
  22. P_F.vel = vector(4,0,0)
  23. P_F.acc = vector(0,0,0)
  24. Candace.vel = vector(0,0,0)
  25. Candace.acc = vector(2,0,0)
  26.  
  27. #Time and time step
  28. t=0
  29. dt = 0.01
  30.  
  31. #MotionMaps for P_F and Candace
  32. P_F_MotionMap = MotionMap(P_F, 1, 0.5, markerScale=0.75, labelMarkerOrder=False)
  33. Candace_MotionMap = MotionMap(Candace, 1, 0.5, markerScale=0.75, labelMarkerOrder=False, markerColor=color.cyan)
  34.  
  35. #tells scene to wait for a click before while loop runs (DO NOT ALTER)
  36. scene.waitfor ('click')
  37.  
  38. #While loops to run the program
  39. while t < t_CandaceDelay:
  40. rate(500)
  41.  
  42. P_F.pos = P_F.pos + P_F.vel*dt #Update P_F position
  43. P_F_MotionMap.update(t, P_F.vel) #Update P_F MotionMap
  44.  
  45. t = t + dt
  46.  
  47. label_PFpos = label(pos=vec(P_F.pos.x,0,0), text=P_F.pos.x, yoffset=-10, border=1, box=False)
  48.  
  49. while t >= t_CandaceDelay: #Candace starts moving after some time delay
  50. rate(500)
  51.  
  52. P_F.pos = P_F.pos + P_F.vel*dt #Update P_F position
  53. P_F_MotionMap.update(t, P_F.vel)
  54.  
  55. Candace.vel = Candace.vel + Candace.acc*dt #Update Candace velocity
  56. Candace.pos = Candace.pos + Candace.vel*dt #Update Candace position
  57. Candace_MotionMap.update(t, Candace.vel) #Update Candace MotionMap
  58.  
  59. if Candace.pos.x >= P_F.pos.x: #Stop the program
  60. print_options(height=120) #Sets the height of our print box
  61. print("Final position = ", P_F.pos.x, "m")
  62. print("Phineas and Ferb's final velocity = ", P_F.vel.x, "m/s")
  63. print("Candace's final velocity = ",Candace.vel.x, "m/s")
  64. print("Candace's acceleration = ",Candace.acc.x, "m/s2")
  65. print("Final time = ", t, "s")
  66. label_PFfinal = label(pos=vec(P_F.pos.x,0,0), text=P_F.pos.x, yoffset=-10, border=1, box=False)
  67. scene.pause()
  68.  
  69. t = t + dt

See Also

  • repository/phineas_ferb.1598368895.txt.gz
  • Last modified: 2020/08/25 15:21
  • by porcaro1