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:ball_on_a_ramp [2021/03/24 23:06]
porcaro1 [Activity]
repository:ball_on_a_ramp [2021/03/24 23:34] (current)
porcaro1 [Answer Key]
Line 21: Line 21:
 ** Ball on a Ramp **  ** Ball on a Ramp ** 
  
-Provided below is some [[https://​www.glowscript.org/#/​user/​porcaro1/​folder/​REPOSITORYSTUFF/​program/​BallonRamp(StudentVersion)/​edit | code]] that is supposed to model the behavior of a ball rolling down an inclined plane. Run the code.+Provided below is some code that is supposed to model the behavior of a ball rolling down an inclined plane. Run the code.
  
 ==Exploration Instructions== ==Exploration Instructions==
Line 64: Line 64:
  
 ===Code=== ===Code===
-==Incomplete== +[[https://​www.glowscript.org/#/​user/​porcaro1/​folder/​RepositoryPrograms/program/BallOnRamp-Incomplete2 ​| Link]]
-[[https://​www.glowscript.org/#/​user/​porcaro1/​folder/​REPOSITORYSTUFF/program/BallonRamp(StudentVersion)/​edit ​| Link]]+
 <code Python [enable_line_numbers="​true"​]>​ <code Python [enable_line_numbers="​true"​]>​
 GlowScript 2.7 VPython GlowScript 2.7 VPython
Line 145: Line 144:
 #    t=tFinal #sets the timer to the final value, so the loop stops </​code>​ #    t=tFinal #sets the timer to the final value, so the loop stops </​code>​
  
 +----
 +====Answer Key====
 +===Handout===
 +==Evaluation Questions==
 +  - Increasing the height of the ramp did not affect the final speed of the ball.
 +  - Increasing the length of the ramp increased the final speed of the ball.
 +  - The simulation is not realistic; When a ball rolls down a ramp, it is moved due to the force of gravity; however, it cannot fall straight down since it is restricted by the ramp. On a completely horizontal surface, gravity and the normal force perfectly balance each other out, and there is no acceleration. As the ramp becomes steeper, the less the force of gravity is resisted by the normal force. For a completely vertical surface, there will be no normal force and therefore the force of gravity pulls the ball towards the earth unimpeded. This means that increasing the ramp height should increase the speed of the ball. Additionally,​ changing the length of the ramp should not affect the final speed of the ball. Although a ball rolling down a steeper ramp will accelerate faster, the final speed of the ball at the end of the ramp will be the same, regardless of ramp length (ignoring frictional forces). This can be demonstrated by relating the potential and kinetic energy. We can set potential energy equation equal to the kinetic energy equation to find the speed of the ball is affected by the ramp: $$mgh=\dfrac{1}{2}mv^2$$ where $m$ is mass of the ball, $g$ is the acceleration of gravity, $h$ is the height of the ramp, and $v$ is the speed of the ball. Since the mass, force of gravity, and height of the ramp does not change when you lengthen the ramp, the velocity will be the same.
 +  -  Adding a coefficient of friction could reduce the speed of the ball. This is because frictional forces resist motion.
 +  - See highlighted code below. Note that some values are in slightly different locations in the code below.
 +  - "​axis"​ tells us the direction that the ramp will point. In this instance, the ramp will be "​R1X"​ units in the x-direction and "​-R1Y"​ units in the y-direction
 +===Code===
 ==Partially Complete== ==Partially Complete==
-<code Python [enable_line_numbers="​true"​]>​+[[https://​www.glowscript.org/#/​user/​porcaro1/​folder/​RepositoryPrograms/​program/​BallonRamp-Solution/​edit | Link]] 
 +<code Python [enable_line_numbers="​true", highlight_lines_extra="​84,​85,​86"]>
 GlowScript 2.7 VPython GlowScript 2.7 VPython
  
Line 239: Line 250:
     if ball.pos.x > R1s + R1X:     if ball.pos.x > R1s + R1X:
         t=tFinal</​code>​         t=tFinal</​code>​
----- +==Complete== 
-====Answer Key==== +[[https://​www.glowscript.org/#/​user/​porcaro1/​folder/​RepositoryPrograms/​program/​BallonRamp-Solution ​| Link]] 
-===Handout=== +<code Python [enable_line_numbers="​true",​ highlight_lines_extra="​18,​19,​20,​21,​22,​23,​24,​30,​32,​38,​39,​40,​67,​68,​69,​93,​94,​100,​101,​102,​104,​105,​106,​107,​108,​109,​110"]>
-==Evaluation Questions== +
-  - Increasing the height of the ramp did not affect the final speed of the ball. +
-  - Increasing the length of the ramp increased the final speed of the ball. +
-  - The simulation is not realistic; When a ball rolls down a ramp, it is moved due to the force of gravity; however, it cannot fall straight down since it is restricted by the ramp. On a completely horizontal surface, gravity and the normal force perfectly balance each other out, and there is no acceleration. As the ramp becomes steeper, the less the force of gravity is resisted by the normal force. For a completely vertical surface, there will be no normal force and therefore the force of gravity pulls the ball towards the earth unimpeded. This means that increasing the ramp height should increase the speed of the ball. Additionally,​ changing the length of the ramp should not affect the final speed of the ball. Although a ball rolling down a steeper ramp will accelerate faster, the final speed of the ball at the end of the ramp will be the same, regardless of ramp length (ignoring frictional forces). This can be demonstrated by relating the potential and kinetic energy. We can set potential energy equation equal to the kinetic energy equation to find the speed of the ball is affected by the ramp: $$mgh=\dfrac{1}{2}mv^2$$ where $m$ is mass of the ball, $g$ is the acceleration of gravity, $h$ is the height of the ramp, and $v$ is the speed of the ball. Since the mass, force of gravity, and height of the ramp does not change when you lengthen the ramp, the velocity will be the same. +
-  -  Adding a coefficient of friction could reduce the speed of the ball. This is because frictional forces resist motion. +
-  - See below +
-  -  +
-===Code=== +
-[[https://​www.glowscript.org/#/​user/​porcaro1/​folder/​REPOSITORYSTUFF/​program/​BallonRamp(TeacherVersion)/​edit ​| Link]] +
-<code Python [enable_line_numbers="​true",​ highlight_lines_extra=""​]>​+
 GlowScript 2.7 VPython GlowScript 2.7 VPython
  
-# Window setup################################################################​############​ +# Window setup########################​ 
-scene.width = 800 #how far the view extends along the X-axis initially +scene.width = 800 #The width of your view window 
-scene.height = 600 #how tall the view extends on the Y-axis initially+scene.height = 400 #The height of your view window 
 +######################################​
  
-####################​#############################​#########################################​+Parameters and Initial Conditions### 
 +BaR = 10 #Radius of the ball 
 +BaS = 1 #Scalar to change ball speed 
 +Bh = 5 #Height of books in first stack of books 
 +Bw = 30 #Width of books in first stack of books 
 +Bs = -100 #X-value offset of the center of the first book stack 
 +Tt = 0 #refrence point for drawing the books (not used in any real math) 
 +Bc = 1 #condition for beginning to draw books (checked against time) 
 +R1L = 100 #Length of first ramp 
 +nB = 5 #The number of books in the first stack 
 +R2L = 100 #Length of flat section ** 
 +n2B = 5 #The number of books in the second stack of books *** 
 +B2c = 1 #condition for beginning second stack of books (checked against time)*** 
 +T2t = 0 #refrence point for drawing second stack of books(not used in any real math) *** 
 +B2h = 5 #height of books in second stack of books *** 
 +B2w = 30 #width of books in second stack of books *** 
 +R3L= 100 #length of second ramp *** 
 +#########################################​
  
 +# Time and time step#####################​
 +t = 0 #start time (this command sets the counter to 0)
 +tFinal = 100 #The end number on the counter to stop actions
 +tFinal2=100 #Same as above but for second loop (final counter number)**
 +#########################################​
  
-Parameters ​and Initial Conditions#######################################################​ +#Ramp and speed calculations#############​ 
-BaR = 10 #radius of the ball (balldia) +R1Y = Bh*nB #Starting Y-value coordinate for ramp (total Y value of ramp) 
-BaS = 1 #Scalar of speed for ball (ballspeed) +R1X = sqrt(R1L**2 - R1Y**2) ​#Starting X-value coordinate for ramp (total X value of ramp) 
-Bh = 5 #Y-value of individual books (bookheight) +S1x = R1X/​R1L*BaS ​#the horizontal vector of movement down first ramp 
-Bw = 30 #X-value of the individual books (bookwidth) +S1y = R1Y/​R1L*BaS ​#the vertical vector of movement down first ramp 
-Bs = -100 #X-value of the centerpoint of the stack of books (bookstack) +R3Y = B2h*n2B ​#Y-value for second ramp *** 
-Tt = 0 #refrence point for drawing the books (tabletop) +R3X = sqrt(R3L**2 - R3Y**2) ​#X-value for third ramp *** 
-Bc = 1 #condition for beginning to draw books (checked against time)(numberbooks) +B2s = R1X + R2L + R3X + Bs + B2w #X-value of the centerpoint of the second stack of books *** 
-R1L = 100 #Length of down ramp (ramplength) +#########################################​
-R1T = 10 #height of the ramp (rampthickness) +
-nB = 8 #The number of books in the initial stack (numberofbooks) +
-A1 = .1 #​acceleration for ramp 1 determined by students from data+
  
-###########################################################################################​ +#Drawing initial objects#################​
- +
- +
-# Introduction of Objects#################################################################​ +
-#books drawn one at a time in code +
-#ramp drawn on top of books in code +
-#ball drawn on top of ramp in code +
- +
-##########################################################################################​ +
- +
- +
-# Time and time step######################################################################​ +
-t = 0 #start time +
-t2 = 0 #start line for second stack of books *** +
-tFinal = 100 #First phase final time +
-dt = 1 #rate of time change +
-##########################################################################################​ +
- +
- +
-#MAIN CODE LOCATED BELOW +
- +
-#Ramp and speed calculations##############################################################​ +
-R1Y = Bh*nB #Starting Y-value of top of ramp  (rampy) +
-R1X = sqrt(R1L**2 - R1Y**2) #distance of ramp from stack of books (x-value) (rampx) +
-S1x = R1X/R1L*BaS #the horizontal vector of movement (speedx) +
-S1y = R1Y/R1L*BaS #the vertical vector of movement (speedy) +
-A1x = R1X/R1L*A1 # horizontal acceleration +
-A1y = R1Y/R1L*A1 # vertical acceleration +
-##########################################################################################​ +
- +
- +
-#Drawing initial objects#################################################​#################​+
 #draw tabletop #draw tabletop
 Table= box(pos = vector(75,​-6,​0),​ size = vector(400, 10, 30), color = color.orange) Table= box(pos = vector(75,​-6,​0),​ size = vector(400, 10, 30), color = color.orange)
Line 315: Line 305:
     book = cylinder(pos = vector(Bs, Bc, 0), axis = vec(Bw, 0, 0), radius = Bh, color = color.yellow)     book = cylinder(pos = vector(Bs, Bc, 0), axis = vec(Bw, 0, 0), radius = Bh, color = color.yellow)
     t=t+1     t=t+1
 +ballstopx = Bs - Bw/2 - R1L/2
 t=t+1 t=t+1
  
Line 326: Line 317:
 BaY = R1h+Bh + BaR/2 BaY = R1h+Bh + BaR/2
 ball =  sphere(pos=vec(BaX,​BaY,​0),​ radius = BaR/2, color=color.red) ball =  sphere(pos=vec(BaX,​BaY,​0),​ radius = BaR/2, color=color.red)
 +
 +#draw ramp 2 **
 +R2h = Tt + Bh/2
 +R2s = Bs + Bw + R1X + R2L/2
 +ramp2 = box(pos = vector(R2s, R2h, 0), size = vector(R2L, Bh*4, 10), color = color.orange)
 +
 +##########################################​
 +
 +#MOVEMENT COMMANDS LOCATED BELOW###############################################################################​
 +
 +
 +#Command for ball rolling down first ramp################################################### ​
  
 scene.camera.follow(ball) #this makes the camera follow the ball scene.camera.follow(ball) #this makes the camera follow the ball
-t=0 #reset counter to zero+t=0 #resets the time counter to 0 at the start of the loop 
 + 
 +theta = acos(R1X/​R1L) #this calculates angle of the ramp 
 +A1x = sin(theta)*cos(theta) #calculates x-value of acceleration 
 +A1y = sin(theta)*sin(theta) #calculates y-value of acceleration 
 + 
 +while t<​tFinal:​ #sets the condition for this command taking place 
 +    rate(20) #how many times per cycle the action will take place 
 +    ball.pos.x = ball.pos.x + S1x #updates the x position of the ball at rate listed above every sec 
 +    ball.pos.y = ball.pos.y - S1y #updates the y position of the ball at rate listed above every sec 
 +    S1x = S1x + A1x #adjusts the update position based on the x acceleration 
 +    S1y = S1y + A1y #adjusts the update position based on the y acceleration 
 +    t=t+1 #makes it so ever cycle it adds 1 to the time counter 
 + 
 +    if ball.pos.x > R1s + R1X: #sets condition for when the ball's x position reaches the end of the ramp  
 +        t=tFinal #sets the timer to the final value, so the loop stops 
 ###########################################################################################​ ###########################################################################################​
  
-#Command for ball rolling down first ramp##################################################​ +#Command for our second stage animation####################################################​
-while t<​tFinal:​ +
-    rate(20) ​#how many times per second the action will take place +
-    ball.pos.x = ball.pos.x + S1x +
-    ball.pos.y = ball.pos.y - S1y +
-    S1x = S1x + A1x +
-    S1y = S1y + A1y +
-    t=t+1+
  
-#Stopping ball motion at end of ramp #see if the ball is at the position of the ramp + rampx (total position on the screen is the two combined+t=0 #reset counter for second loop 
 +S2x = S1x # carries over x-value speed from end of ramp 
 +S2y = 0 #stop vertical movement of the ball as we hit the flat section
  
-    ​if ball.pos.x > R1s R1X+while t<​tFinal2:#​sets the condition for this command taking place 
-        t=tFinal ​</​code>​+  rate(20) #how many timeps per cycle the action will take place 
 +  ball.pos.x = ball.pos.x + S2x #updates the x position of the ball at rate above 
 +  ball.pos.y = ball.pos.y + S2y #updates the y position of the ball at the rate above 
 +  ​if ball.pos.x > R2s .5*R2L - BaR*.5#sets condition for when ball reaches end of plane 
 +    t = tFinal2 #sets timer to the final for section 2 when above condition is met 
 +  t=t+1 #increases the time counter by 1 every time loop runs 
 +   
 +###########################################################################################​</​code>​
  
 ---- ----
  • repository/ball_on_a_ramp.1616627172.txt.gz
  • Last modified: 2021/03/24 23:06
  • by porcaro1