Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
repository:football_players [2020/02/17 01:29]
porcaro1
repository:football_players [2021/02/18 19:08] (current)
porcaro1
Line 15: Line 15:
   * Cut/Copy Code.   * Cut/Copy Code.
   * Modify existing code   * Modify existing code
 +    * [[https://​www.glowscript.org/#/​user/​kstedman/​folder/​Public/​program/​CollidingCars|Colliding Crates]]
  
 ---- ----
 ====Activity==== ====Activity====
 ===Handout=== ===Handout===
 +{{ :​repository:​football_players_2.png?​nolink&​600|}}
 **Inelastic Collisions** \\ **Inelastic Collisions** \\
-{{ :​repository:​football_players.png?​nolink&​600|}}+
 In this activity, you will be asked to complete several tasks involving what you have learned about conservation of momentum and the interaction between masses when they collide and applying this knowledge to actual computer program code.  ​ In this activity, you will be asked to complete several tasks involving what you have learned about conservation of momentum and the interaction between masses when they collide and applying this knowledge to actual computer program code.  ​
  
Line 30: Line 32:
   - What is the final velocity of Biff and Buff while still in mid-air?   - What is the final velocity of Biff and Buff while still in mid-air?
   - Whose team wins the game: Biff's or Buff'​s?​   - Whose team wins the game: Biff's or Buff'​s?​
-  - Now modify your [[https://​www.glowscript.org/#/​user/​kstedman/​folder/​Public/​program/​CollidingCars|Colliding Crates]] program to fit this scenario+  - Now modify your [[colliding_crates|Colliding Crates]] program to fit this scenario
 ===Code=== ===Code===
 +[[https://​www.glowscript.org/#/​user/​porcaro1/​folder/​RepositoryPrograms/​program/​FootballPlayers-Incomplete | Link]]
 <code Python [enable_line_numbers="​true"​]>​ <code Python [enable_line_numbers="​true"​]>​
 GlowScript 2.7 VPython GlowScript 2.7 VPython
Line 41: Line 44:
 #Setting the time interval #Setting the time interval
 t=0                                                                             #​I'​ve set the initial time to zero. t=0                                                                             #​I'​ve set the initial time to zero.
-tf=0.940 ​                                                                           #I've set the final time to 0, which gives the crate enough time to slide across the floor+tf=0.940 ​                                                                       #I've set the final time to 0, which gives the crate enough time to slide across the floor
 dt=0.01 ​                                                                        #I want my time interval set at 1/100th of a time unit dt=0.01 ​                                                                        #I want my time interval set at 1/100th of a time unit
  
Line 59: Line 62:
    
 #This creates the graph of the kinetic energy of the crate #This creates the graph of the kinetic energy of the crate
-#f1 = gcurve(color=color.blue) ​                                                  ​#Setting up a graph to show the kinetic energy of the crate as a function of time +#f1 = gcurve(color=color.blue) ​                                                 #Setting up a graph to show the kinetic energy of the crate as a function of time 
-#for t in arange(0, 0.94, 0.01): ​                                                ​# Time goes from 0 to 0.94 in 0.01 time intervals+#for t in arange(0, 0.94, 0.01): ​                                               # Time goes from 0 to 0.94 in 0.01 time intervals
 #    f1.plot(pos=(t,​cratev.mag**2)) #    f1.plot(pos=(t,​cratev.mag**2))
 </​code>​ </​code>​
Line 66: Line 69:
 ====Answer Key==== ====Answer Key====
 ===Handout=== ===Handout===
 +{{ :​repository:​football_players_1.png?​nolink&​600|}}
   -Using the equation for momentum $\vec{p} = m\vec{v}$, we can plug in the known information to find Buff and Biff's respective momenta   -Using the equation for momentum $\vec{p} = m\vec{v}$, we can plug in the known information to find Buff and Biff's respective momenta
     -$\vec{p}_{Buff} = (100  \text{kg})(-8 ​ \text{m/s}) =-800  \text{kg·m/​s}$ ​     -$\vec{p}_{Buff} = (100  \text{kg})(-8 ​ \text{m/s}) =-800  \text{kg·m/​s}$ ​
Line 77: Line 81:
   -See below   -See below
 ===Code=== ===Code===
-[[https://​www.glowscript.org/#/​user/​kstedman/folder/Public/program/92/​edit ​| Link]] +[[https://​www.glowscript.org/#/​user/​porcaro1/folder/RepositoryPrograms/program/FootballPlayers-Solution ​| Link]] 
-<code Python [enable_line_numbers="​true",​ highlight_lines_extra="​6,​8,​10,20,24,25,28,​33"​]>​+<code Python [enable_line_numbers="​true",​ highlight_lines_extra="​6,7,8,17,20,21,22,24,25,30,32,33,​34,​35,​36,​37"]>
 GlowScript 2.7 VPython GlowScript 2.7 VPython
  
 #Creating the objects #Creating the objects
 floor = box(pos=vector(0,​-30,​0),​ size=vector(160,​4,​12),​ color=color.white) ​     #I've created the floor that the crate will slide across floor = box(pos=vector(0,​-30,​0),​ size=vector(160,​4,​12),​ color=color.white) ​     #I've created the floor that the crate will slide across
-crate1 = box(pos=vector(-40,​-20,​0),​ size=vector(20,​20,​5),​ color=color.red) ​          ​#I've created the crate, along with its dimensions and initial position resting on the floor+crate1 = box(pos=vector(-40,​-20,​0),​ size=vector(20,​20,​5),​ color=color.red) ​     #I've created the crate, along with its dimensions and initial position resting on the floor
 crate2 = box(pos=vector(40,​-20,​0),​ size=vector(20,​20,​5),​ color=color.blue) crate2 = box(pos=vector(40,​-20,​0),​ size=vector(20,​20,​5),​ color=color.blue)
-crate1m = user_input("​What is the mass of the left crate?","​mass of left crate"​) +crate1m = 80 
-crate2m = user_input("​What is the mass of the right crate?","​mass of the right crate"​) +crate2m = 100
-crate1v = user_input("​What is the velocity of the left crate?","​velocity of the left crate"​) +
-crate2v = user_input("​What is the velocity of the right crate?","​velocity of the right crate"​) +
 #Setting the time interval #Setting the time interval
 t=0                                                                             #​I'​ve set the initial time to zero. t=0                                                                             #​I'​ve set the initial time to zero.
-tf=10                                                                            #I've set the final time to 0, which gives the crate enough time to slide across the floor+tf=10                                                                           ​#I've set the final time to 0, which gives the crate enough time to slide across the floor
 dt=0.01 ​                                                                        #I want my time interval set at 1/100th of a time unit dt=0.01 ​                                                                        #I want my time interval set at 1/100th of a time unit
  
 #Creates velocity vectors as a function of time #Creates velocity vectors as a function of time
 get_library('​https://​rawgit.com/​perlatmsu/​physutil/​master/​js/​physutil.js'​) ​     #The program needed to know what a motion map is defined as get_library('​https://​rawgit.com/​perlatmsu/​physutil/​master/​js/​physutil.js'​) ​     #The program needed to know what a motion map is defined as
-motionMap1 = MotionMap(crate1,​ tf, 5, markerScale=0.1) ​                          ​#I want to display 5 arrows showing the motion of the crate+motionMap1 = MotionMap(crate1,​ tf, 5, markerScale=0.1) ​                         #I want to display 5 arrows showing the motion of the crate
 motionMap2 = MotionMap(crate2,​ tf, 5, markerScale=0.1) motionMap2 = MotionMap(crate2,​ tf, 5, markerScale=0.1)
  
 #Giving the objects an initial velocity #Giving the objects an initial velocity
-crate1v=vector(crate1v,0,0)                                                           #I'm defining the constant velocity of my crate to be 75 in the x-direction(left to right) ​                                       +crate1v = vec(12,0,0) 
-crate2v=vector(crate2v,0,0)+crate2v = vec(-8,0,0)
 while crate2.pos.x-crate1.pos.x>​20 and crate2.pos.x<​70 and crate1.pos.x>​-70: ​   #I want the crate to stop before it slides off the floor while crate2.pos.x-crate1.pos.x>​20 and crate2.pos.x<​70 and crate1.pos.x>​-70: ​   #I want the crate to stop before it slides off the floor
     rate(50) ​                                                                   #This rate can speed up or slow down the replay     rate(50) ​                                                                   #This rate can speed up or slow down the replay
-    crate1.pos=crate1.pos+crate1v*dt ​                                              ​#I'm moving the crate by adding the change in position (cratev*dt) to the previous position (crate.pos)+    crate1.pos=crate1.pos+crate1v*dt ​                                           #I'm moving the crate by adding the change in position (cratev*dt) to the previous position (crate.pos)
     crate2.pos=crate2.pos+crate2v*dt     crate2.pos=crate2.pos+crate2v*dt
     t=t+dt ​                                                                     #I'm updating the time     t=t+dt ​                                                                     #I'm updating the time
     ​     ​
 #This updates the velocity vectors #This updates the velocity vectors
-    motionMap1.update(t,​crate1v) ​                                                 #This updates the motion map and display of the arrows as the crate slides across the floor+    motionMap1.update(t,​crate1v) ​                                               #This updates the motion map and display of the arrows as the crate slides across the floor
     motionMap2.update(t,​crate2v)     motionMap2.update(t,​crate2v)
     ​     ​
-while crate2.pos.x<​70 and crate2.pos.x-crate1.pos.x<​=20 and crate1.pos.x>​-70:​+while crate2.pos.x<​70 and crate2.pos.x-crate1.pos.x<​=20 and crate1.pos.x>​-70: ​ 
     rate(50)     rate(50)
-    crate1v = (crate1m*crate1v+crate2m*crate2v)/​(crate1m+crate2m)+    crate1v = (crate1m*crate1v+crate2m*crate2v)/​(crate1m+crate2m) ​              #This determines the velocity of crate1 by dividing the total momentum by the total mass
     crate2v = crate1v     crate2v = crate1v
-    crate1.pos=crate1.pos+crate1v*dt ​                                            ​#I'm moving the crate by adding the change in position (cratev*dt) to the previous position (crate.pos)+    crate1.pos=crate1.pos+crate1v*dt ​                                           #I'm moving the crate by adding the change in position (cratev*dt) to the previous position (crate.pos)
     crate2.pos=crate2.pos+crate2v*dt     crate2.pos=crate2.pos+crate2v*dt
-    t=t+dt +    t=t+dt</​code>​
-     +
-#This creates the graph of the kinetic energy of the crate +
-#f1 = gcurve(color=color.blue) ​                                                  #​Setting up a graph to show the kinetic energy of the crate as a function of time +
-#for t in arange(0, 0.94, 0.01): ​                                                # Time goes from 0 to 0.94 in 0.01 time intervals +
-#    f1.plot(pos=(t,​crate1v.mag**2))  ​                                           # plot time vs. kinetic energy of the crate +
-    ​</​code>​+
     ​     ​
 ---- ----
  
-====See Also==== +
-[[colliding_crates | Colliding Crates]]+
  • repository/football_players.1581902957.txt.gz
  • Last modified: 2020/02/17 01:29
  • by porcaro1