from visual import * # Create objects: ground, package, and plane # Ground is at y=0 # Package initial height is 1000 m # Package size is enlarged for viewing. For calculations, consider it to be 2 m diameter # For visibility, plane's height is 1050 m, slightly above the package ground = box(pos=vector(0,0,0), length = 2000, height = 10, width = 1000, color=color.green) package = sphere(pos=vector(-1000, 1000, 0), radius = 25, color=color.yellow) plane = box(pos=vector(-1000,1050,0), length = 100, height = 50, width = 50, color=color.red) # Turn off autoscaling scene.autoscale = 0 # Create trails for plane and package planetrail = curve(color=plane.color) packagetrail = curve(color=package.color) packagetrail_drop = curve(color=color.cyan) # Constants g = 9.81 # strength of gravitational field near Earth's surface in N/kg # Initial velocity of the plane and package plane.v = vector(90,0,0) #(About 200 mph) package.v = plane.v # Package has same initial velocity as plane # Initialize time, define time step t=0 deltat = 0.02 # Two while loops in this program. The first lasts for five (simulated) seconds, # and models the plane moving at a constant velocity with the package still # attached to the plane. while t < 5: rate(100) # update positions plane.pos = plane.pos + plane.v*deltat package.pos = package.pos + package.v*deltat # update trails planetrail.append(pos=plane.pos) packagetrail.append(pos=package.pos) # update time t=t+deltat # Change the color of the package to indicate it has been dropped package.color = color.cyan # Re-initialize time and elevation (t=0, y=1000) when package is dropped; # maintain the plane at the same horizontal velocity t=0 package.pos.y = 1000 plane.pos.y = 1050 #Establish initial vertical and horizontal velocities of the package package.v.y = 0 package.v.x = 90 # The second while loop, below, models the motion of the package (and the plane) # after the package is dropped. Motion coninues until the package's height reaches # zero. # MODIFY THE CODE IN THIS LOOP according to the instructions in the lab handout. while package.pos.y > 0: rate(25) #Update the positions of the package and the plane #Update vertical velocity of the package #Update the trails of the package and plane # Update time print "Package hit the ground in", t, "s" # In addition to time, print the final values of the following quantities: # magnitude of package velocity # x-component of package velocity # y-component of package velocity # x-position of plane # x-position of package