GlowScript 2.9 VPython get_library('https://cdn.rawgit.com/PERLMSU/physutil/master/js/physutil.js') #Window setup scene.width = 1024 scene.height = 768 scene.center = vector(600,0,0) #Objects cliff = box(pos=vector(-100,0,0), size=vec(200,800,0), color=color.white) ravine = box(pos=vector(245,-200, 0), size=vec(490,400,0), color=color.white) lake = box(pos=vector(940, -200, 0), size=vec(900,400,0), color=color.blue) runawaycraft = sphere(pos=vector(-200,400,0), radius=10, color=color.red) rescuecraft = sphere(pos=vector(-200,400,0), radius=10, color=color.green) # Use runaway as template to add rescue #Parameters and Initial Conditions g = vector(0,-9.81,0) b = 0 #Drag coefficient runawaycraftm = 1500 runawaycraftv = vector(53.64,0,0) # change velocity to calculated value from part A runawaycraftp = runawaycraftm*runawaycraftv # Add the next 5 lines for the rescue craft initialed values: rescuecraftm = 1900 rescuecraftv = vector(116.366,0,0) rescuecraftp = rescuecraftm*rescuecraftv rescuecrafta = vector(0.2093,0,0) rescuecraftF = rescuecraftm*rescuecrafta #Time and time step t=0 tf=5 dt = 0.01 #MotionMap/Graph runawaycraftMotionMap = MotionMap(runawaycraft, tf, 5, markerScale=1, labelMarkerOrder=False, markerColor=color.orange) # Use runaway motionmap as template for: rescuecraftMotionMap = MotionMap(rescuecraft, tf, 5, markerScale=1, labelMarkerOrder=False, markerColor=color.orange) #Calculation Loop while runawaycraft.pos.x < 0: rate(500) Fgrav = runawaycraftm*g Fground = -Fgrav Fnet = Fgrav + Fground runawaycraftp = runawaycraftp + Fnet*dt runawaycraft.pos = runawaycraft.pos + (runawaycraftp/runawaycraftm)*dt runawaycraftMotionMap.update(t, runawaycraftp/runawaycraftm) t = t + dt # Use given while as tempate for the next 8 lines # Modify conditional to pos.y and remove ground force while runawaycraft.pos.y > 0: rate(500) Fgrav = runawaycraftm*g Fnet = Fgrav runawaycraftp = runawaycraftp + Fnet*dt runawaycraft.pos = runawaycraft.pos + (runawaycraftp/runawaycraftm)*dt runawaycraftMotionMap.update(t, runawaycraftp/runawaycraftm) t = t + dt # Use the 2 working runaway while loops as template to add the following 2 resucue while loops while rescuecraft.pos.x < 0: rate(500) Fgrav = rescuecraftm*g Fground = -Fgrav Fnet = Fgrav + Fground + rescuecraftF rescuecraftp = rescuecraftp + Fnet*dt rescuecraft.pos = rescuecraft.pos + (rescuecraftp/rescuecraftm)*dt rescuecraftMotionMap.update(t, rescuecraftp/rescuecraftm) t = t + dt while rescuecraft.pos.y > 0: rate(500) Fgrav = rescuecraftm*g Fnet = Fgrav # May include rescuecraftF here too rescuecraftp = rescuecraftp + Fnet*dt rescuecraft.pos = rescuecraft.pos + (rescuecraftp/rescuecraftm)*dt rescuecraftMotionMap.update(t, rescuecraftp/runawaycraftm) t = t + dt