Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from visual import *
- from visual.graph import *
- scene.width = 800
- scene.height = 800
- scene.range = (16,16,16)
- scene.autoscale = 0
- scene.center = (0, 12,0)
- scene.background = color.white
- ball = sphere(radius=1.0, color=color.red, pos=(0,1,0))
- wallG = box(pos=(0,-0.1,0), size=(24,0.2,5), color=color.green)
- accel = vector(0,-9.8,0)
- ball.velocity = vector(0,15,0)
- dt=0.05
- t=0
- display2 = gdisplay(background=color.white, foreground=color.black)
- poscurve = gcurve(color=color.blue)
- velcurve = gcurve(color=color.red)
- analposcurve = gcurve(color=color.green)
- while t < 3.1:
- rate(100)
- ball.velocity = ball.velocity + accel*dt
- ball.pos = ball.pos + ball.velocity*dt
- t = t + dt
- poscurve.plot(pos=(t, ball.pos.y))
- analposcurve.plot(pos=(t, 1 + 15*t + 0.5*accel.y*t**2))
- if ball.pos.y - ball.radius < wallG.pos.y:
- ball.velocity = -ball.velocity
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement