## Model 2: Projectile Motion ## Author: M. Haley from __future__ import division from visual import * ## CONSTANTS g = 9.8 ## gravitational acceleration on Earth ## OBJECTS AND INITIAL VALUES track = box(pos=vector(0,-.05,0), size=(2.0,0.05,.10), color=color.white) cart = box(pos=vector(-1,0,0), size=(.1,.04,.06), color=color.green) cart.m = 1 ## Initialize with initial speed and angle v0 = 5 theta = radians(0) ## argument in degrees ## components of initial velocity v0x = v0*cos(theta) v0y = v0*sin(theta) v0z = 0 ## Define initial cart momentum using mass and velocity #cart.p = print 'initial cart momentum =', cart.p ## create object that draws a trail behind cart trail = curve(color=cart.color) ## Define the initial time and time step size deltat = .01 t = 0 ## CALCULATIONS #while t < 10: # print 'the time is now', t # Fnet = vector(0,0,0) # ## momentum update # #cart.p = # ## position update # #cart.pos = # ## update trail # trail.append(pos=cart.pos) # ## advance time # t = t + deltat # rate(100) #print 'After the loop. The final time is', t