Ball Launch
Copy and paste the code from this GlowScript program. Click the button to launch the ball. Your goal is to hit the target.
Successful Attempt 1 | Successful Attempt 2 | Sucessful Attempt 3 | |
---|---|---|---|
Variable 1 | 1. | 1. | 1. |
Variable 2 | 2. | 2. | 2. |
Variable 3 | 3. | 3. | 3. |
Answer the following questions that are related to the program and projectile motion.
Extra: Within the code you’ll find a reference to the drag coefficient (line 27). Change the value to something between 0.01 and 0.001. Click to “Run this program”.
Successful Attempt 4 | |
---|---|
Variable 1 | 1. |
Variable 2 | 2. |
Variable 3 | 3. |
Variable 4 (Drag) | 4. |
GlowScript 2.7 VPython get_library('https://rawgit.com/perlatmsu/physutil/master/js/physutil.js') #objects x = 0 y = 0 ball = sphere(pos=vector(x,y,0), radius=10, color=vector(1,0,0), texture=textures.rough, make_trail=True) ballmass = 1 platform = box(pos=vector(0,-25,0), length=100, height=50, width=1, color=color.orange) pL = label(pos=vector(0,200,0), text='Click to Launch', space=30, height=16, border=4, font='sans') target = box(pos=vector(800,-25,0), length=100, height=50, width=1, color=vector(0.8,0.8,0)) tL = label(pos=vector(800,-75,0), text='Target', space=30, height=16, border=4, font='sans') #Window setup scene.range = 480 scene.center = vector(400,100,0) scene.width = 960 scene.height = 600 scene.background = vector(0.5,0.5,0.5) #Parameters and Initial Conditions g = vector(0,-10,0) #Free Fall acceleration b = 0 #Drag coefficient #Time and time step t = 0 tf = 10 dt = 0.01 #velocity v0 = 100 theta = 45 vx = v0*cos(theta*pi/180) vy = v0*sin(theta*pi/180) ballv = vector(vx,vy,0) #motion map motionmapv = MotionMap(ball, tf, 5, markerScale=.8, markerColor=color.green, labelMarkerOrder=False) motionmapa = MotionMap(ball, tf, 5, markerScale=6, markerColor=color.blue, labelMarkerOrder=False) #graph gd = graph(width=600, height=250, title='<b>Horizontal Range vs. Time</b>', xtitle='<i>time</i>', ytitle='<i>Horizontal Range</i>', foreground=color.black, background=color.white, xmin=0, xmax=15, ymin=0, ymax=1000) rangecurve = gcurve(color=color.red) gd = graph(width=600, height=250, title='<b>Height vs. Time</b>', xtitle='<i>time</i>', ytitle='<i>Height</i>', foreground=color.black, background=color.white, xmin=0, xmax=15, ymin=0, ymax=1000) heightcurve = gcurve(color=color.green) ev = scene.waitfor('click') while ball.pos.y >= 0: rate(500) Fgrav = ballmass*g Fnet = Fgrav balla = Fnet/ballmass ball.pos = ball.pos + ballv*dt ballv = ballv + balla*dt motionmapv.update(t, ballv) motionmapa.update(t, balla) rangecurve.plot(t,ball.pos.x) heightcurve.plot(t,ball.pos.y) t = t + dt print (x) print (y) print (vx) print (vy) print (t)
Successful Attempt 1 | Successful Attempt 2 | Successful Attempt 3 | |
---|---|---|---|
Initial Speed (m/s) | 95 | 90 | 115 |
Launch Angle (°) | 60 | 45 | 30 |
Free Fall Acceleration (m/s2) | -10 | -10 | -14 |
Successful Attempt 4 | |
---|---|
Launch Speed (m/s) | 120 |
Launch Angle (°) | 50 |
Free Fall Acceleration (m/s2) | -10 |
Drag Coefficient (-) | 0.008 |
GlowScript 2.7 VPython get_library('https://rawgit.com/perlatmsu/physutil/master/js/physutil.js') #objects x = 0 y = 0 ball = sphere(pos=vector(x,y,0), radius=10, color=vector(1,0,0), texture=textures.rough, make_trail=True) ballmass = 10 platform = box(pos=vector(0,-25,0), length=100, height=50, width=1, color=color.orange) pL = label(pos=vector(0,200,0), text='Click to Launch', space=30, height=16, border=4, font='sans') target = box(pos=vector(800,-25,0), length=100, height=50, width=1, color=vector(0.8,0.8,0)) tL = label(pos=vector(800,-75,0), text='Target', space=30, height=16, border=4, font='sans') #Window setup scene.range = 480 scene.center = vector(400,100,0) scene.width = 960 scene.height = 600 scene.background = vector(0.5,0.5,0.5) #Parameters and Initial Conditions g = vector(0,-8,0) #Free Fall acceleration b = 0.000 #Drag coefficient #Time and time step t = 0 tf = 10 dt = 0.01 #velocity v0 = 60 theta = 55 vx = v0*cos(theta*pi/180) vy = v0*sin(theta*pi/180) ballv = vector(vx,vy,0) #motion map motionmapv = MotionMap(ball, tf, 5, markerScale=.8, markerColor=color.green, labelMarkerOrder=False) motionmapa = MotionMap(ball, tf, 5, markerScale=6, markerColor=color.blue, labelMarkerOrder=False) #graph gd = graph(width=600, height=250, title='<b>Horizontal Range vs. Time</b>', xtitle='<i>time</i>', ytitle='<i>Horizontal Range</i>', foreground=color.black, background=color.white, xmin=0, xmax=15, ymin=0, ymax=1000) rangecurve = gcurve(color=color.red) gd = graph(width=600, height=250, title='<b>Height vs. Time</b>', xtitle='<i>time</i>', ytitle='<i>Height</i>', foreground=color.black, background=color.white, xmin=0, xmax=15, ymin=0, ymax=1000) heightcurve = gcurve(color=color.green) ev = scene.waitfor('click') while ball.pos.y >= 0: rate(500) Fgrav = ballmass*g Fdrag = -b*ballv*mag(ballv) Fnet = Fgrav + Fdrag balla = Fnet/ballmass ball.pos = ball.pos + ballv*dt ballv = ballv + balla*dt motionmapv.update(t, ballv) motionmapa.update(t, balla) rangecurve.plot(t,ball.pos.x) heightcurve.plot(t,ball.pos.y) t = t + dt print (x) print (y) print (vx) print (vy) print (t)