—-
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.
GlowScript 2.7 VPython get_library('https://rawgit.com/perlatmsu/physutil/master/js/physutil.js') #Window setup scene.width = 800 scene.height = 150 scene.center = vec(50,5,0) scene.background = color.white*0.5 #Objects (DO NOT ALTER THESE) floor = box(pos=vector(50,0,0), size=vec(160,1,2)) 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 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 #position labels L_start= label(pos=floor.pos, text='0', offset=0, yoffset=-10, space=10, height=16, border=4, font='sans') 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') #Time for Candace to get her camera t_CandaceDelay = 20 #Parameters and Initial Conditions P_F_v = vector(4,0,0) P_F_a = vector(0,0,0) Cand_v = vector(0,0,0) Cand_a = vector(2,0,0) #Time and time step t=0 dt = 0.01 #MotionMaps for P_F and Candace P_F_MotionMap = MotionMap(P_F, 1, 0.5, markerScale=0.75, labelMarkerOrder=False) Candace_MotionMap = MotionMap(Candace, 1, 0.5, markerScale=0.75, labelMarkerOrder=False, markerColor=color.cyan) #tells scene to wait for a click before while loop runs (DO NOT ALTER) scene.waitfor ('click') #Calculation Loops #Motion of P_F before Candace starts moving while t < t_CandaceDelay: rate(500) P_F_MotionMap.update(t, P_F.vel) #Update Phineas and Ferb MotionMap #motion of P_F and Candace once Candace starts moving while t >= t_CandaceDelay: rate(500) P_F_MotionMap.update(t, P_F.vel) Candace_MotionMap.update(t, Candace.vel) #Update Candace MotionMap if Candace.pos.x >= P_F.pos.x: #Stop the program print_options(height=120) #Sets the height of our print box label_PFfinal = label(pos=vec(P_F.pos.x,0,0), text=P_F.pos.x, yoffset=-10, border=1, box=False) scene.pause() t = t + dt
GlowScript 2.7 VPython get_library('https://rawgit.com/perlatmsu/physutil/master/js/physutil.js') #Window setup scene.width = 800 scene.height = 150 scene.center = vec(50,5,0) scene.background = color.white*0.5 #Objects floor = box(pos=vector(50,0,0), size=vec(160,1,2)) 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") 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") #position labels label_PFstart = label(pos=vec(P_F.pos.x,0,0), text='-20', yoffset=-10, border=1, box=False) label_0 = label(pos=vec(0,0,0), text='0', yoffset=-10, border=1, box=False) #Time for Candace to get her camera t_CandaceDelay = 20 #Parameters and initial conditions P_F.vel = vector(4,0,0) P_F.acc = vector(0,0,0) Candace.vel = vector(0,0,0) Candace.acc = vector(2,0,0) #Time and time step t=0 dt = 0.01 #MotionMaps for P_F and Candace P_F_MotionMap = MotionMap(P_F, 1, 0.5, markerScale=0.75, labelMarkerOrder=False) Candace_MotionMap = MotionMap(Candace, 1, 0.5, markerScale=0.75, labelMarkerOrder=False, markerColor=color.cyan) #tells scene to wait for a click before while loop runs (DO NOT ALTER) scene.waitfor ('click') #While loops to run the program while t < t_CandaceDelay: rate(500) P_F.pos = P_F.pos + P_F.vel*dt #Update P_F position P_F_MotionMap.update(t, P_F.vel) #Update P_F MotionMap t = t + dt label_PFpos = label(pos=vec(P_F.pos.x,0,0), text=P_F.pos.x, yoffset=-10, border=1, box=False) while t >= t_CandaceDelay: #Candace starts moving after some time delay rate(500) P_F.pos = P_F.pos + P_F.vel*dt #Update P_F position P_F_MotionMap.update(t, P_F.vel) Candace.vel = Candace.vel + Candace.acc*dt #Update Candace velocity Candace.pos = Candace.pos + Candace.vel*dt #Update Candace position Candace_MotionMap.update(t, Candace.vel) #Update Candace MotionMap if Candace.pos.x >= P_F.pos.x: #Stop the program print_options(height=120) #Sets the height of our print box print("Final position = ", P_F.pos.x, "m") print("Phineas and Ferb's final velocity = ", P_F.vel.x, "m/s") print("Candace's final velocity = ",Candace.vel.x, "m/s") print("Candace's acceleration = ",Candace.acc.x, "m/s2") print("Final time = ", t, "s") label_PFfinal = label(pos=vec(P_F.pos.x,0,0), text=P_F.pos.x, yoffset=-10, border=1, box=False) scene.pause() t = t + dt