from visual import* from visual.graph import * scene.height = 600 scene.width = 800 scene.autoscale = 0 floor = box(pos=(-1,0,0),length=10, width = 10, height = 0.1) ramp = box(pos=(0,1.71,0), axis=(5,1.71,0), length=10, height=.1, width=2) block = box(pos=(-4.5,0.25,0), axis=(5,1.71,0), length=0.50, height=.25, width=.5, color=color.red) block.vel = vector(4.698,1.710,0) # initial velocity #block.accel = vector(4.698,1.710,0) # a = g(sin()-mu*cos()) mu = 0.1 # coeffficient of friction mass = 0.100 # mass of box g = -9.81 graph1 = gdisplay(x=0, y=0, width=600, height=550, title='Velocity vs. Time', xtitle='t(s)', ytitle='V (m/s)', xmax=4., xmin=0., ymax=2, ymin=-0, foreground=color.white, background=color.black) velPlot = gcurve(color=color.red) dt = 0.01 time = 0 while block.y >0.2: rate(100) if scene.mouse.clicked: if block.vel.y > 0: a = g*(sin(20*pi/180)+mu*cos(20*pi/180)) else: a = g*(sin(20*pi/180)-mu*cos(20*pi/180)) block.accel = vector(a*cos(20*pi/180),a*sin(20*pi/180),0) block.pos = block.pos + block.vel*dt block.vel = block.vel + block.accel*dt time = time + dt velPlot.plot(pos=(time,block.y))